ITPub博客

首页 > Linux操作系统 > Linux操作系统 > smb 执行档

smb 执行档

原创 Linux操作系统 作者:bontonpan 时间:2009-01-30 12:46:23 0 删除 编辑

#!/bin/sh
#
# chkconfig: 35 91 9
# description: Starts and stops the Samba /usr/sbin/smbd3 and /usr/sbin/nmbd3 daemons \
#              used to provide SMB network services.

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# 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


start() {
       # If CUPS is used as printing system, reload smb after a 1 minute delay
       # to allow the printers to appear properly as samba shares.
        if killall -0 cupsd 2>/dev/null; then
         ( sleep 60 && killproc /usr/local/samba/sbin/smbd -HUP 1>/dev/null) &
       fi
       export TMPDIR="/var/tmp"
        gprintf "Starting SMB services: "
        daemon /usr/local/samba/sbin/smbd -D
        RETVAL=$?
        echo
        gprintf "Starting NMB services: "
        daemon /usr/local/samba/sbin/nmbd -D
        RETVAL2=$?
        echo
        [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /usr/local/samba/var/locks/smb3 || \
           RETVAL=1
        return $RETVAL
}
stop() {
        gprintf "Shutting down SMB services: "
        killproc /usr/local/samba/sbin/smbd
        RETVAL=$?
echo
        gprintf "Shutting down NMB services: "
        killproc /usr/local/samba/sbin/nmbd
        RETVAL2=$?
        [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/locks/smb3
        echo ""
        return $RETVAL
}
restart() {
        stop
        start
}
reload() {
       export TMPDIR="/var/tmp"
        gprintf "Reloading smb.conf file: "
        killproc /usr/local/samba/sbin/smbd -HUP
        RETVAL=$?
        echo
        return $RETVAL
}
mdkstatus() {
        status /usr/local/samba/sbin/smbd
        status /usr/local/samba/sbin/nmbd
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  reload)
        reload
        ;;
  status)
        mdkstatus
        ;;
  condrestart)
        [ -f /var/lock/subsys/smb3 ] && restart || :
        ;;
  *)
gprintf "Usage: %s {start|stop|restart|status|condrestart}\n" "$0"
        exit 1
esac

exit $?

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11754813/viewspace-544784/,如需转载,请注明出处,否则将追究法律责任。

下一篇: winbindd 执行档
请登录后发表评论 登录
全部评论

注册时间:2009-01-30

  • 博文量
    51
  • 访问量
    37087