#!/bin/bash
#
#  /etc/rc.d/init.d/clamd
# 
#  clamd startup script
#
#  chkconfig: - 50 50
#  description: ClamAV Daemon
#  processname: clamd
#
###################
# source function library
. /etc/rc.d/init.d/functions

CLAMD=/usr/sbin/clamd
CLAMD_CONF=/etc/clamd.conf

# pull in sysconfig settings
[ -f /etc/sysconfig/clamd ] && . /etc/sysconfig/clamd

RETVAL=0
prog="ClamAV Daemon"

test -x $CLAMD || exit 0

start(){
    action $"Starting ${prog}:" ${CLAMD} -c ${CLAMD_CONF}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/clamd
}

stop(){
    echo $"Shutting down ${prog}"
    killproc ${CLAMD}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/clamd
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status $"${CLAMD}"
	RETVAL=$?
	echo
	;;
    restart)
	stop
	start
RETVAL=$?
;;
    reload)
	pid=`pidofproc ${CLAMD}`
	kill -USR2 ${pid}
	RETVAL=$?
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
exit 1
esac

exit $RETVAL

