#!/bin/sh
# description: Starts and stops the Samba smbd and nmbd daemons
# named this script as "smb" and put it into /etc/rc.d/init.d/
# don't forget to change it to executable file with "chmod 755 smb"
# config: /etc/samba/smb.conf
# Check that the Samba configuration file exists
[ -f /usr/local/samba/lib/smb.conf ] exit 0
start( )
{
echo -n "Starting SMB services: "
/usr/local/samba/bin/smbd -D
ERROR=$?
echo
echo -n "Starting NMB services: "
/usr/local/samba/bin/nmbd -D
ERROR2=$?
if [ $ERROR2 -ne 0 ]
then
ERROR=1
fi
echo
return $ERROR
}
stop( )
{
echo -n "Shutting down SMB services: "
/bin/kill -TERM -a smbd
ERROR=$?
echo
echo -n "Shutting down NMB services: "
/bin/kill -TERM -a nmbd
ERROR2=$?
if [ $ERROR2 -ne 0 ]
then
ERROR=1
fi
echo
return $ERROR
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: $0 {startstop}"
exit 1
esac
exit $?
----------------------------------------------------------------
还有些话要说
启动
# /etc/rc.d/init.d/smb start
Starting SMB services:
Starting NMB services:
# ps ax | grep mbd
1268 ? S 0:00 /usr/local/samba/bin/smbd -D
1270 ? S 0:00 /usr/local/samba/bin/nmbd -D
1465 pts/2 S 0:00 grep mbd
关闭
# /etc/rc.d/init.d/smb stop
Shutting down SMB services:
Shutting down NMB services:
最后我们还需要把它们添加到/etc/rc.d/rcX.d 目录中去以后就可以自动启动喽
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc3.d/S35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc5.d/S35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc0.d/K35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc1.d/K35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc2.d/K35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc4.d/K35smb
# ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc6.d/K35smb
没有评论:
发表评论