clamav/clamd-wrapper
2011-01-08 10:47:53 +01:00

91 lines
2.0 KiB
Bash

#!/bin/bash
#
# Xchkconfig: - 75 35
# Xdescription: The clamd daemon listens for incoming connections on \
# Unix or TCP socket and scans files or directories on demand.
test "$CLAMD_SERVICE" || {
echo $"*** $0 can not be called in this way"
echo $"*** Please see /usr/share/doc/clamav-server-*/README how"
echo $"*** the clamav-server can be configured"
exit 6
}
# Source function library.
. /etc/init.d/functions
# Get config.
test -r /etc/sysconfig/network && . /etc/sysconfig/network
# Check that networking is up.
test "$NETWORKING" != "no" || exit 6
lockfile=/var/lock/subsys/clamd.${CLAMD_SERVICE}
sysconffile=/etc/sysconfig/clamd.${CLAMD_SERVICE}
procname=clamd.${CLAMD_SERVICE}
CLAMD_CONFIGFILE=/etc/clamd.d/${CLAMD_SERVICE}.conf
CLAMD_OPTIONS=
CLAMD_PIDFILE=/var/run/clamd.${CLAMD_SERVICE}/clamd.pid
## backward-compatibility check...
for i in /var/run/clamd.${CLAMD_SERVICE}/clamd.sock \
/var/run/clamav.${CLAMD_SERVICE}/clamd.sock; do
CLAMD_SOCKET=$i
test ! -e "$i" || break
done
test -f "$sysconffile" && . "$sysconffile"
RETVAL=0
prog="clamd.${CLAMD_SERVICE}"
start () {
echo -n $"Starting $prog: "
daemon --pidfile=${CLAMD_PIDFILE} \
exec -a $procname /usr/sbin/clamd \
${CLAMD_CONFIGFILE:+-c $CLAMD_CONFIGFILE} ${CLAMD_OPTIONS} --pid ${CLAMD_PIDFILE}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop () {
echo -n $"Stopping $prog: "
killproc -p ${CLAMD_PIDFILE} $procname
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}
reload() {
rc=0
echo -n $"Reloading $prog: "
killproc -p ${CLAMD_PIDFILE} $procname -HUP || rc=$?
echo
echo -n $"Loading new virus-database: "
killproc -p ${CLAMD_PIDFILE} $procname -USR2 || rc=$?
echo
return $rc
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start|stop|restart|reload)
$1 ;;
status)
status -p ${CLAMD_PIDFILE} $procname ;;
condrestart)
test ! -f $lockfile || restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 2
esac