-#!/bin/bash
+#!/bin/sh
#
-# chkconfig: 345 91 35
-# description: Starts and stops the Samba smbd and nmbd daemons \
-# used to provide SMB network services.
+# chkconfig: 345 91 35
+# description: Starts and stops the Samba smbd and nmbd daemons \
+# used to provide SMB network services.
+#
+# config: /etc/samba/smb.conf
+# config: /etc/samba/lmhosts
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
. /etc/sysconfig/samba
# Check that networking is up.
-[ "${NETWORKING}" = "no" ] && exit 0
+if is_no "${NETWORKING}"; then
+ msg_Network_Down smb
+ exit 1
+fi
+
+TMPDIR="/tmp"; export TMPDIR
# Check that smb.conf exists.
[ -f /etc/samba/smb.conf ] || exit 0
# See how we were called.
case "$1" in
start)
- show Starting smbd
- daemon $NICELEVEL smbd -D
- show Starting nmbd
- daemon $NICELEVEL nmbd -D
- touch /var/lock/subsys/smb
+ # Check if the service is already running?
+ if [ ! -f /var/lock/subsys/smb ]; then
+ msg_starting smbd
+ daemon $NICELEVEL smbd -D
+ msg_starting nmbd
+ daemon $NICELEVEL nmbd -D
+ if [ "$WINBINDD" = "yes" ]; then
+ msg_starting winbindd
+ daemon $NICELEVEL winbindd
+ fi
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb
+ else
+ msg_Already_Running smb
+ exit 1
+ fi
;;
stop)
- show Shutting down smbd
- killproc smbd
- show Shutting down nmbd
- killproc nmbd
- rm -f /var/lock/subsys/smb
+ # Stop daemons.
+ if [ -f /var/lock/subsys/smb ]; then
+ msg_stopping smbd
+ killproc smbd
+ msg_stopping nmbd
+ killproc nmbd
+ if [ "$WINBINDD" = "yes" ]; then
+ msg_stopping winbindd
+ killproc winbindd
+ fi
+ rm -f /var/lock/subsys/smb >/dev/null 2>&1
+ else
+ msg_Not_Running smb
+ exit 1
+ fi
;;
status)
status smbd
status nmbd
+ status winbindd
smbstatus
+ exit $?
;;
restart)
$0 stop
$0 start
;;
+ reload)
+ if [ -f /var/lock/subsys/smb ]; then
+ msg_reloading smb
+ killproc smbd -HUP
+ else
+ msg_Not_Running smb
+ exit 1
+ fi
+ ;;
*)
- echo "Usage: $0 {start|stop|restart|status}"
+ msg_Usage "$0 {start|stop|restart|reload|status}"
exit 1
esac
+exit $RETVAL