SOURCES: shishi-shishid.init - use functions - force-reload is not...

qboosh qboosh at pld-linux.org
Sat Jan 5 12:50:14 CET 2008


Author: qboosh                       Date: Sat Jan  5 11:50:14 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- use functions
- force-reload is not supposed to start service if not running
- added try-restart action (LSB 3.1)

---- Files affected:
SOURCES:
   shishi-shishid.init (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: SOURCES/shishi-shishid.init
diff -u SOURCES/shishi-shishid.init:1.3 SOURCES/shishi-shishid.init:1.4
--- SOURCES/shishi-shishid.init:1.3	Sun Sep 17 18:17:31 2006
+++ SOURCES/shishi-shishid.init	Sat Jan  5 12:50:09 2008
@@ -35,10 +35,7 @@
 	exit 0
 fi
 
-# See how we were called.
-case "$1" in
-  start)
-	# Check if the service is already running?
+start() {
 	if [ ! -f /var/lock/subsys/shishid ]; then
 		msg_starting shishid
 		busy
@@ -58,43 +55,52 @@
 	else
 		msg_already_running shishid
 	fi
-	;;
-  stop)
+}
+
+stop() {
 	if [ -f /var/lock/subsys/shishid ]; then
-		# Stop daemons.
 		msg_stopping shishid
 		killproc shishid
 		rm -f /var/lock/subsys/shishid
 	else
 		msg_not_running shishid
 	fi
+}
+
+condrestart() {
+	if [ -f /var/lock/subsys/shishid ]; then
+		stop
+		start
+	else
+		msg_not_running shishid
+		RETVAL=$1
+	fi
+}
+
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
 	;;
   restart)
-	$0 stop
-	$0 start
-	exit $?
-	;;
-# not supported (yet?)
-#  reload)
-#	if [ -f /var/lock/subsys/shishid ]; then
-#		msg_reloading shishid
-#		killproc shishid -HUP
-#		RETVAL=$?
-#	else
-#		msg_not_running shishid
-#		RETVAL=7
-#	fi
-#	;;
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
   force-reload)
-	$0 restart
-	exit $?
+	condrestart 7
 	;;
   status)
 	status shishid
 	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/shishi-shishid.init?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list