#! /bin/sh
#
# Author: Baumgaertner, 2006
#
#
### BEGIN INIT INFO
# Provides:       SPAMASS
# Required-Start: $remote_fs
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    Start SPAMASS-milter
### END INIT INFO

SPAMASS_MILTER_BIN=/usr/local/sbin/spamass-milter
test -x $SPAMASS_MILTER_BIN || exit 5

. /etc/rc.config
#test "$START_SPAMASS" = yes || exit 0

# First reset status of this service
. /etc/rc.status

rc_reset

case "$1" in
    start)
    echo "Starting spam-scanning for sendmail (SPAMASS):"
    echo -n "   starting SPAMASS-milter"
    startproc -u vscan $SPAMASS_MILTER_BIN -p local:/var/spamd/spamass-milter.sock > /dev/null 2>&1 
    rc_status -v
;;
    stop)
    echo "Shutting down spam-scanning:"
    echo -n "   shutting down SPAMASS-milter"
    killproc -TERM $SPAMASS_MILTER_BIN 
    rc_status -v
;;
    try-restart)
    $0 status >/dev/null &&  $0 restart
    rc_status
;;                                             	
    restart)
    $0 stop
    $0 start  
    rc_status
;;
    force-reload)
    # SPAMASS-milter & SPAMASSd doesn't support SIGHUP currently
    $0 stop  &&  $0 start
    rc_status
;;                                                  	
    status)
    echo -n "Checking for service SPAMASS (SPAMASS-milter):"
    checkproc $SPAMASS_MILTER_BIN
    rc_status -v
;;
    *)
    echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload}"
    exit 1
esac

# Inform the caller not only verbosely and set an exit status.
rc_exit