#!/bin/sh
. /etc/rc.common
StartService ()
{
    if [ "${CLAMAV:=-NO-}" = "-YES-" ]; then
    ConsoleMessage "Starting ClamAV"
	freshclam -d
	clamd
	else
	NoService
    fi
}

StopService ()
{
    ConsoleMessage "Stoping ClamAV"
	if [ -f /var/clamav/clamd.pid ]; then kill -9 $(head -1 /var/clamav/clamd.pid);fi
	if [ -f /var/clamav/freshclam.pid ]; then kill -9 $(head -1 /var/clamav/freshclam.pid);fi
}

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

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

RunService "$1"
