4
# Provides: clamav-freshclam
5
# Required-Start: $syslog
6
# Should-Start: clamav-daemon
9
# Default-Start: 2 3 4 5
11
# Short-Description: ClamAV virus database updater
12
# Description: Clam AntiVirus virus database updater
15
DAEMON=/usr/bin/freshclam
17
DESC="ClamAV virus database updater"
18
[ -x $DAEMON ] || exit 0
20
CLAMAV_CONF_FILE=/etc/clamav/clamd.conf
21
FRESHCLAM_CONF_FILE=/etc/clamav/freshclam.conf
22
PIDFILE=/var/run/clamav/freshclam.pid
23
[ -f /var/lib/clamav/interface ] && INTERFACE=`cat /var/lib/clamav/interface`
25
. /lib/lsb/init-functions
29
slurp_config "$FRESHCLAM_CONF_FILE"
31
[ -n "$PidFile" ] && PIDFILE="$PidFile"
32
[ -n "$DataBaseDirectory" ] || DataBaseDirectory=/var/run/clamav
34
make_dir "$DataBaseDirectory"
36
if [ -f "$PIDFILE" ]; then
37
PID=`pidofproc -p $PIDFILE $DAEMON`
40
PID=`pidofproc $DAEMON`
47
if [ "$1" = "stop" ] && [ "$RUNNING" != 0 ]; then
49
elif [ "$1" = "start" ] && [ "$RUNNING" = 0 ]; then
57
for inet in $INTERFACE; do
58
route | grep -q "$inet" && IS_UP=`expr "$IS_UP" + 1`
59
[ "$inet" = "$IFACE" ] && MATCH=1
62
if [ -n "$INTERFACE" ]; then # Want if-up.d handling
63
if [ -n "$IFACE" ]; then # Called by if-up.d - for us
64
if [ "$MATCH" = '1' ]; then # IFACE is ours
65
if [ "$IS_UP" = '1' ]; then # and is only one up
67
else # Either not up, or others are up
70
else # IFACE is not ours
73
else # Not called by if-up.d && $1='(stop|start)'
76
else # No if-up.d handling - just return
81
handle_iface $1 || exit 0
83
[ -z "$UpdateLogFile" ] && UpdateLogFile=/var/log/clamav/freshclam.log
84
[ -z "$DatabaseDirectory" ] && DatabaseDirectory=/var/lib/clamav/
85
[ -n "$DatabaseOwner" ] || DatabaseOwner=clamav
89
su "$DatabaseOwner" -p -s /bin/sh -c "freshclam -l $UpdateLogFile --datadir $DatabaseDirectory"
93
log_daemon_msg "Starting $DESC" "$NAME"
94
# If user wants it run from cron, we only accept no-daemon and stop
95
if [ -f /etc/cron.d/clamav-freshclam ]; then
96
log_warning_msg "Not starting $NAME - cron option selected"
97
log_warning_msg "Run the init script with the 'no-daemon' option"
101
su "$DatabaseOwner" -p -s /bin/sh -c ". /lib/lsb/init-functions && start_daemon $DAEMON -d --quiet"
106
log_daemon_msg "Stopping $DESC" "$NAME"
107
if [ -n "$PID" ]; then
111
if kill -0 "$PID" 2>/dev/null; then
113
log_progress_msg "Waiting . "
115
while kill -0 "$PID" 2>/dev/null; do
117
cnt=`expr "$cnt" + 1`
118
if [ "$cnt" -gt 15 ]; then
124
log_progress_msg ". "
128
killproc -p $PIDFILE $DAEMON
133
restart|force-reload)
139
log_daemon_msg "Reloading $DESC" "$NAME"
140
if [ "$RUNNING" = 0 ] && [ -n "$PID" ]; then
149
0) log_success_msg "$NAME is running."
151
1) log_warning_msg "$NAME is not running, but pidfile $PIDFILE exists."
153
3) log_failure_msg "$NAME is not running."
155
*) log_failure_msg "$NAME is unknown."
160
log_failure_msg "Usage: $0 {no-daemon|start|stop|restart|force-reload|reload-log|skip|status}" >&2