Index: hb-working-rcscripts.xml =================================================================== RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v retrieving revision 1.32 diff -u -t -r1.32 hb-working-rcscripts.xml --- hb-working-rcscripts.xml 2 Mar 2011 08:09:48 -0000 1.32 +++ hb-working-rcscripts.xml 3 Jul 2011 14:16:32 -0000 @@ -440,10 +440,6 @@ stop() { (Commands necessary to stop the service) } - -restart() { - (Commands necessary to restart the service) -}

@@ -574,6 +570,11 @@

 start() {
+  if [ "${RC_CMD}" = "restart" ];
+  then
+    # Do something in case a restart requires more than stop, start
+  fi
+
   ebegin "Starting my_service"
   start-stop-daemon --start --exec /path/to/my_service \
     --pidfile /path/to/my_pidfile
@@ -591,6 +592,15 @@
 service fails to start.
 

+

+Another notable setting used in the above example is to check the contents of +the RC_CMD variable. Unlike the previous init script system, the newer +openrc system does not support script-specific restart functionality. +Instead, the script needs to check the contents of the RC_CMD variable to +see if a function (be it start() or stop()) is called as part of a +restart or not. +

+ Make sure that --exec actually calls a service and not just a shell script that launches services and exits -- that's what the init script is @@ -604,14 +614,13 @@

-Other functions you can define are: stop() and restart(). You are -not obliged to define these functions! Our init system is intelligent enough to -fill these functions by itself if you use start-stop-daemon. +Another function you can define is stop(). You are not obliged to define +this function though! Our init system is intelligent enough to fill this +functions by itself if you use start-stop-daemon.

-Although you do not have to create a stop() function, here is an -example: +Here is an example of a stop() function:

@@ -681,6 +690,10 @@
 }
 
+ +The function restart() however cannot be overridden in openrc! + +