#!/bin/bash
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#               Sagator version by Tamet Vincent
#
# Version:	1.1 20051130

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="/usr/sbin/sagator"
CHROOT="/var/spool/vscan"
NAME="sagatord"
DESC="sagator daemon, an interface for postfix and antivirus"
OPTS=""
PIDFILE="/var/run/sagator.pid"

test -f $DAEMON || exit 0

[ -f /etc/default/sagator ] && . /etc/default/sagator

start()
{
if start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" \
    --exec $DAEMON -- $OPTS ; then
   echo "$NAME."
else
   echo "."
fi
}

stop()
{
    if [ -f $PIDFILE ]; then
    	kill `cat $PIDFILE`
    	if $DAEMON --wait; then
            echo "$NAME."
        else
            echo "."
        fi
	rm -f "$PIDFILE"
    else
        echo "."
    fi
}

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start
	;;
  stop)
	echo -n "Stopping $DESC: "
	stop
	;;
  restart|force-reload)
	sh $0 stop
	sh $0 start
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit $RETVAL
