]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/packages/clamav
439c20579f5ea7c0691ba814e1fa4e371802ec6e
[people/pmueller/ipfire-2.x.git] / src / initscripts / packages / clamav
1 #!/bin/sh
2 # Begin $rc_base/init.d/clamav
3
4 . /etc/sysconfig/rc
5 . $rc_functions
6
7 case "$1" in
8 start)
9 if [ $(basename $0) == "clamav" ]; then
10 boot_mesg "Starting Clamav Definition Updater..."
11 loadproc /usr/bin/freshclam -d -c 10
12
13 COUNTER=0
14 while [ "$COUNTER" -lt "61" ]; do
15 [ -e "/var/lib/clamav/main.cld" ] || \
16 [ -e "/var/lib/clamav/main.cvd" ] && \
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" ] && \
21 break
22 if [ "$COUNTER" -lt "1" ]; then
23 boot_mesg -n "Downloading database"
24 else
25 boot_mesg -n "."
26 fi
27 sleep 15
28 COUNTER=$(($COUNTER + 1))
29 done
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..."
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
47 ;;
48
49 stop)
50 boot_mesg "Stopping Clamav Definition Updater..."
51 killproc /usr/bin/freshclam
52 rm -rf /var/lib/clamav/*.tmp
53
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 ;;
73 esac
74
75 # End $rc_base/init.d/clamav