SOURCES: func-certmaster.init, func-funcd.init - use new template ...

patrys patrys at pld-linux.org
Sun Dec 9 14:01:17 CET 2007


Author: patrys                       Date: Sun Dec  9 13:01:17 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use new template format for init scripts
- fix packaging

---- Files affected:
SOURCES:
   func-certmaster.init (1.1 -> 1.2) , func-funcd.init (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/func-certmaster.init
diff -u SOURCES/func-certmaster.init:1.1 SOURCES/func-certmaster.init:1.2
--- SOURCES/func-certmaster.init:1.1	Tue Dec  4 18:24:49 2007
+++ SOURCES/func-certmaster.init	Sun Dec  9 14:01:12 2007
@@ -1,48 +1,93 @@
 #!/bin/sh
 #
-# func:		Starts the func certmaster daemon
+# certmaster	certmaster short service description
 #
-# Version:	@(#) /etc/rc.d/init.d/func 0.1
+# chkconfig:	- 97 3
 #
-# chkconfig:	- 98 99
-# description:	Starts and stops the func daemon at startup and shutdown..
+# description:	certmaster long service description
+#
+# $Id$
 
+# Source function library
 . /etc/rc.d/init.d/functions
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/certmaster ] && . /etc/sysconfig/certmaster
+
+# 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 certmaster
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+start() {
 	# Check if the service is already running?
 	if [ ! -f /var/lock/subsys/certmaster ]; then
-		msg_starting "certmaster"
+		msg_starting certmaster
 		daemon /usr/bin/certmaster
 		RETVAL=$?
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/certmaster
 	else
-		msg_already_running "certmaster"
+		msg_already_running certmaster
 	fi
-	;;
-  stop)
+}
+
+stop() {
 	if [ -f /var/lock/subsys/certmaster ]; then
-		msg_stopping "certmaster"
+		# Stop daemons.
+		msg_stopping certmaster
 		killproc certmaster
+		killproc --pidfile /var/run/certmaster.pid certmaster -TERM
 		rm -f /var/lock/subsys/certmaster
 	else
-		msg_not_running "certmaster"
+		msg_not_running certmaster
 	fi
+}
+
+condrestart() {
+	if [ -f /var/lock/subsys/certmaster ]; then
+		stop
+		start
+	else
+		if [ $1 -ne 0 ]; then
+			msg_not_running certmaster
+		fi
+		RETVAL=$1
+	fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
+	;;
+  stop)
+  	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  force-reload)
+	condrestart 7
 	;;
   status)
 	status certmaster
-	exit $?
-	;;
-  restart|force-reload)
-	$0 stop
-	$0 start
-	exit $?
+	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|restart|force-reload|status}"
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
 	exit 3
 esac
 

================================================================
Index: SOURCES/func-funcd.init
diff -u SOURCES/func-funcd.init:1.1 SOURCES/func-funcd.init:1.2
--- SOURCES/func-funcd.init:1.1	Tue Dec  4 18:24:50 2007
+++ SOURCES/func-funcd.init	Sun Dec  9 14:01:12 2007
@@ -1,48 +1,93 @@
 #!/bin/sh
 #
-# func:		Starts the func daemon
+# funcd	funcd short service description
 #
-# Version:	@(#) /etc/rc.d/init.d/func 0.1
+# chkconfig:	- 98 2
 #
-# chkconfig:	- 98 99
-# description:	Starts and stops the func daemon at startup and shutdown..
+# description:	funcd long service description
+#
+# $Id$
 
+# Source function library
 . /etc/rc.d/init.d/functions
 
-RETVAL=0
-# See how we were called.
-case "$1" in
-  start)
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/funcd ] && . /etc/sysconfig/funcd
+
+# 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 funcd
+		exit 1
+	fi
+else
+	exit 0
+fi
+
+start() {
 	# Check if the service is already running?
 	if [ ! -f /var/lock/subsys/funcd ]; then
-		msg_starting "funcd"
+		msg_starting funcd
 		daemon /usr/bin/funcd
 		RETVAL=$?
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/funcd
 	else
-		msg_already_running "funcd"
+		msg_already_running funcd
 	fi
-	;;
-  stop)
+}
+
+stop() {
 	if [ -f /var/lock/subsys/funcd ]; then
-		msg_stopping "funcd"
+		# Stop daemons.
+		msg_stopping funcd
 		killproc funcd
+		killproc --pidfile /var/run/funcd.pid funcd -TERM
 		rm -f /var/lock/subsys/funcd
 	else
-		msg_not_running "funcd"
+		msg_not_running funcd
 	fi
+}
+
+condrestart() {
+	if [ -f /var/lock/subsys/funcd ]; then
+		stop
+		start
+	else
+		if [ $1 -ne 0 ]; then
+			msg_not_running funcd
+		fi
+		RETVAL=$1
+	fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+  	start
+	;;
+  stop)
+  	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  force-reload)
+	condrestart 7
 	;;
   status)
 	status funcd
-	exit $?
-	;;
-  restart|force-reload)
-	$0 stop
-	$0 start
-	exit $?
+	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|restart|force-reload|status}"
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
 	exit 3
 esac
 
================================================================

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



More information about the pld-cvs-commit mailing list