Blame | Last modification | View Log | RSS feed
#!/bin/bash
#
# clamav This shell script takes care of starting and stopping
# clamav.
#
# chkconfig: - 61 39
# description: Clamav is a is a GPL anti-virus toolkit for UNIX.
# processname: clamav
# config: /etc/clamd.conf
# pidfile: /var/run/clamav/clamd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source clamav configureation.
if [ -f /etc/sysconfig/clamav ] ; then
. /etc/sysconfig/clamav
fi
[ -f /usr/sbin/clamd ] || exit 0
RETVAL=0
prog="clamd"
start() {
# Start daemons.
echo -n $"Starting $prog: "
daemon /usr/sbin/clamd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
if [ "$CLAMAV_MILTER" == "yes" ] ; then
echo -n $"Starting clamav-milter: "
daemon clamav-milter --config-file /etc/clamav-milter.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamav-milter
fi
echo -n $"Starting freshclam: "
touch /var/run/clamav/freshclam.pid
chown clamav:clamav /var/run/clamav/freshclam.pid
if [ -x /usr/bin/selinuxenabled ] && /usr/bin/selinuxenabled; then
/sbin/restorecon /var/run/clamav/freshclam.pid
fi
daemon --check freshclam \
/usr/bin/freshclam -d -c 24 \
--quiet \
-p /var/run/clamav/freshclam.pid \
--daemon-notify=/etc/clamd.conf
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc clamd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
if test -f /var/lock/subsys/clamav-milter; then
echo -n $"Shutting down clamav-milter: "
killproc clamav-milter
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamav-milter
fi
if test -f /var/run/clamav/freshclam.pid; then
echo -n $"Shutting down freshclam: "
killproc freshclam
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freshclam
fi
return $RETVAL
}
reload() {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
RETVAL=$?
;;
restart)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/clamd ]; then
stop
start
RETVAL=$?
fi
;;
status)
status clamd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL