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

Bug#661109: lsb: Please include helper function for init scripts on upstart-based systems



tags 661109 -moreinfo +pending
thanks

Le 01.05.2012 07:42, Steve Langasek a écrit :
> My opinion is that this is best done in the single /lib/lsb/init-functions
> file.  The filename is an interface defined in the LSB, but there's nothing
> in the LSB that says this interface can't provide additional shell
> functions; and having this all in a single place simplifies the interface
> for the Debian init scripts.  And if you've followed the discussion on
> debian-devel, you know that there's quite a lot of interest in having
> simpler init scripts. :)
> 
> If you decide not to include this patch in lsb/init-functions, then I guess
> I'll propose a new shell include as you describe; but I really don't think
> that's the best solution.

That's convincing enough for me. I just committed the attached patch and
will push it later today. I plan to upload it after the new Fancy output
(as 4.1+Debian1) will have reached testing, along with other stuff.

Thanks for your patch, cheers,

OdyX
From c766b98712af007ff80e42dbbf5fc42535efe625 Mon Sep 17 00:00:00 2001
From: Steve Langasek <steve.langasek@canonical.com>
Date: Tue, 1 May 2012 08:55:45 +0200
Subject: [PATCH] Add a new helper function: init_is_upstart().

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 |    8 ++++++++
 init-functions                |   12 ++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/debian/lsb-base.README.Debian b/debian/lsb-base.README.Debian
index 6be48f9..5533b30 100644
--- a/debian/lsb-base.README.Debian
+++ b/debian/lsb-base.README.Debian
@@ -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.
 
diff --git a/init-functions b/init-functions
index 18fd2bd..c9abd33 100644
--- a/init-functions
+++ b/init-functions
@@ -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 "$@"
-- 
1.7.2.5

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: