]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- force-reload is not supposed to start service if it is not running
authorJakub Bogusz <qboosh@pld-linux.org>
Sun, 25 Nov 2007 11:18:22 +0000 (11:18 +0000)
committerJakub Bogusz <qboosh@pld-linux.org>
Sun, 25 Nov 2007 11:18:22 +0000 (11:18 +0000)
- 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

svn-id: @9091

rc.d/init.d/template.init

index 718f9a0362da9ab49d99cf13c490a59669acd96e..cb331316cf30c4999ac6903805a2b42ccb122efd 100644 (file)
@@ -69,6 +69,18 @@ reload() {
        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 @@ case "$1" in
   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
 
This page took 0.03549 seconds and 4 git commands to generate.