#!/bin/sh

# Startup spamd

. /etc/rc.common

PIDFILE=/var/run/spamd.pid
SPAMD=spamd

StartService ()
{
    if [ -r $PIDFILE ]; then
        ConsoleMessage "spamd already running"
    else
	ConsoleMessage "Starting spamd"
	$SPAMD -d -r $PIDFILE
    fi
}

StopService ()
{
    if [ -r $PIDFILE ]; then
        ConsoleMessage "Stopping spamd"
	kill -TERM `cat $PIDFILE`
    else
	ConsoleMessage "spamd not running"
    fi
}

RestartService ()
{
    if [ -r $PIDFILE ]; then
        ConsoleMessage "Restarting spamd"
        kill -HUP `cat $PIDFILE`
    else
        ConsoleMessage "spamd not running.  Starting"
	StartService
    fi
}

RunService "$1"
