]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/packages/clamav
clamav: fix database present check
[ipfire-2.x.git] / src / initscripts / packages / clamav
CommitLineData
f7ff12a3
MT
1#!/bin/sh
2# Begin $rc_base/init.d/clamav
3
4. /etc/sysconfig/rc
5. $rc_functions
6
7case "$1" in
8 start)
bfa65be8
AF
9 if [ $(basename $0) == "clamav" ]; then
10 boot_mesg "Starting Clamav Definition Updater..."
11 loadproc /usr/bin/freshclam -d -c 10
4558108c 12
bfa65be8 13 COUNTER=0
4558108c 14 while [ "$COUNTER" -lt "61" ]; do
63decf77 15 [ -e "/var/lib/clamav/main.cld" ] || \
aeefbca7 16 [ -e "/var/lib/clamav/main.cvd" ] && \
63decf77
AF
17 [ -e "/var/lib/clamav/bytecode.cld" ] || \
18 [ -e "/var/lib/clamav/bytecode.cvd" ] && \
19 [ -e "/var/lib/clamav/daily.cld" ] || \
20 [ -e "/var/lib/clamav/daily.cvd" ] && \
bfa65be8 21 break
4558108c 22 if [ "$COUNTER" -lt "1" ]; then
aeefbca7 23 boot_mesg -n "Downloading database"
4558108c
AF
24 else
25 boot_mesg -n "."
26 fi
27 sleep 15
bfa65be8
AF
28 COUNTER=$(($COUNTER + 1))
29 done
4558108c
AF
30 if [ "$COUNTER" -gt "0" ]; then
31 boot_mesg
32 fi
33 if [ "$COUNTER" -gt "60" ]; then
34 boot_mesg "Download takes longer than 15min check freshclam status!"
35 echo_failure;
36 exit 1;
37 fi
38
39 boot_mesg "Starting Clamav Daemon..."
bfa65be8
AF
40 loadproc /usr/sbin/clamd
41 else
42 boot_mesg "Starting Clamav in background..."
43 /etc/init.d/clamav start > /dev/tty12 < /dev/tty12 &
44 echo_ok;
45 exit 0;
46 fi
f7ff12a3
MT
47 ;;
48
49 stop)
50 boot_mesg "Stopping Clamav Definition Updater..."
51 killproc /usr/bin/freshclam
aeefbca7 52 rm -rf /var/lib/clamav/*.tmp
4558108c 53
f7ff12a3
MT
54 boot_mesg "Stopping Clamav Daemon..."
55 killproc /usr/sbin/clamd
56 ;;
57
58 restart)
59 $0 stop
60 sleep 1
61 $0 start
62 ;;
63
64 status)
65 statusproc /usr/sbin/clamd
66 statusproc /usr/bin/freshclam
67 ;;
68
69 *)
70 echo "Usage: $0 {start|stop|restart|status}"
71 exit 1
72 ;;
73esac
74
75# End $rc_base/init.d/clamav