3
DAEMON=/usr/bin/freshclam
5
DESC="ClamAV virus database updater"
6
[ -x $DAEMON ] || exit 0
8
CLAMAV_CONF_FILE=/etc/clamav/clamd.conf
9
FRESHCLAM_CONF_FILE=/etc/clamav/freshclam.conf
10
PIDFILE=/var/run/clamav/freshclam.pid
11
[ -f /var/lib/clamav/interface ] && INTERFACE=`cat /var/lib/clamav/interface`
13
. /lib/lsb/init-functions
17
slurp_config "$FRESHCLAM_CONF_FILE"
19
PID=`pidofproc -p $PIDFILE $DAEMON`
20
[ "$PID" = '1' ] && unset PID
24
if [ "$1" = "stop" ]; then
25
pidofproc -p $PIDFILE $DAEMON > /dev/null || return 1
26
elif [ "$1" = "start" ]; then
27
pidofproc -p $PIDFILE $DAEMON > /dev/null && return 1
34
for inet in $INTERFACE; do
35
route | grep -q "$inet" && IS_UP=`expr "$IS_UP" + 1`
36
[ "$inet" = "$IFACE" ] && MATCH=1
39
if [ -n "$INTERFACE" ]; then # Want if-up.d handling
40
if [ -n "$IFACE" ]; then # Called by if-up.d - for us
41
if [ "$MATCH" = '1' ]; then # IFACE is ours
42
if [ "$IS_UP" = '1' ]; then # and is only one up
44
else # Either not up, or others are up
47
else # IFACE is not ours
50
else # Not called by if-up.d && $1='(stop|start)'
53
else # No if-up.d handling - just return
58
handle_iface $1 || exit 0
60
[ -z "$UpdateLogFile" ] && UpdateLogFile=/var/log/clamav/freshclam.log
61
[ -z "$DatabaseDirectory" ] && DatabaseDirectory=/var/lib/clamav/
65
log_warning_msg "It takes freshclam ~3min to timeout and try the next mirror in the list"
66
freshclam -l "$UpdateLogFile" --datadir "$DatabaseDirectory"
69
log_begin_msg "Starting $DESC: $NAME"
70
# If user wants it run from cron, we only accept no-daemon and stop
71
if [ -f /etc/cron.d/clamav-freshclam ]; then
72
log_warning_msg "Not starting $NAME - cron option selected"
73
log_warning_msg "Run the init script with the 'no-daemon' option"
77
start_daemon -p $PIDFILE $DAEMON -d --quiet
81
log_begin_msg "Stopping $DESC: $NAME"
82
if [ -n "$PID" ]; then
86
if kill -0 "$PID" 2>/dev/null; then
90
while kill -0 "$PID" 2>/dev/null; do
93
if [ "$cnt" -gt 15 ]; then
103
killproc -p $PIDFILE $DAEMON
108
restart|force-reload)
113
log_begin_msg "Reloading $DESC: $NAME"
114
killproc -p $PIDFILE $DAEMON 1
120
pidofproc -p $PIDFILE $DAEMON > /dev/null
122
0) log_success_msg "$NAME is running."
124
2) log_warning_msg "$NAME is not running, but pidfile $PIDFILE exists."
126
3) log_failure_msg "$NAME is not running."
128
*) log_failure_msg "$NAME is unknown."
133
log_failure_msg "Usage: $0 {no-daemon|start|stop|restart|force-reload|reload-log|skip|status}" >&2