debian packagin updates from Eloy
[Samba.git] / packaging / Debian / debian / samba.init
blob00b8dcbb100a35a48c93ac7dc0141657811ba76c
1 #!/bin/sh
3 # Start/stops the Samba daemons (nmbd and smbd).
7 # Defaults
8 RUN_MODE="daemons"
10 # Reads config file (will override defaults above)
11 [ -r /etc/default/samba ] && . /etc/default/samba
13 NMBDPID=/var/run/samba/nmbd.pid
14 SMBDPID=/var/run/samba/smbd.pid
16 # clear conflicting settings from the environment
17 unset TMPDIR
19 # If Samba is running from inetd then there is nothing to do
20 if [ "$RUN_MODE" = "inetd" ]; then
21 # INIT_VERSION is defined for scripts than run directly from init...
22 if [ "$INIT_VERSION" = "" ]; then
23 cat <<EOF
25 Warning: Samba is set to start from inetd; this script has no effect.
26 Run "dpkg-reconfigure samba" if you want Samba to be started and stopped
27 from this script. If you want to continue running Samba from inetd, you
28 should use "killall nmbd smbd" to restart the service, or update-inetd
29 to disable/reenable it.
31 EOF
33 exit 0
36 # See if the daemons are there
37 test -x /usr/sbin/nmbd -a -x /usr/sbin/smbd || exit 0
39 case "$1" in
40 start)
41 echo -n "Starting Samba daemons:"
43 echo -n " nmbd"
44 start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- -D
46 echo -n " smbd"
47 start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- -D
49 echo "."
51 stop)
52 echo -n "Stopping Samba daemons: "
54 start-stop-daemon --stop --quiet --pidfile $NMBDPID
55 # Wait a little and remove stale PID file
56 sleep 1
57 if [ -f $NMBDPID ] && ! ps h `cat $NMBDPID` > /dev/null
58 then
59 # Stale PID file (nmbd was succesfully stopped),
60 # remove it (should be removed by nmbd itself IMHO.)
61 rm -f $NMBDPID
63 echo -n "nmbd "
65 start-stop-daemon --stop --quiet --pidfile $SMBDPID
66 # Wait a little and remove stale PID file
67 sleep 1
68 if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID` > /dev/null
69 then
70 # Stale PID file (nmbd was succesfully stopped),
71 # remove it (should be removed by smbd itself IMHO.)
72 rm -f $SMBDPID
74 echo "smbd."
77 reload)
78 echo -n "Reloading /etc/samba/smb.conf (smbd only)"
79 start-stop-daemon --stop --signal HUP --pidfile $SMBDPID
81 echo "."
83 restart|force-reload)
84 $0 stop
85 sleep 1
86 $0 start
89 echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload}"
90 exit 1
92 esac
94 exit 0