]> git.pld-linux.org Git - packages/samba.git/blobdiff - smb.init
- use functions
[packages/samba.git] / smb.init
index c55adf9bf01aae650fcf349eb64581348fc5cc5a..5b906c0f93e970f095ecec37d23102bc147a292d 100644 (file)
--- a/smb.init
+++ b/smb.init
@@ -36,24 +36,24 @@ unset TMP || :
 # Check that smb.conf exists.
 [ -f /etc/samba/smb.conf ] || exit 0
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+start() {
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/smb ]; then
                msg_starting smbd
-               daemon smbd -D
+               daemon /usr/sbin/smbd -D
                RETVAL=$?
                msg_starting nmbd
-               daemon nmbd -D
+               daemon /usr/sbin/nmbd -D
                [ $RETVAL -eq 0 ] && RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/smb
+               if [ $RETVAL -eq 0 ]; then
+                       touch /var/lock/subsys/smb
+               fi
        else
                msg_already_running smb
        fi
-       ;;
-  stop)
+}
+
+stop() {
        # Stop daemons.
        if [ -f /var/lock/subsys/smb ]; then
                msg_stopping smbd
@@ -64,19 +64,33 @@ case "$1" in
        else
                msg_not_running smb
        fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/smb ]; then
+               stop
+               start
+       else
+               msg_not_running smb
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
-  status)
-       status smbd
-       RETVAL=$?
-       status nmbd
-       RET=$?
-       [ $RETVAL -eq 0 ] && RETVAL=$RET
-       smbstatus
+  stop)
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
-       exit $?
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
        ;;
   reload|force-reload)
        if [ -f /var/lock/subsys/smb ]; then
@@ -84,12 +98,20 @@ case "$1" in
                killproc smbd -HUP
                RETVAL=$?
        else
-               msg_not_running smb >&2
+               msg_not_running smb
                exit 7
        fi
        ;;
+  status)
+       status smbd
+       RETVAL=$?
+       status nmbd
+       RET=$?
+       [ $RETVAL -eq 0 ] && RETVAL=$RET
+       smbstatus
+       ;;
   *)
-       msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
        exit 3
 esac
 
This page took 0.040023 seconds and 4 git commands to generate.