- unify with template.init
authorElan Ruusamäe <glen@pld-linux.org>
Mon, 26 May 2008 19:44:34 +0000 (19:44 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    collectd.init -> 1.2

collectd.init

index d2c89a9cbc21279daf81b6eb65cc03828b84a2d0..bce6a5f79bf830b349b9188bb19abe9adc316659 100644 (file)
@@ -4,10 +4,9 @@
 #
 # chkconfig:   345 93 11
 #
-# description: utility that colect various system information  \
-#              into rrd files \
-
-
+# description: utility that colect various system information into rrd files
+#
+# $Id$
 
 # Source function library
 . /etc/rc.d/init.d/functions
 # Get service config
 [ -f /etc/sysconfig/collectd ] && . /etc/sysconfig/collectd
 
+# Get network config
+. /etc/sysconfig/network
 
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+               msg_network_down collectd
+               exit 1
+       fi
+else
+       exit 0
+fi
 
-RETVAL=0
-
-case "$1" in
-  start)
+start() {
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/collectd ]; then
                msg_starting collectd
@@ -30,8 +37,9 @@ case "$1" in
        else
                msg_already_running collectd
        fi
-       ;;
-  stop)
+}
+
+stop() {
        if [ -f /var/lock/subsys/collectd ]; then
                msg_stopping collectd
                killproc collectd
@@ -39,20 +47,43 @@ case "$1" in
        else
                msg_not_running collectd
        fi
+}
+
+condrestart() {
+       if [ -f /var/lock/subsys/collectd ]; then
+               stop
+               start
+       else
+               msg_not_running collectd
+               RETVAL=$1
+       fi
+}
+
+RETVAL=0
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
-       exit $?
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
        ;;
   status)
        status collectd
        exit $?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
        exit 3
 esac
 
 exit $RETVAL
-
This page took 0.035164 seconds and 4 git commands to generate.