#!/bin/sh

. /etc/rc.common

StartService ()
{
    if [ "${AMAVISCLAMAV:=-NO-}" = "-YES-" ]; then
	ConsoleMessage "Starting AMAVIS-CLAMAV"
	freshclam -d -p /var/clamav/freshclam.pid
	clamd
	su clamav -c amavisd
	fi
}

StopService ()
{
	ConsoleMessage "Stoping AMAVIS-CLAMAV"
	killall -u clamav
}

RestartService ()
{
    if [ "${AMAVISCLAMAV:=-NO-}" = "-YES-" ]; then
	ConsoleMessage "Reloading AMAVIS-CLAMAV"
	StopService
	StartService
    else
	StopService
	fi
}

RunService "$1"
