#!/bin/sh -e
#
# Start and stop the Modula-3 Network Object agent daemon

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/netobjd
NAME=netobjd
DESC="Network Object agent daemon"

test -f $DAEMON || exit 0

ssd=`which start-stop-daemon`

case "$1" in
  start)
	echo -n "Starting $DESC: "
	su nobody -c "$ssd --start --quiet --exec $DAEMON" &
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --exec $DAEMON \
		--user nobody --name $NAME
	echo "$NAME."
	;;
  restart|force-reload)
  	$0 stop
	sleep 1
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
