#!/bin/sh -e
#start/stopping of bbbsd on a Debian Linux system.
#  bbbsd - 24 May 2003 - rjc

DAEMON=/opt/bbbs/scripts/sh/in.bbbsd

test -f $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting BBBS daemons "
    #  is the chuid needed here?
#    start-stop-daemon --start --background --chuid bbbs:bbbs --exec $DAEMON
    start-stop-daemon --start --exec $DAEMON
    echo "."
    ;;
  stop)
    echo -n "Stopping BBBS daemons "
    killall bbbsd
    ;;
  reload)
    echo -n "Reloading BBBS daemons "
    killall bbbsd
    sleep 1
    sh $0 start
    ;;
  restart|force-reload)
    sh $0 stop
    sleep 1
    sh $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/bbbsd {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0
