#! /bin/sh
#
# Copyright (c) 1998 Florian La Roche
#

WATCH=/var/lib/news/run/innwatch.pid
ACTIVED=/var/lib/news/run/actived.pid
PID=/var/lib/news/run/innd.pid
H=/usr/lib/news

case "$1" in
    start)	echo "Starting News-Server INN."
		if test "x$UID" = x0 ; then
			su news -c $H/bin/rc.news
		else
			$H/bin/rc.news
		fi
		;;
    stop)	echo "Shutting down News-Server INN."
		if test -f $PID ; then
			$H/bin/ctlinnd shutdown now ""
		fi
		if test -f $WATCH ; then
			kill -TERM `cat $WATCH`
		fi
		if test -f $ACTIVED ; then
			kill -TERM `cat $ACTIVED`
		fi
		;;
    reload)	if test -f $PID ; then
			killall -TERM -p`cat $PID` $H/bin/innd
		fi
		;;
    *)		echo "Usage: $0 {start|stop}"
		exit 1
esac

exit 0
