#!/bin/sh
#
# /etc/rc.d/rc.wsdd2
#
# start/stop/restart the wsdd2 daemon.
#
# This init script ships as executable, and will start automatically if Samba
# is configured to start.

wsdd2_start() {
  if [ -r /etc/samba/smb.conf -a -x /etc/rc.d/rc.samba -a -x /usr/sbin/wsdd2 ]; then
    echo "Starting wsdd2:  /usr/bin/wsdd2 -d"
    /usr/sbin/wsdd2 -d
  fi
}

wsdd2_stop() {
  killall --ns $$ -TERM wsdd2 2> /dev/null
}

wsdd2_restart() {
  wsdd2_stop
  sleep 1
  wsdd2_start
}

case "$1" in
'start')
  # We don't want to run this more than once, so just use restart to start it:
  wsdd2_restart
  ;;
'stop')
  wsdd2_stop
  ;;
'restart')
  wsdd2_restart
  ;;
*)
  wsdd2_start
esac