#!/bin/sh 
#
# rwhod++	Startup script for the rwhod server.
#
#		Modified for math.tu-berlin
#		by Sebastian Kolbe <sko@pool.math.tu-berlin.de>
#		Based on initscript for rwhod:
#		Modified for rwhod
#		by Herbert Xu <herbert@debian.org>
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
#
# Version:	Wed Feb 16 20:46:20 CET 2005

PATH=/bin:/sbin:/usr/bin:/usr/sbin

DESC="System status server"
CMDDIR="/opt/rwhod"
DAEMONBIN="${CMDDIR}/rwhod++"
UPDATEBIN="updateSpooldir.sh"
DAEMONUSER="daemon"
OPTIONS="-t 120 -s /opt/rwhod/spool $CMDDIR/Lokale_Rechner $CMDDIR/Andere_Rechner"

test -x ${DAEMONBIN} || exit 0

start_stop() {
	case "$1" in
	start)
		printf "Starting $DESC:"
#		su $DAEMONUSER -c "${CMDDIR}/${UPDATEBIN} > /dev/null 2>&1 < /dev/null &"
		start-stop-daemon --start --oknodo --chuid $DAEMONUSER --quiet \
				  --exec ${DAEMONBIN} -- $OPTIONS
		printf " rwhod++"
		printf ".\n"
		;;
	stop)
		printf "Stopping $DESC:"
#		killall -1 ${UPDATEBIN} > /dev/null 2>&1
		start-stop-daemon --stop --oknodo --quiet \
				  --exec ${DAEMONBIN}
		printf " rwhod++"
		printf ".\n"
		;;
	restart | force-reload)
		start_stop stop
		sleep 1
		start_stop start
		;;
	*)
		printf "Usage: $0 {start|stop|restart|force-reload}\n" >&2
		exit 1
		;;
	esac
}

start_stop "$@"

exit 0
