From da6d8fec021a1e3667b61a59b72153b4aea893d3 Mon Sep 17 00:00:00 2001 From: Chris Lawrence Date: Mon, 14 Jul 2008 11:30:52 -0500 Subject: [PATCH] lsb 3.2-14 Debian release. --- debian/changelog | 10 +++++++ debian/lsb-base.README.Debian | 17 ++++++++++- init-functions | 55 ++++++++++++++++++++++++++--------- 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5f8a033..757fa7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +lsb (3.2-14) unstable; urgency=low + + * Update pidofproc(), status_of_proc() to sync with Ubuntu. + Thanks to Dustin Kirkland. (Closes: #490095) + * Add hooks to init-functions, thanks to Miroslav Jezbera. + These are documented in README.Debian in lsb-base. + (Closes: #490408) + + -- Chris Lawrence Mon, 14 Jul 2008 11:30:52 -0500 + lsb (3.2-13) unstable; urgency=low * Include status_of_proc() function from Ubuntu's lsb-base. diff --git a/debian/lsb-base.README.Debian b/debian/lsb-base.README.Debian index 0ca9871..d39610d 100644 --- a/debian/lsb-base.README.Debian +++ b/debian/lsb-base.README.Debian @@ -130,4 +130,19 @@ Bourne-style shell permitted by Debian policy (i.e. not just bash). "Fancy output" can be overriden by setting FANCYTTY=0 in this file. - -- Chris Lawrence , Sat, 26 Aug 2006 21:40:06 -0500 +From lsb-base 3.2-14, you can use the following hook functions which +are called by the appropriate functions, instead of supplying your own +logging functions: + +log_daemon_msg_pre +log_daemon_msg_post +log_end_msg_pre +log_end_msg_post +log_action_end_msg_post +log_action_end_msg_post + +Each function receives all of the arguments sent to the parent +function; the "pre" functions operate before any output, while the +"post" functions operate after the output is produced. + + -- Chris Lawrence , Mon, 14 Jul 2008 11:34:48 -0500 diff --git a/init-functions b/init-functions index 51670b5..cddd918 100644 --- a/init-functions +++ b/init-functions @@ -81,14 +81,17 @@ pidofproc () { if $(kill -0 "${pid:-}" 2> /dev/null); then echo "$pid" return 0 + elif ps "${pid:-}" >/dev/null 2>&1; then + echo "$pid" + return 0 # program is running, but not owned by this user else return 1 # program is dead and /var/run pid file exists fi fi fi if [ -x /bin/pidof -a ! "$specified" ]; then - /bin/pidof -o %PPID $1 - status="$?" + status="0" + /bin/pidof -o %PPID $1 || status="$?" if [ "$status" = 1 ]; then return 3 # program is not running fi @@ -137,7 +140,7 @@ killproc () { if [ -n "$sig" ]; then return 0 fi - return 0 # program is not running + return 3 # program is not running fi if [ "$status" = 0 -a "$is_term_sig" = yes ]; then @@ -148,22 +151,32 @@ killproc () { # Return LSB status status_of_proc () { - local daemon name status + local pidfile daemon name status + + pidfile= + OPTIND=1 + while getopts p: opt ; do + case "$opt" in + p) pidfile="$OPTARG";; + esac + done + shift $(($OPTIND - 1)) + + if [ -n "$pidfile" ]; then + pidfile="-p $pidfile" + fi daemon="$1" name="$2" + status="0" - if [ -x /bin/pidof ]; then - /bin/pidof -o %PPID "$daemon" >/dev/null || status="$?" - if [ "$status" = 0 ]; then - log_success_msg "$name is running." - else - log_failure_msg "$name is not running." - fi + pidofproc $pidfile $daemon >/dev/null || status="$?" + if [ "$status" = 0 ]; then + log_success_msg "$name is running." + return 0 else - log_failure_msg "/bin/pidof not available." - status="1" + log_failure_msg "$name is not running." + return $status fi - return "$status" } log_use_fancy_output () { @@ -243,6 +256,7 @@ log_daemon_msg () { if [ -z "${1:-}" ]; then return 1 fi + log_daemon_msg_pre "$@" if [ -z "${2:-}" ]; then echo -n "$1:" @@ -250,6 +264,7 @@ log_daemon_msg () { fi echo -n "$1: $2" + log_daemon_msg_post "$@" } # #319739 @@ -281,6 +296,7 @@ log_end_msg () { if [ -z "${1:-}" ]; then return 1 fi + log_end_msg_pre "$@" # Only do the fancy stuff if we have an appropriate terminal # and if /usr is already mounted @@ -299,6 +315,7 @@ log_end_msg () { echo " failed!" fi fi + log_end_msg_post "$@" return $1 } @@ -315,6 +332,7 @@ log_action_cont_msg () { } log_action_end_msg () { + log_action_end_msg_pre "$@" if [ -z "${2:-}" ]; then end="." else @@ -332,7 +350,16 @@ log_action_end_msg () { echo "failed${end}" fi fi + log_action_end_msg_post "$@" } +# Hooks for /etc/lsb-base-logging.sh +log_daemon_msg_pre () { :; } +log_daemon_msg_post () { :; } +log_end_msg_pre () { :; } +log_end_msg_post () { :; } +log_action_end_msg_post () { :; } +log_action_end_msg_post () { :; } + FANCYTTY= [ -e /etc/lsb-base-logging.sh ] && . /etc/lsb-base-logging.sh || true -- 2.30.2