#!/bin/sh
#
# Startup script for the Clam AntiVirus Daemon
#
# chkconfig: 2345 79 30
# description: Clam AntiVirus Daemon is a TCP/IP or unix domain 
# socket protocol server.
# processname: clamd
# pidfile: /var/run/clamav/clamd.pid
# config: /etc/clamd.conf

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

# Source networking configuration.
. /etc/sysconfig/network

[ -x /usr/sbin/clamd ] || exit 0

# fix weird #6486
export ENV=""
export PWD=""
export HOME="/var/lib/clamav"
export TMPDIR="${HOME}"
export USER="clamav"
export USERNAME="${USER}"
export LOGNAME="${USER}"

# See how we were called.
case "$1" in
  start)
	gprintf "Starting Clam AntiVirus Daemon: "
	daemon clamd -c /etc/clamd.conf
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
	;;
  stop)
	gprintf "Stopping Clam AntiVirus Daemon: "
	killproc clamd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
	;;
  status)
	status clamd
	RETVAL=$?
	;;
  restart|reload)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  *)
	gprintf "Usage: clamd {start|stop|status|restart|reload}\n"
	exit 1
esac

exit $RETVAL
