Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 - 1
#!/bin/bash
2
#
3
# clamav        This shell script takes care of starting and stopping
4
#               clamav.
5
#
6
# chkconfig: - 61 39
7
# description: Clamav is a is a GPL anti-virus toolkit for UNIX.
8
# processname: clamav
9
# config: /etc/clamd.conf
10
# pidfile: /var/run/clamav/clamd.pid
11
 
12
# Source function library.
13
. /etc/rc.d/init.d/functions
14
 
15
# Source clamav configureation.
16
if [ -f /etc/sysconfig/clamav ] ; then
17
        . /etc/sysconfig/clamav
18
fi
19
 
20
[ -f /usr/sbin/clamd ] || exit 0
21
 
22
RETVAL=0
23
prog="clamd"
24
 
25
start() {
26
        # Start daemons.
27
 
28
        echo -n $"Starting $prog: "
29
        daemon /usr/sbin/clamd
30
        RETVAL=$?
31
        echo
32
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
33
 
34
        if [ "$CLAMAV_MILTER" == "yes" ] ; then
35
            echo -n $"Starting clamav-milter: "
36
            daemon clamav-milter --config-file /etc/clamav-milter.conf
37
            RETVAL=$?
38
            echo
39
            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamav-milter
40
        fi
41
 
42
        echo -n $"Starting freshclam: "
43
        touch /var/run/clamav/freshclam.pid
44
        chown clamav:clamav /var/run/clamav/freshclam.pid
45
        if [ -x /usr/bin/selinuxenabled ] && /usr/bin/selinuxenabled; then
46
            /sbin/restorecon /var/run/clamav/freshclam.pid
47
        fi
48
        daemon --check freshclam \
49
            /usr/bin/freshclam -d -c 24 \
50
              --quiet \
51
              -p /var/run/clamav/freshclam.pid \
52
              --daemon-notify=/etc/clamd.conf
53
        RETVAL=$?
54
        echo
55
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
56
 
57
        return $RETVAL
58
}
59
 
60
stop() {
61
        # Stop daemons.
62
        echo -n $"Shutting down $prog: "
63
        killproc clamd
64
        RETVAL=$?
65
        echo
66
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
67
        if test -f /var/lock/subsys/clamav-milter; then
68
                echo -n $"Shutting down clamav-milter: "
69
                killproc clamav-milter
70
                RETVAL=$?
71
                echo
72
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamav-milter
73
        fi
74
        if test -f /var/run/clamav/freshclam.pid; then
75
                echo -n $"Shutting down freshclam: "
76
                killproc freshclam
77
                RETVAL=$?
78
                echo
79
                [ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid
80
                [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freshclam
81
        fi
82
        return $RETVAL
83
}
84
 
85
reload() {
86
        stop
87
        start
88
}
89
 
90
# See how we were called.
91
case "$1" in
92
  start)
93
        start
94
        ;;
95
  stop)
96
        stop
97
        ;;
98
  reload)
99
        reload
100
        RETVAL=$?
101
        ;;
102
  restart)
103
        stop
104
        start
105
        RETVAL=$?
106
        ;;
107
  condrestart)
108
        if [ -f /var/lock/subsys/clamd ]; then
109
            stop
110
            start
111
            RETVAL=$?
112
        fi
113
        ;;
114
  status)
115
        status clamd
116
        RETVAL=$?
117
        ;;
118
  *)
119
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
120
        exit 1
121
esac
122
 
123
exit $RETVAL