]> git.pld-linux.org Git - packages/clamav.git/blob - clamav.init
- simplify triggers - use addusertogroup macro
[packages/clamav.git] / clamav.init
1 #!/bin/sh
2 #
3 # clamd         clamd (antyvirus daemon)
4 #
5 # chkconfig:    345 60 40
6 #
7 # description:  Clam Antivirus daemon
8 #
9 # processname:  clamd
10 # pidfile:      /var/run/clamav/clamd.pid
11 #
12 # $Id$
13
14 # Source function library
15 . /etc/rc.d/init.d/functions
16
17 # Get service config
18 [ -f /etc/sysconfig/clamd ] && . /etc/sysconfig/clamd
19
20 start() {
21         # Check if the service is already running?
22         if [ ! -f /var/lock/subsys/clamd ]; then
23                 msg_starting "Clam Antivirus daemon"
24                 daemon --pidfile /var/run/clamav/clamd.pid /usr/sbin/clamd
25                 RETVAL=$?
26                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
27         else
28                 msg_already_running "Clam Antivirus daemon"
29         fi
30 }
31
32 stop() {
33         if [ -f /var/lock/subsys/clamd ]; then
34                 msg_stopping "Clam Antivirus daemon"
35                 killproc --pidfile /var/run/clamav/clamd.pid clamd
36                 rm -f /var/lock/subsys/clamd /var/run/clamav/clamd.pid >/dev/null 2>&1
37         else
38                 msg_not_running "Clam Antivirus daemon"
39         fi
40 }
41
42 reload() {
43         if [ -f /var/lock/subsys/clamd ]; then
44                 msg_reloading "Clam Antivirus daemon"
45                 killproc clamd -HUP
46                 RETVAL=$?
47         else
48                 msg_not_running "Clam Antivirus daemon"
49                 RETVAL=7
50         fi
51 }
52
53 condrestart() {
54         if [ -f /var/lock/subsys/clamd ]; then
55                 stop
56                 start
57         else
58                 msg_not_running "Clam Antivirus daemon"
59                 RETVAL=$1
60         fi
61 }
62
63 RETVAL=0
64 # See how we were called.
65 case "$1" in
66   start)
67         start
68         ;;
69   stop)
70         stop
71         ;;
72   restart)
73         stop
74         start
75         ;;
76   try-restart)
77         condrestart 0
78         ;;
79   reload|force-reload)
80         reload
81         ;;
82   status)
83         status clamd
84         exit $?
85         ;;
86   *)
87         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
88         exit 3
89 esac
90
91 exit $RETVAL
This page took 0.041835 seconds and 3 git commands to generate.