[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#208010: [PROPOSAL] init script LSB 1.3 compliance (revised v)



--- debian-policy-3.6.1.0.orig/policy.sgml	2003-08-19 14:32:23.000000000 +0200
+++ debian-policy-3.6.1.0/policy.sgml	2003-09-13 08:28:27.000000000 +0200
@@ -5362,13 +5362,16 @@
 	      <tag><tt>force-reload</tt></tag>
 	      <item>cause the configuration to be reloaded if the
 		  service supports this, otherwise restart the
-		  service.</item>
+		  service,</item>
+
+	      <tag><tt>status</tt></tag>
+	      <item>print the current status of the service.</item>
 	    </taglist>
 
 	    The <tt>start</tt>, <tt>stop</tt>, <tt>restart</tt>, and
 	    <tt>force-reload</tt> options should be supported by all
 	    scripts in <file>/etc/init.d</file>, the <tt>reload</tt>
-	    option is optional.
+	    and <tt>status</tt> options are optional.
 	  </p>
 
 	  <p>
@@ -5421,6 +5424,53 @@
 	  </p>
 
 	  <p>
+	    In the case of init script commands other than <tt>status</tt>,
+	    the init script should return an exit status of zero if the action
+	    described by the argument has been successful or the package has
+	    been removed but not purged. Otherwise, the init script should
+	    print an error message and return a non-zero exit status code.
+	    Packages are encouraged to select return codes based on the
+	    following list.
+	    <taglist>
+	      <tag>1</tag>
+	      <item>generic or unspecified error,</item>
+	      <tag>2</tag>
+	      <item>invalid or excess argument(s),</item>
+	      <tag>3</tag>
+	      <item>unimplemented feature (for example, <tt>reload</tt>),</item>
+	      <tag>4</tag>
+	      <item>user had insufficient privilege,</item>
+	      <tag>6</tag>
+	      <item>program is not configured,</item>
+	      <tag>7</tag>
+	      <item>program is not running.</item>
+	    </taglist>
+	    Note that the <tt>stop</tt> command is required to behave sensibly
+	    when the service is not running, and therefore should not return
+	    exit code 7.
+	    All error messages should be printed on standard error. All status
+	    messages should be printed on standard output. (This does not
+	    prevent scripts from calling logging functions.)
+	  </p>
+
+	  <p>
+	    If the status command is given, the init script should return the
+	    following exit status codes.
+	    <taglist>
+	      <tag>0</tag>
+	      <item>program is running or service is OK,</item>
+	      <tag>1</tag>
+	      <item>program is dead and /var/run pid file exists,</item>
+	      <tag>2</tag>
+	      <item>program is dead and /var/lock lock file exists,</item>
+	      <tag>3</tag>
+	      <item>program is stopped,</item>
+	      <tag>4</tag>
+	      <item>program or service status is unknown.</item>
+	    </taglist>
+	  </p>
+
+	  <p>
 	    Often there are some variables in the <file>init.d</file>
 	    scripts whose values control the behaviour of the scripts,
 	    and which a system administrator is likely to want to
@@ -5648,6 +5698,14 @@
   . /etc/default/bind
 fi
 
+help () {
+  echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
+}
+
+if [ -n "$2" ]; then
+  help
+  exit 2
+fi
 
 case "$1" in
 start)
@@ -5658,7 +5716,7 @@
   ;;
 stop)
   echo -n "Stopping domain name service: named"
-  start-stop-daemon --stop --quiet  \
+  start-stop-daemon --stop --quiet --oknodo \
     --pidfile /var/run/named.pid --exec /usr/sbin/named
   echo "."
   ;;
@@ -5676,10 +5734,13 @@
     --pidfile /var/run/named.pid --exec /usr/sbin/named
   echo "."
   ;;
+status)
+  echo "Checking status of domain name service: unknown."
+  exit 4
+  ;;
 *)
-  echo "Usage: /etc/init.d/bind " \
-         " {start|stop|restart|reload|force-reload}" >&2
-  exit 1
+  help
+  exit 2
   ;;
 esac
 
@@ -5923,6 +5984,24 @@
 		daemon starting message.
 	      </p>
 	    </item>
+
+	    <item>
+	      <p>When the daemon's status is queried</p>
+
+	      <p>
+		When the <tt>status</tt> option is given, the first line of
+		output should have the following format:
+		<example compact="compact">
+Checking status of <var>description</var>: <var>short-state</var>.
+		</example>
+		where <var>description</var> is the same as in the daemon
+		starting message, and <var>short-state</var> is one of
+		<tt>running</tt>, <tt>dead, pid file exists</tt>, <tt>dead,
+		lock file exists</tt>, <tt>stopped</tt>, and <tt>unknown</tt>,
+		corresponding to the status exit code. A more verbose status
+		report may follow if appropriate.
+	      </p>
+	    </item>
 	  </list>
 	</p>
       </sect>

Attachment: pgpDkg9U8qfSY.pgp
Description: PGP signature


Reply to: