配置您的/etc/rc.d/init.d/smb脚本文件以启动和停止 Sambasmbd和nmbd守护进程服务器自动地。创建smb脚本文件, touch/etc/rc.d/init.d/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 /etc/smb.conf ] || exit 0
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n "Starting SMB services: "
daemon smbd -D
RETVAL=$?
echo
echo -n "Starting NMB services: "
daemon 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
|
现在,使此脚本可执行并更改其默认权限
[root@deep ] /# chmod 700 /etc/rc.d/init.d/smb
|
创建符号
rc.dSamba 的链接,使用命令
[root@deep ] /# chkconfig --add smb
|
Samba 脚本不会在您重新启动服务器时自动启动 smbd 和 nmbd 守护程序。您可以通过执行以下命令将其更改为默认执行此操作
[root@deep ] /# chkconfig --level 345 smb on
|
使用以下命令手动启动 Samba 服务器
[root@deep ] /# /etc/rc.d/init.d/smb start
|
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
|
保护重要的配置文件,可以使用 immutable 位来防止意外删除或覆盖必须保护的文件。它还可以防止有人创建指向此文件的符号链接。一旦您的smb.conf和lmhosts文件已配置,最好使用像这样的命令来保护它们
[root@deep ] /# chattr +i /etc/smb.conf
[root@deep ] /# chattr +i /etc/lmhosts
|