From 1565969c4c85900f05c337b31bd9f27cc4b3aece Mon Sep 17 00:00:00 2001 From: Jamie Lenehan Date: Thu, 5 Oct 2006 08:00:52 +0000 Subject: clamav 0.84: Simplify the init scripts. assume that the volatiles processing takes care of the required directories and permissions in /var, don't try and create the home directories when adding the clamav user. --- packages/clamav/files/clamav-freshclam.init | 118 +++++++--------------------- 1 file changed, 28 insertions(+), 90 deletions(-) (limited to 'packages/clamav/files/clamav-freshclam.init') diff --git a/packages/clamav/files/clamav-freshclam.init b/packages/clamav/files/clamav-freshclam.init index 47491a2a54..490a41e31f 100644 --- a/packages/clamav/files/clamav-freshclam.init +++ b/packages/clamav/files/clamav-freshclam.init @@ -1,15 +1,17 @@ #!/bin/sh -# This is a modified version of the debian clamav-freshclam init script -set -e +PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/freshclam NAME=freshclam DESC="ClamAV virus database updater" - -[ -x $DAEMON ] || exit 0 - CLAMAV_CONF_FILE=/etc/clamd.conf FRESHCLAM_CONF_FILE=/etc/freshclam.conf -PIDFILE=/var/run/clamav/freshclam.pid +pidfile=/var/run/clamav/freshclam.pid + +set -e + +test -r /etc/default/clamav-freshclam && . /etc/default/clamav-freshclam +test -x "$DAEMON" || exit 0 +test ! -r "$CLAMAV_CONF_FILE" && exit 0 slurp_config() { @@ -40,51 +42,8 @@ slurp_config() fi } - slurp_config "$FRESHCLAM_CONF_FILE" -for inet in $INTERFACE; do - if route | grep -q "$inet"; then - IS_UP=true - break - else - IS_UP=false - fi -done -for inet in $INTERFACE; do - if [ "$inet" = "$IFACE" ]; then - match=true - break - else - match=false - fi -done - -# We don't want to always start/stop if running from if-up/down.d -if ! [ "$1" = "start" -o "$1" = "stop" ]; then # Exempt restart/reload/etc from checks - if [ -n "$INTERFACE" ]; then # Want it only run from if-up.d - if [ -z "$IFACE" ]; then # Is not called by if-up.d - if [ "$IS_UP" = false ]; then # And route isn't up (e.g., upgrade) - echo "Interface not up. Exiting." - exit 0 - fi - elif [ "$match" != 'true' ]; then # IFACE coming up is not the one selected - echo "Interface not up. Exiting." - exit 0 - fi - fi -fi - -# If user wants it run from cron, we only accept no-daemon and stop -if [ -f /etc/cron.d/clamav-freshclam ]; then - if ! [ "$1" = "no-daemon" -o "$1" = "stop" ]; then - echo "Cron option has been selected for running freshclam" - echo "Please either run freshclam directly, or run the init" - echo "script with the 'no-daemon' option" - exit 0 - fi -fi - [ -z "$UpdateLogFile" ] && UpdateLogFile=/var/log/clamav/freshclam.log if [ -z "$DatabaseDirectory" ]; then @@ -92,54 +51,33 @@ if [ -z "$DatabaseDirectory" ]; then [ -z "$DatabaseDirectory" ] && DatabaseDirectory=/var/lib/clamav/ fi -[ -e "$PIDFILE" ] && PID=`cat $PIDFILE` -[ "$PID" = '1' ] && unset PID - -# Make sure dirs exist and are correct -for i in /var/run/clamav /var/log/clamav $DatabaseDirectory -do - [ ! -d $i ] && mkdir -p $i && chown clamav:clamav $i -done case "$1" in no-daemon) - echo "It takes freshclam ~3min to timeout and try the next mirror in the list" - freshclam -l "$UpdateLogFile" --datadir "$DatabaseDirectory" - ;; + echo "It takes freshclam ~3min to timeout and try the next mirror in the list" + freshclam -l "$UpdateLogFile" --datadir "$DatabaseDirectory" + ;; + start) - echo -n "Starting $DESC: " - start-stop-daemon -S -x $DAEMON -- -d --quiet -p $PIDFILE - echo "$NAME" - ;; + echo -n "Starting $DESC: " + start-stop-daemon -S -x $DAEMON -- -d --quiet -p $pidfile + echo "$NAME." + ;; + stop) - echo -n "Stopping $DESC: " - start-stop-daemon -o -K -q -p $PIDFILE $DAEMON - if [ -n "$PID" ]; then - sleep 1 - if kill -0 "$PID" 2>/dev/null; then - echo -n "Waiting . " - cnt=0 - while kill -0 "$PID" 2>/dev/null; do - cnt=`expr "$cnt" + 1` - if [ "$cnt" -gt 60 ]; then - echo -n " Failed.. " - break - fi - sleep 2 - echo -n ". " - done - fi - fi - echo "$NAME" - ;; + echo -n "Stopping $DESC: " + start-stop-daemon -K -p $pidfile + ;; + restart|force-reload) - $0 stop - $0 start - ;; + $0 stop + $0 start + ;; + *) - echo "Usage: $0 {no-daemon|start|stop|restart|force-reload}" >&2 - exit 1 - ;; + echo "Usage: $0 {no-daemon|start|stop|restart|force-reload}" >&2 + exit 1 + ;; esac exit 0 -- cgit v1.2.3