#! /bin/sh
#
# sagator	starts up the sagator antivirus/antispam engine
#
# Based on skeleton originally by Miquel van Smoorenburg and Ian Murdock,
#
### BEGIN INIT INFO
# Provides:		sagator
# Required-start:	$syslog $local_fs $remote_fs $named $network
# Required-stop:	$syslog $local_fs $remote_fs $named $network
# Should-start:		spamassassin spamd clamav clamd mysql postgresql
# Should-stop:		spamassassin spamd clamav clamd mysql postgresql
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	sagator
# Description:		Starts and stops SAGATOR antivirus/antispam engine.
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
PIDFILE="/var/run/sagator.pid"
DAEMON="/usr/sbin/sagator"
CHROOT="/var/spool/vscan"
OPTS=""

test -x $DAEMON || exit 0

set -e

. /lib/lsb/init-functions

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

case "$1" in
  start)
	log_begin_msg "Starting sagator"
	if $DAEMON $OPTS; then
		log_end_msg 0
	else
		log_end_msg 1
	fi
	;;
  stop)
	log_begin_msg "Stopping sagator"
	if [ -f $PIDFILE ]; then
		kill `cat $PIDFILE`
		if $DAEMON --wait; then
		    log_end_msg 0
		else
		    log_end_msg 1
		fi
		rm -f "$PIDFILE"
	else
		log_end_msg 0
	fi
	;;
  restart|force-reload)
	sh $0 stop
	sh $0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
