#!/bin/sh ### BEGIN INIT INFO # Provides: nmbd # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # X-Start-Before: smbd # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start Samba NetBIOS nameserver (nmbd) ### END INIT INFO setvar PIDDIR = '/var/run/samba' setvar NMBDPID = "$PIDDIR/nmbd.pid" # clear conflicting settings from the environment unset TMPDIR # See if the daemons are there test -x /usr/sbin/nmbd || exit 0 source /lib/lsb/init-functions match $1 { with start if init_is_upstart { exit 1 } setvar SERVER_ROLE = $(samba-tool testparm --parameter-name="server role" 2>/dev/null | tail -1) if test $SERVER_ROLE = "active directory domain controller" { exit 0 } if test -n $(which testparm) { setvar NMBD_DISABLED = $(testparm -s --parameter-name='disable netbios' ) } if test $NMBD_DISABLED != Yes { log_daemon_msg "Starting NetBIOS name server" nmbd # Make sure we have our PIDDIR, even if it's on a tmpfs install -o root -g root -m 755 -d $PIDDIR if ! start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/nmbd -- -D { log_end_msg 1 exit 1 } log_end_msg 0 } with stop if init_is_upstart { exit 0 } log_daemon_msg "Stopping NetBIOS name server" nmbd start-stop-daemon --stop --quiet --pidfile $NMBDPID # Wait a little and remove stale PID file sleep 1 if test -f $NMBDPID && ! ps h $(cat $NMBDPID) > /dev/null { # Stale PID file (nmbd was succesfully stopped), # remove it (should be removed by nmbd itself IMHO.) rm -f $NMBDPID } log_end_msg 0 with restart|force-reload if init_is_upstart { exit 1 } $0 stop sleep 1 $0 start with status status_of_proc -p $NMBDPID /usr/sbin/nmbd nmbd exit $? with * echo "Usage: /etc/init.d/nmbd {start|stop|restart|force-reload|status}" exit 1 } exit 0