update Tor to 0.3.5.8
[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.cvd" ] && \
16                                         [ -e "/var/lib/clamav/daily.cvd" ] || \
17                                         [ -e "/var/lib/clamav/daily.cld" ] && \
18                                 break
19                                 if [ "$COUNTER" -lt "1" ]; then
20                                         boot_mesg -n "Downloading database"
21                                 else
22                                         boot_mesg -n "."
23                                 fi
24                                 sleep 15
25                                 COUNTER=$(($COUNTER + 1))
26                         done
27                         if [ "$COUNTER" -gt "0" ]; then
28                                 boot_mesg
29                         fi
30                         if [ "$COUNTER" -gt "60" ]; then
31                                 boot_mesg "Download takes longer than 15min check freshclam status!"
32                                 echo_failure;
33                                 exit 1;
34                         fi
35
36                         boot_mesg "Starting Clamav Daemon..."
37                         loadproc /usr/sbin/clamd
38                 else
39                         boot_mesg "Starting Clamav in background..."
40                         /etc/init.d/clamav start > /dev/tty12 < /dev/tty12 &
41                         echo_ok;
42                         exit 0;
43                 fi
44                 ;;
45
46         stop)
47                 boot_mesg "Stopping Clamav Definition Updater..."
48                 killproc /usr/bin/freshclam
49                 rm -rf /var/lib/clamav/*.tmp
50
51                 boot_mesg "Stopping Clamav Daemon..."
52                 killproc /usr/sbin/clamd
53                 ;;
54
55         restart)
56                 $0 stop
57                 sleep 1
58                 $0 start
59                 ;;
60
61         status)
62                 statusproc /usr/sbin/clamd
63                 statusproc /usr/bin/freshclam
64                 ;;
65
66         *)
67                 echo "Usage: $0 {start|stop|restart|status}"
68                 exit 1
69                 ;;
70 esac
71
72 # End $rc_base/init.d/clamav