Gentoo Archives: gentoo-doc-cvs

From: "Sven Vermeulen (swift)" <swift@g.o>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] gentoo commit in xml/htdocs/doc/en/handbook: hb-working-rcscripts.xml
Date: Fri, 12 Aug 2011 19:37:59
swift       11/08/12 19:34:56

  Modified:             hb-working-rcscripts.xml
  Fix #348724 (documentation part) - Document that restart functionality is not something users can define in the init scripts themselves

Revision  Changes    Path
1.33                 xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml

file :
diff :

Index: hb-working-rcscripts.xml
RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- hb-working-rcscripts.xml	2 Mar 2011 08:09:48 -0000	1.32
+++ hb-working-rcscripts.xml	12 Aug 2011 19:34:56 -0000	1.33
@@ -4,7 +4,7 @@
 <!-- The content of this document is licensed under the CC-BY-SA license -->
 <!-- See -->
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.32 2011/03/02 08:09:48 nightmorph Exp $ -->
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.33 2011/08/12 19:34:56 swift Exp $ -->
@@ -14,8 +14,8 @@
 these aspects and explains how to deal with these scripts.
@@ -440,10 +440,6 @@
 stop() {
   <comment>(Commands necessary to stop the service)</comment>
-restart() {
-  <comment>(Commands necessary to restart the service)</comment>
@@ -574,6 +570,11 @@
 <pre caption="Example start() function">
 start() {
+  if [ "${RC_CMD}" = "restart" ];
+  then
+    <comment># Do something in case a restart requires more than stop, start</comment>
+  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 <c>RC_CMD</c> variable. Unlike the previous init script system, the newer
+<c>openrc</c> system does not support script-specific restart functionality.
+Instead, the script needs to check the contents of the <c>RC_CMD</c> variable
+to see if a function (be it <c>start()</c> or <c>stop()</c>) is called as part
+of a restart or not.
 Make sure that <c>--exec</c> 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: <c>stop()</c> and <c>restart()</c>. You are
-not obliged to define these functions! Our init system is intelligent enough to
-fill these functions by itself if you use <c>start-stop-daemon</c>.
+Another function you can define is <c>stop()</c>. You are not obliged to define
+this function though! Our init system is intelligent enough to fill in this
+function by itself if you use <c>start-stop-daemon</c>.
-Although you do not <e>have</e> to create a <c>stop()</c> function, here is an
+Here is an example of a <c>stop()</c> function:
 <pre caption="Example stop() function">
@@ -681,6 +690,10 @@
+The function <c>restart()</c> cannot be overridden in openrc!