SOURCES: collectd.init - unify with template.init

glen glen at pld-linux.org
Mon May 26 21:44:39 CEST 2008


Author: glen                         Date: Mon May 26 19:44:39 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- unify with template.init

---- Files affected:
SOURCES:
   collectd.init (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/collectd.init
diff -u SOURCES/collectd.init:1.1 SOURCES/collectd.init:1.2
--- SOURCES/collectd.init:1.1	Mon May 26 09:45:34 2008
+++ SOURCES/collectd.init	Mon May 26 21:44:34 2008
@@ -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
@@ -15,12 +14,20 @@
 # 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 @@
 	else
 		msg_already_running collectd
 	fi
-	;;
-  stop)
+}
+
+stop() {
 	if [ -f /var/lock/subsys/collectd ]; then
 		msg_stopping collectd
 		killproc collectd
@@ -39,20 +47,43 @@
 	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
-
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/collectd.init?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list