#! /bin/sh
#
# init.d/inn	Start/stop the news server.
#

test -f /usr/lib/news/bin/innd || exit 0

start () {
    start-stop-daemon --quiet --start --user news \
	--pidfile /var/run/news/innd.pid --startas /usr/lib/news/bin/rc.news
    sleep 1
}

stop () {
    if [ -f /var/run/news/innwatch.pid ]
    then
	start-stop-daemon --quiet --stop --pidfile /var/run/news/innwatch.pid
    fi
    start-stop-daemon --quiet --stop \
	--pidfile /var/run/news/innd.pid --exec /usr/lib/news/bin/innd
}

case "$1" in
    start)
	start
	;;
    stop)
	echo "Stopping news server: innd"
	stop
	;;
    restart|force-reload)
	stop
	sleep 2
	start
	;;
    *)
	echo "Usage: /etc/init.d/inn start|stop|restart|force-reload">&2
	exit 1
	;;
esac

exit 0
