Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9241358
  • 博文数量: 187
  • 博客积分: 7517
  • 博客等级: 少将
  • 技术积分: 1981
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-20 18:51
文章分类

全部博文(187)

文章存档

2015年(3)

2013年(4)

2012年(20)

2011年(2)

2010年(96)

2009年(14)

2008年(47)

2007年(1)

我的朋友

分类: LINUX

2010-04-02 14:04:35

一 配置服务器流程如下

 

二 配置服务器过程

    首先查找samba的守护进程是否存在,若不存在,则安装samba软件(当然,前提是在某文件夹下存放了samba的安装软件,在这里将安装软件samba-3.0.25b.tar.gz与当前脚本文件放在同一文件夹下)。然后,清除防火墙规则,并启动samba服务器。

    在后面还给了一个简单的用以更新samba服务器配置的脚本。

#!/bin/bash

echo "set samba server for sharing document with Widows in local net"

smbserverfolder=/etc/init.d 

 #./smb

smbexefolder=/usr/sbin/     

 #./smbd ./nmbd

 

smbfolder=/etc/samba

smb=/etc/samba/smb.conf

#Samba have two server ---  smbd nmbd

if [ -r $smbfoler ] && [ -f $smb ] ; then 

echo "samba server has been installed, and will be opened"

else

echo "can't read $smbfolder or samba don't exist"

echo "install samba server ....."

#

#install samba server step...

#

smbdir=samba-3.0.25b

smbfile="$smbdir.tar.gz"

cp  "./$smbfile"  /tmp

cd /tmp

tar -zxvf "/tmp/$smbfile"

cd "./$smbdir/source"

./configure

make clean

make install

fi

 

#清除防火墙规则

echo "clear iptables rules....."

/sbin/iptables -F

 

echo "open samba server......"

#pgrep smbd -- pkill smbd ;pgrep nmbd -- pkill nmbd

/usr/sbin/smbd

/usr/sbin/nmbd

 

#查找是否有更新samba配置的脚本,若有则执行

if [ -f "./smb.confshare" ];then

echo "add share folder... and update samba setting ... "

./smb.confshare

else

echo "no script to add sharefolder , please manually add "

fi

 

#查找是否有用以挂载samba服务器的脚本,若有则执行

if [ -f "./smb.mounthosts" ];then

echo "mount all honts in this local net"

./smb.mounthosts

else

echo "no script to mount sharefolder ,please manually mount "

fi

 

 

-------------------------------------------------------------------

下面这个脚本名为smb.confshare,用以修改samba配置文件

 

#!/bin/bash

 

smbfolder=/etc/samba

smbconf=smb.conf

sharefolder=/home/sharedoc

 

 

echo "++++++++++++++++build share directory+++++++++++++++"

echo "/home/sharedoc"

echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"

#build a share doc in own host

if ( ! [ -d "$sharefolder" ]);then mkdir  "$sharefolder" ; fi

id nobody

chown -R nobody:nobody "$sharefolder"  

 

#set configure in samba for sharing directory

if [ -r "$smbfolder" ]; then

cd "$smbfolder"

mv "$smbconf" smbOLD.conf

cat > $smbconf << "EOF"

#++++++++++++write grant to smb.conf++++++++++++

[global]

workgroup = LinuxSir

server string = linux samba server

security = share

[linuxsharedoc]

path =$sharefolder

browseable = yes

guest ok = yes

writeable = yes

EOF

 

阅读(426) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~