5 # Required-Start: $network $local_fs $remote_fs
6 # Required-Stop: $network $local_fs $remote_fs
7 # Default-Start: 2 3 4 5
9 # Should-Start: slapd cups
10 # Should-Stop: slapd cups
11 # Short-Description: start Samba daemons (nmbd and smbd)
18 # Reads config file (will override defaults above)
19 [ -r /etc
/default
/samba
] && .
/etc
/default
/samba
22 NMBDPID
=$PIDDIR/nmbd.pid
23 SMBDPID
=$PIDDIR/smbd.pid
25 # clear conflicting settings from the environment
28 # See if the daemons are there
29 test -x /usr
/sbin
/nmbd
-a -x /usr
/sbin
/smbd ||
exit 0
31 .
/lib
/lsb
/init-functions
35 log_daemon_msg
"Starting Samba daemons"
36 # Make sure we have our PIDDIR, even if it's on a tmpfs
37 install -o root
-g root
-m 755 -d $PIDDIR
39 if [ -n `which testparm` ]
41 NMBD_DISABLED
=`testparm -s --parameter-name='disable netbios' 2>/dev/null`
43 if [ "$NMBD_DISABLED" != 'Yes' ]; then
44 log_progress_msg
"nmbd"
45 if ! start-stop-daemon
--start --quiet --oknodo --exec /usr
/sbin
/nmbd
-- -D
52 if [ "$RUN_MODE" != "inetd" ]; then
53 log_progress_msg
"smbd"
54 if ! start-stop-daemon
--start --quiet --oknodo --exec /usr
/sbin
/smbd
-- -D; then
63 log_daemon_msg
"Stopping Samba daemons"
64 log_progress_msg
"nmbd"
66 start-stop-daemon
--stop --quiet --pidfile $NMBDPID
67 # Wait a little and remove stale PID file
69 if [ -f $NMBDPID ] && ! ps h
`cat $NMBDPID` > /dev
/null
71 # Stale PID file (nmbd was succesfully stopped),
72 # remove it (should be removed by nmbd itself IMHO.)
76 if [ "$RUN_MODE" != "inetd" ]; then
77 log_progress_msg
"smbd"
78 start-stop-daemon
--stop --quiet --pidfile $SMBDPID
79 # Wait a little and remove stale PID file
81 if [ -f $SMBDPID ] && ! ps h
`cat $SMBDPID` > /dev
/null
83 # Stale PID file (nmbd was succesfully stopped),
84 # remove it (should be removed by smbd itself IMHO.)
93 if [ "$RUN_MODE" != "inetd" ]; then
94 log_daemon_msg
"Reloading /etc/samba/smb.conf" "smbd only"
96 start-stop-daemon
--stop --quiet --signal HUP
--pidfile $SMBDPID
101 restart|force-reload
)
108 NMBD_DISABLED
=`testparm -s --parameter-name='disable netbios' 2>/dev/null`
109 if [ "$NMBD_DISABLED" != "Yes" ]; then
110 status_of_proc
-p $NMBDPID /usr
/sbin
/nmbd nmbd || status
=$?
112 if [ "$RUN_MODE" != "inetd" ]; then
113 status_of_proc
-p $SMBDPID /usr
/sbin
/smbd smbd || status
=$?
115 if [ "$NMBD_DISABLED" = "Yes" -a "$RUN_MODE" = "inetd" ]; then
121 echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload|status}"