Add a new helper function: init_is_upstart().
authorSteve Langasek <steve.langasek@canonical.com>
Tue, 1 May 2012 06:55:45 +0000 (08:55 +0200)
committerDidier Raboud <odyx@debian.org>
Tue, 1 May 2012 07:16:35 +0000 (09:16 +0200)
init_is_upstart() is to be used by init scripts of upstart-aware packages to
render the init script inert when upstart is present.

Signed-off-by: Didier Raboud <odyx@debian.org>
Closes: #661109
Git-Dch: Full

debian/lsb-base.README.Debian
init-functions

index 6be48f9a98c81ccfda20181e30a5c2ae9e138a5e..5533b3033f1682e3f7b10720b45ab8e37bb19d55 100644 (file)
@@ -111,6 +111,14 @@ specific to Debian and (in some cases) other derived distributions.
         status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
 
+  - init_is_upstart
+
+    If the currently running init daemon is upstart, return zero; if the
+    calling init script belongs to a package which also provides a native
+    upstart job, it should generally exit non-zero in this case.
+
+    init_is_upstart is available from lsb-base 4.1+Debian2+.
+
 To use these functions, source /lib/lsb/init-functions at the
 beginning of your (Bourne sh or compatible) init script.
 
index 18fd2bd91a3e3c26b2d6d3f62721139593d75d0f..c9abd337742e1a9ce3b615e0c282ed3eb2bb457b 100644 (file)
@@ -259,6 +259,18 @@ get_lsb_header_val () {
         sed -n "/$LSB_S/,/$LSB_E/ s/# $2: \(.*\)/\1/p" $1
 }
 
+# If the currently running init daemon is upstart, return zero; if the
+# calling init script belongs to a package which also provides a native
+# upstart job, it should generally exit non-zero in this case.
+init_is_upstart()
+{
+   if which initctl && initctl version | grep -q upstart
+   then
+       return 0
+   fi
+   return 1
+}
+
 # int log_begin_message (char *message)
 log_begin_msg () {
     log_begin_msg_pre "$@"