#!/bin/sh
#
# freshclam      Start/Stop the freshclam.
#
# chkconfig: - 62 38
# description: freshclam is an update daemon for Clam AV database.
#
# processname: freshclam
# config: /etc/freshclam.conf
# pidfile: /var/run/clamav/freshclam.pid
#
# (c) 2004/05/17 Petr@Kristof.CZ under GNU GPL 2.0+
#

SYSTEMCTL_SKIP_REDIRECT=1

# Source function library
. /etc/init.d/functions

# Get network config
. /etc/sysconfig/network

test -f /etc/freshclam.conf || exit 0


RETVAL=0

start() {
	echo -n $"Starting freshclam: "
	# Start me up!
	daemon /usr/bin/freshclam -d -p /var/run/clamav/freshclam.pid
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
	return $RETVAL
}

stop() {
	echo -n $"Stopping freshclam: "
	killproc freshclam
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
	return $RETVAL
}	

restart() {
  	stop
	start
}	

reload() {
	echo -n $"Reloading DB: "
	killproc freshclam -ALRM
	RETVAL=$?
	echo
	return $RETVAL
}


case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
	status freshclam
	;;
  restart)
  	restart
	;;
  condrestart)
  	[ -f /var/lock/subsys/freshclam ] && restart || :
	;;
  reload)
	reload
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit $?

