clamav/clamav-clamd.initscript

72 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#
# clamd -- 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: /run/clamav/clamd.pid
# config: /etc/clamd.conf
# Source function library.
. /etc/rc.d/init.d/functions
NAME=clamd
DAEMON=/usr/sbin/$NAME
DAEMONPID=/var/run/clamav/$NAME.pid
DAEMONCONF=/etc/clamd.conf
OPTIONS="-c $DAEMONCONF"
[ -x $DAEMON ] || exit 0
# Source networking configuration.
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
# check if the clamv conf file is present
[ -r "$DAEMONCONF" ] || exit 0
USER=`grep '^User' $DAEMONCONF | awk '{ print $2}'`
LOGFILE=`grep '^LogFile ' $DAEMONCONF | awk '{ print $2}'`
case "$1" in
start)
echo -n $"Starting Clam AntiVirus Daemon: "
if [ "${LOGFILE}" ]; then
touch ${LOGFILE}
chown ${USER}:${USER} ${LOGFILE}
fi
daemon --pidfile=$DAEMONPID $DAEMON $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
;;
stop)
echo -n $"Stopping Clam AntiVirus Daemon: "
killproc -p $DAEMONPID $NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME $DAEMONPID
;;
restart|reload)
$0 stop
sleep 1
$0 start
;;
condrestart)
[ -e /var/lock/subsys/$NAME ] && $0 restart
;;
status)
statusproc $DAEMON
RETVAL=$?
;;
*)
echo $"Usage: ""/etc/init.d/$NAME {start|stop|status|restart|condrestart}"
exit 1
;;
esac
exit $RETVAL