]> git.pld-linux.org Git - packages/clamav.git/blobdiff - clamav.init
- bug note: bb#1553
[packages/clamav.git] / clamav.init
index 960ab24f53ee8c16ac5f5c5d997d6e3149b839db..bcdc1ccb0afd613294d4ca8d33e57a27e0fdcba7 100644 (file)
@@ -4,58 +4,90 @@
 #
 # chkconfig:   345 60 40
 #
-# description: clamd (secure shell daemon) is a server part of the ssh suite.
-#              Ssh can be used for remote login, remote file copying, TCP port
-#              forwarding etc. Ssh offers strong encryption and authentication.
-
+# description: Clam Antivirus daemon
+#
+# processname: clamd
+# pidfile:     /var/run/clamav/clamd.pid
+#
+# $Id$
 
 # Source function library
 . /etc/rc.d/init.d/functions
 
-# Get network config
-. /etc/sysconfig/network
-
 # Get service config
 [ -f /etc/sysconfig/clamd ] && . /etc/sysconfig/clamd
 
-# See how we were called.
-case "$1" in
-  start)
+start() {
        # Check if the service is already running?
+       if [ -f /var/lock/subsys/clamd ]; then
+               msg_already_running "Clam Antivirus daemon"
+               return
+       fi
+
+       msg_starting "Clam Antivirus daemon"
+       daemon --pidfile /var/run/clamav/clamd.pid /usr/sbin/clamd
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
+}
+
+stop() {
        if [ ! -f /var/lock/subsys/clamd ]; then
-               msg_starting clamd
-               daemon /usr/sbin/clamd 
+               msg_not_running "Clam Antivirus daemon"
+               return
+       fi
+
+       msg_stopping "Clam Antivirus daemon"
+       killproc --pidfile /var/run/clamav/clamd.pid clamd
+       rm -f /var/lock/subsys/clamd /var/run/clamav/clamd.pid >/dev/null 2>&1
+}
+
+reload() {
+       if [ -f /var/lock/subsys/clamd ]; then
+               msg_reloading "Clam Antivirus daemon"
+               killproc clamd -HUP
                RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd               
        else
-               msg_already_running clamd
+               msg_not_running "Clam Antivirus daemon"
+               RETVAL=7
+       fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/clamd ]; then
+               stop
+               start
+       else
+               msg_not_running "Clam Antivirus daemon"
+               RETVAL=$1
        fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
   stop)
-        if [ -f /var/lock/subsys/clamd ]; then
-               msg_stopping clamd
-               killproc clamd
-               rm -f /var/run/clamd.pid /var/lock/subsys/clamd >/dev/null 2>&1
-       else
-               msg_not_running clamd
-               exit 1
-       fi      
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  reload|force-reload)
+       reload
        ;;
   status)
        status clamd
        exit $?
        ;;
-  reload)
-       msg_reloading clamd
-       killproc clamd -HUP
-       ;;
   *)
-       msg_usage "$0 {start|stop|init|status|restart|reload}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
+       exit 3
 esac
 
 exit $RETVAL
This page took 0.055656 seconds and 4 git commands to generate.