设置samba的两个必须的daemon文件smbd和nmbd为开机自启动的话就方便很多了。
1. 在/etc/rc.d/init.d/目录下,touch一个新的脚本文件:smb
2. 编辑smb:
#!/bin/sh
#
# chkconfig: - 91 35
# description: Starts and stops the Samba smbd and nmbd daemons \
# used to provide SMB network services.
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# Check that smb.conf exists.
[ -f /usr/local/samba/lib/smb.conf ] || exit 0
RETVAL=0
# See how we were called.
case "$1" in start) echo -n "Starting SMB services: " daemon /usr/local/samba/sbin/smbd -D RETVAL=$? echo echo -n "Starting NMB services: " daemon /usr/local/samba/sbin/nmbd -D RETVAL2=$? echo [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/smb || \ RETVAL=1 ;; stop) echo -n "Shutting down SMB services: " killproc smbd RETVAL=$? echo echo -n "Shutting down NMB services: " killproc nmbd RETVAL2=$? [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/smb echo "" ;; restart) $0 stop $0 start RETVAL=$? ;; reload) echo -n "Reloading smb.conf file: " killproc -HUP smbd RETVAL=$? echo ;; status) status smbd status nmbd RETVAL=$? ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac
exit $RETVAL
|
3. 给这个脚本文件赋予执行权限:
# chmod 700 /etc/rc.d/init.d/smb |
4. 为Samba建立rc.d的链接:
5. 在重启服务的时候Samba脚本不会自动启动smbd和nmbd两个。可以通过下面的命令改变这个情况:
# chkconfig --level 345 smb on |
6. 在脚本中可以看到它可以接受四个参数,意思非常明了。
现在就可以通过如下的命令启动Samba服务了:
# /etc/rc.d/init.d/smb start |
当有如下显示时,就表示脚本编写成功,服务启动了
Starting SMB services: [ OK ]
Starting NMB services: [ OK ] |
阅读(2645) | 评论(0) | 转发(0) |