import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
[metze/old/v3-2-winbind-ndr.git] / packaging / Debian / debian / samba.init
1 #!/bin/sh
2 #
3 # Start/stops the Samba daemons (nmbd and smbd).
4 #
5 #
6
7 # Defaults
8 RUN_MODE="daemons"
9
10 # Reads config file (will override defaults above)
11 [ -r /etc/default/samba ] && . /etc/default/samba
12
13 NMBDPID=/var/run/samba/nmbd.pid
14 SMBDPID=/var/run/samba/smbd.pid
15
16 # clear conflicting settings from the environment
17 unset TMPDIR
18
19 # See if the daemons are there
20 test -x /usr/sbin/nmbd -a -x /usr/sbin/smbd || exit 0
21
22 case "$1" in
23         start)
24                 echo -n "Starting Samba daemons:"
25
26                 echo -n " nmbd"
27                 start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- -D
28
29                 if [ "$RUN_MODE" != "inetd" ]; then
30                         echo -n " smbd"
31                         start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- -D
32                 fi
33
34                 echo "."
35                 ;;
36         stop)
37                 echo -n "Stopping Samba daemons: "
38
39                 start-stop-daemon --stop --quiet --pidfile $NMBDPID
40                 # Wait a little and remove stale PID file
41                 sleep 1
42                 if [ -f $NMBDPID ] && ! ps h `cat $NMBDPID` > /dev/null
43                 then
44                         # Stale PID file (nmbd was succesfully stopped),
45                         # remove it (should be removed by nmbd itself IMHO.)
46                         rm -f $NMBDPID
47                 fi
48                 echo -n "nmbd"
49
50                 if [ "$RUN_MODE" != "inetd" ]; then
51                         start-stop-daemon --stop --quiet --pidfile $SMBDPID
52                         # Wait a little and remove stale PID file
53                         sleep 1
54                         if [ -f $SMBDPID ] && ! ps h `cat $SMBDPID` > /dev/null
55                         then
56                                 # Stale PID file (nmbd was succesfully stopped),
57                                 # remove it (should be removed by smbd itself IMHO.)
58                                 rm -f $SMBDPID
59                         fi
60                         echo -n " smbd"
61                 fi
62
63                 echo "."
64
65                 ;;
66         reload)
67                 echo -n "Reloading /etc/samba/smb.conf (smbd only)"
68                 start-stop-daemon --stop --signal HUP --pidfile $SMBDPID
69
70                 echo "."
71                 ;;
72         restart|force-reload)
73                 $0 stop
74                 sleep 1
75                 $0 start
76                 ;;
77         *)
78                 echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload}"
79                 exit 1
80                 ;;
81 esac
82
83 exit 0