#! /bin/sh # # clamd /etc/init.d/ initscript for clamd # PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin NAME="freshclam" DESC="clamav daemon" CONFIG=/etc/amavis/freshclam.conf DAEMON=/usr/local/bin/freshclam PIDFILE="`grep ^PidFile $CONFIG | sed -e 's/PidFile //'`" PARAMS="--daemon --quiet" test -f $DAEMON || exit 0 test -f $CONFIG || exit 0 START="--start --quiet --pidfile ${PIDFILE} --name ${NAME} --startas ${DAEMON} -- ${PARAMS}" set -e if grep -q "^Example" $CONFIG; then echo "Clamav is not configured." echo "Please edit $CONFIG and run '$0 start'" exit 0 fi case "$1" in start) echo -n "Starting $DESC: " if start-stop-daemon ${START} >/dev/null 2>&1 ; then echo "${NAME}." else if start-stop-daemon --test ${START} >/dev/null 2>&1 ; then echo "(failed)." exit 1 else echo "(already running)." exit 0 fi fi ;; stop) echo -n "Stopping $DESC: " if start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \ --name $NAME --retry 10 >/dev/null 2>&1 ; then echo "${NAME}." else if start-stop-daemon --test ${START} >/dev/null 2>&1 ; then echo "(not running)." exit 0 else echo "(failed)." exit 1 fi fi ;; restart|force-reload|reload) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|reload|restart|force-reload}" >&2 exit 1 ;; esac exit 0