SVN: rc-scripts/trunk/rc.d/init.d/template.init

qboosh qboosh at pld-linux.org
Sun Nov 25 12:18:23 CET 2007


Author: qboosh
Date: Sun Nov 25 12:18:22 2007
New Revision: 9091

Modified:
   rc-scripts/trunk/rc.d/init.d/template.init
Log:
- force-reload is not supposed to start service if it is not running
- new try-restart action (as specified by LSB 3.1.0, formerly "condrestart" in some distros)
  it should restart service if running and just exit sucessfully otherwise

Modified: rc-scripts/trunk/rc.d/init.d/template.init
==============================================================================
--- rc-scripts/trunk/rc.d/init.d/template.init	(original)
+++ rc-scripts/trunk/rc.d/init.d/template.init	Sun Nov 25 12:18:22 2007
@@ -69,6 +69,18 @@
 	fi
 }
 
+condrestart() {
+	if [ -f /var/lock/subsys/<service> ]; then
+		stop
+		start
+	else
+		if [ $1 -ne 0 ]; then
+			msg_not_running <service>
+		fi
+		RETVAL=$1
+	fi
+}
+
 RETVAL=0
 # See how we were called.
 case "$1" in
@@ -78,22 +90,28 @@
   stop)
   	stop
 	;;
-# include force-reload here if program doesn't support reloading without restart
-#  restart|force-reload)
   restart)
 	stop
 	start
 	;;
+  try-restart)
+	condrestart 0
+	;;
 # include force-reload here if program allows reloading without restart
+# otherwise remove reload action and support force-reload as restart if running
   reload|force-reload)
   	reload
 	;;
+# use this one if program doesn't support reloading without restart
+  force-reload)
+	condrestart 7
+	;;
   status)
 	status <service>
 	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
 	exit 3
 esac
 


More information about the pld-cvs-commit mailing list