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

"Didier 'OdyX' Raboud" <[email protected]>
Newsgroups gmane.linux.debian.devel.lsb
Organization Debian, the Universal OS
Message-ID <4F9F94A8.7080500__15596.1346732967$1335858501$gmane$org@debian.org>
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
0001-Add-a-new-helper-function-init_is_upstart.patch (text/x-diff, 2 KB)
From c766b98712af007ff80e42dbbf5fc42535efe625 Mon Sep 17 00:00:00 2001
From: Steve Langasek <[email protected]>
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 <[email protected]>
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
signature.asc (application/pgp-signature, 663 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQGcBAEBAgAGBQJPn5SwAAoJEIvPpx7KFjRV4qkL+wSARl68sMv5w9RNrNSIVU7E
Zz0pMdxtAnccvzASFooJrmRomMhqLBnGpwa/udoCcEdSkrkuF6n7i92m8OyjRBGs
fW/PBKTI9DkmQ4v/f7yDMOWxc4dNZfn0qEBQO67hgU0VffMKeLZNmNAwjTiagC3w
MxLgT9ZMP3ZKBrc8g/8rv/5TPQieIf5oYgSCHJuX+GjHYYEEFubdgGzx7EAN68G3
lbWMp2IjONAQXU90KsTiQ8tizhhilytEA0DX9Vx/7oySoMJ3MrqEVntP0DuUeqHY
XkoKuxBADAUd0+oQYGY3ha9tE3h28UWdjHYZ8CR8FksdFdCjtf/M9aY77b6iz3l9
yt8//0T+obOJEmOegLbVvRm0k9j6IG7EpzpvDDtCfjopLZYrnDaUodDrdnlIeOJg
dEGmz6+fzcsilTtHpnt1MU3yqSM+prefPZJJ615i3yBLaktZghmxL5AX2K90t/AN
6tV9VBC4vwRUnYOIUOCHLSRHH1UNw6NeCWatzsjzTA==
=DnBB
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.