From: Steve Langasek Date: Tue, 1 May 2012 06:55:45 +0000 (+0200) Subject: Add a new helper function: init_is_upstart(). X-Git-Tag: archive/raspbian/10.2018112800+rpi1^2~145 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c766b98712af007ff80e42dbbf5fc42535efe625;p=lsb.git 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 Closes: #661109 Git-Dch: Full --- 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 "$@"