r19619: Add pointer to (up-to-date) packaging from the Debian Samba packaging repository.
[samba.git] / packaging / debian / samba-server.samba.init
1 #! /bin/sh
2
3 #
4 # Start/stops the Samba daemon (smbd).
5 # Adapted from the Samba 3 packages.
6 #
7
8 SMBDPID=/var/run/samba/smbd.pid
9
10 # clear conflicting settings from the environment
11 unset TMPDIR
12
13 # See if the daemon and the config file are there
14 test -x /usr/sbin/smbd -a -r /etc/samba/smb.conf || exit 0
15
16 . /lib/lsb/init-functions
17
18 case "$1" in
19         start)
20                 log_daemon_msg "Starting Samba 4 daemon" "smbd"
21                 
22                 if ! start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/smbd -- -D; then
23                         log_end_msg 1
24                         exit 1
25                 fi
26
27                 log_end_msg 0
28                 ;;
29         stop)
30                 log_daemon_msg "Stopping Samba 4 daemon" "smbd"
31
32                 start-stop-daemon --stop --quiet --pidfile $SMBDPID
33                 # Wait a little and remove stale PID file
34                 sleep 1
35                 if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID` > /dev/null
36                 then
37                         # Stale PID file (smbd was succesfully stopped),
38                         # remove it (should be removed by smbd itself IMHO.)
39                         rm -f $SMBDPID
40                 fi
41
42                 log_end_msg 0
43
44                 ;;
45         reload)
46                 log_daemon_msg "Reloading /etc/samba/smb.conf" "smbd only"
47
48                 start-stop-daemon --stop --signal HUP --pidfile $SMBDPID
49
50                 log_end_msg 0
51                 ;;
52         restart|force-reload)
53                 $0 stop
54                 sleep 1
55                 $0 start
56                 ;;
57         *)
58                 echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload}"
59                 exit 1
60                 ;;
61 esac
62
63 exit 0