#!/bin/sh

. /etc/rc.common

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

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

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

NoService ()
{
	ConsoleMessage "Service is disabled in /etc/hostconfig
	
	Unable to start
	"
}

RunService "$1"
