Package: munin-async Version: 2.0.6-4+deb7u1 Severity: normal Tags: patch Dear Maintainer,
I needed a status to run this init under puppet without continious restarts. While adding this (copied from munin-node) I noticed the pid file wasn't remove on stop and the the SCRIPTNAME was wrong. -- System Information: Debian Release: 7.1 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.9.3-x86_64-linode33 (SMP w/8 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages munin-async depends on: ii adduser 3.113+nmu3 ii munin-common 2.0.6-4+deb7u1 ii munin-node 2.0.6-4+deb7u1 ii perl 5.14.2-21 ii perl-modules 5.14.2-21 munin-async recommends no packages. munin-async suggests no packages. -- Configuration Files: /etc/init.d/munin-async changed: PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Munin asynchronous server" NAME=munin-asyncd DAEMON=/usr/share/munin/$NAME DAEMON_ARGS="" DAEMON_USER="munin-async" PIDFILE=/var/run/munin/$NAME.pid SCRIPTNAME=/etc/init.d/munin-async [ -x "$DAEMON" ] || exit 0 [ -r /etc/default/$NAME ] && . /etc/default/$NAME . /lib/init/vars.sh . /lib/lsb/init-functions do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --chuid $DAEMON_USER --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --chuid $DAEMON_USER --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 } do_stop() { # killproc() doesn't try hard enough if the pid file is missing, # so create it is gone and the daemon is still running if [ ! -r $PIDFILE ]; then pid=$(pidofproc -p $PIDFILE $DAEMON) if [ -z "$pid" ]; then [ "$VERBOSE" != no ] && log_progress_msg "stopped beforehand" log_end_msg 0 return 0 fi echo $pid 2>/dev/null > $PIDFILE if [ $? -ne 0 ]; then log_end_msg 1 return 1 fi fi killproc -p $PIDFILE /usr/bin/munin-node ret=$? # killproc() isn't thorough enough, ensure the daemon has been # stopped manually attempts=0 until ! pidofproc -p $PIDFILE $DAEMON >/dev/null; do attempts=$(( $attempts + 1 )) sleep 0.05 [ $attempts -lt 20 ] && continue log_end_msg 1 return 1 done rm "$PIDFILE" [ $ret -eq 0 ] && [ "$VERBOSE" != no ] && log_progress_msg "done" log_end_msg $ret return $ret } do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # start-stop-daemon --stop --signal 1 --background --make-pidfile --quiet --pidfile $PIDFILE --exec $DAEMON return 0 } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; #reload|force-reload) # # If do_reload() is not implemented then leave this commented out # and leave 'force-reload' as an alias for 'restart'. # #log_daemon_msg "Reloading $DESC" "$NAME" #do_reload #log_end_msg $? #;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; status) pid=$(pidofproc -p $PIDFILE $DAEMON) ret=$? pid=${pid% } # pidofproc() supplies a trailing space, strip it if [ $ret -eq 0 ]; then log_success_msg "Munin-Async is running (PID: $pid)" exit 0 # the LSB specifies that I in this case (daemon dead + pid file exists) # should return 1, however lsb-base returned 2 in this case up to and # including version 3.1-10 (cf. #381684). Since that bug is present # in Sarge, Ubuntu Dapper, and (at the time of writing) Ubuntu Etch, # and taking into account that later versions of pidofproc() do not # under any circumstance return 2, I'll keep understanding invalid # return code for the time being, even though the LSB specifies it is # to be used for the situation where the "program is dead and /var/lock # lock file exists". elif [ $ret -eq 1 ] || [ $ret -eq 2 ]; then log_failure_msg "Munin-Async is dead, although $PIDFILE exists." exit 1 elif [ $ret -eq 3 ]; then log_warning_msg "Munin-Async is not running." exit 3 fi log_warning_msg "Munin-Async status unknown." exit 4 ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac : -- no debconf information
--- munin-async.orig 2013-08-20 02:08:43.000000000 +0000 +++ munin-async 2013-08-20 02:17:01.000000000 +0000 @@ -21,7 +21,7 @@ DAEMON_ARGS="" DAEMON_USER="munin-async" PIDFILE=/var/run/munin/$NAME.pid -SCRIPTNAME=/etc/init.d/$NAME +SCRIPTNAME=/etc/init.d/munin-async # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 @@ -84,6 +84,7 @@ log_end_msg 1 return 1 done + rm "$PIDFILE" [ $ret -eq 0 ] && [ "$VERBOSE" != no ] && log_progress_msg "done" log_end_msg $ret return $ret @@ -150,9 +151,35 @@ ;; esac ;; + status) + pid=$(pidofproc -p $PIDFILE $DAEMON) + ret=$? + pid=${pid% } # pidofproc() supplies a trailing space, strip it + if [ $ret -eq 0 ]; then + log_success_msg "Munin-Async is running (PID: $pid)" + exit 0 + # the LSB specifies that I in this case (daemon dead + pid file exists) + # should return 1, however lsb-base returned 2 in this case up to and + # including version 3.1-10 (cf. #381684). Since that bug is present + # in Sarge, Ubuntu Dapper, and (at the time of writing) Ubuntu Etch, + # and taking into account that later versions of pidofproc() do not + # under any circumstance return 2, I'll keep understanding invalid + # return code for the time being, even though the LSB specifies it is + # to be used for the situation where the "program is dead and /var/lock + # lock file exists". + elif [ $ret -eq 1 ] || [ $ret -eq 2 ]; then + log_failure_msg "Munin-Async is dead, although $PIDFILE exists." + exit 1 + elif [ $ret -eq 3 ]; then + log_warning_msg "Munin-Async is not running." + exit 3 + fi + log_warning_msg "Munin-Async status unknown." + exit 4 + ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 exit 3 ;; esac