#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DEBIAN_CONFIG=/etc/samba/debian_config
NMBDPID=/var/state/samba/nmbd.pid
SMBDPID=/var/state/samba/smbd.pid
unset TMPDIR
if [ ! -f $DEBIAN_CONFIG ]; then
echo "The file $DEBIAN_CONFIG does not exist! There is something wrong"
echo "with the installation of Samba on this system. Please re-install"
echo "Samba. I can't continue!!!"
exit 1
fi
. $DEBIAN_CONFIG
if [ "$run_mode" = "from_inetd" ]; then
exit 0
fi
test -x /usr/sbin/nmbd -a -x /usr/sbin/smbd || exit 0
case "$1" in
start)
echo -n "Starting Samba daemons:"
echo -n " nmbd"
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- -D
echo -n " smbd"
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- -D
echo "."
;;
stop)
echo -n "Stopping Samba daemons:"
echo -n " nmbd"
start-stop-daemon --stop --quiet --pidfile $NMBDPID
echo -n " smbd"
start-stop-daemon --stop --quiet --pidfile $SMBDPID
echo "."
;;
reload)
echo -n "Reloading /etc/samba/smb.conf (smbd only)"
start-stop-daemon --stop --signal HUP --pidfile $SMBDPID
echo "."
;;
restart|force-reload)
echo -n "Restarting Samba daemons:"
echo -n " nmbd"
start-stop-daemon --stop --quiet --pidfile $NMBDPID
sleep 2
start-stop-daemon --start --quiet --exec /usr/sbin/nmbd -- -D
echo -n " smbd"
start-stop-daemon --stop --quiet --pidfile $SMBDPID
sleep 2
start-stop-daemon --start --quiet --exec /usr/sbin/smbd -- -D
echo "."
;;
*)
echo "Usage: /etc/init.d/samba {start|stop|reload|restart|force-reload}"
exit 1
;;
esac
exit 0