Package: lastfmsubmitd Version: 1.0.6-4 Followup-For: Bug #692329 Hi. Here's the modification to account to the change of pidofproc's behaviour in the latest lsb-base package.
-- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 3.5-trunk-686-pae (SMP w/2 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 lastfmsubmitd depends on: ii adduser 3.113+nmu3 ii debconf [debconf-2.0] 1.5.46 ii python 2.7.3-3 ii python-support 1.0.15 lastfmsubmitd recommends no packages. Versions of packages lastfmsubmitd suggests: pn ears <none> -- Configuration Files: /etc/init.d/lastfmsubmitd changed: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/lastfmsubmitd NAME=lastfmsubmitd DESC="Last.fm submission daemon" RUNDIR=/var/run/lastfm PIDFILE=$RUNDIR/$NAME.pid USER=lastfm GROUP=lastfm [ -x "$DAEMON" ] || exit 5 [ -r /etc/default/$NAME ] && . /etc/default/$NAME .. /lib/init/vars.sh .. /lib/lsb/init-functions if [ ! -d ${RUNDIR} ] ; then mkdir -p ${RUNDIR} || true if [ -d ${RUNDIR} ] ; then chown ${USER}:${GROUP} ${RUNDIR} chmod 2775 ${RUNDIR} fi fi do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started pid=$(pidofproc -p $PIDFILE $DAEMON) if [ -n "$pid" ] ; then return 1 fi start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$GROUP \ --exec $DAEMON -- $DAEMON_ARGS \ || return 2 } do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred pid=$(pidofproc -p $PIDFILE $DAEMON) if [ -z "$pid" ] ; then return 1 fi start-stop-daemon --stop --quiet --pidfile $PIDFILE \ --name $NAME --user $USER RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 rm -f $PIDFILE return "$RETVAL" } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 1) [ "$VERBOSE" != no ] && log_progress_msg "is running" ; log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 1) [ "$VERBOSE" != no ] && log_progress_msg "is stopped" ; log_end_msg 0 ;; 2) log_end_msg 1 ;; esac ;; restart|force-reload) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Old process is still running *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? exit $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 exit 1 ;; esac exit 0 -- debconf information excluded
--- lastfmsubmitd.orig 2012-11-19 21:21:57.511940059 +0200 +++ /etc/init.d/lastfmsubmitd 2012-11-19 21:20:16.519481916 +0200 @@ -1,12 +1,12 @@ -#!/bin/sh -e +#!/bin/sh ### BEGIN INIT INFO # Provides: lastfmsubmitd -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog +# Required-Start: $remote_fs $syslog $network +# Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Start and stop lastfmsubmit daemon +# Short-Description: Submission daemon for the Last.fm social music network ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin @@ -14,12 +14,23 @@ NAME=lastfmsubmitd DESC="Last.fm submission daemon" RUNDIR=/var/run/lastfm +PIDFILE=$RUNDIR/$NAME.pid USER=lastfm GROUP=lastfm -if ! [ -x $DAEMON ]; then - exit 0 -fi +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 5 + +# Read configuration variable file if it is present +# you can put here daemon arguments, like --debug +# Ex: DAEMON_ARGS="--debug" +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +. /lib/lsb/init-functions if [ ! -d ${RUNDIR} ] ; then mkdir -p ${RUNDIR} || true @@ -29,31 +40,90 @@ fi fi +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + pid=$(pidofproc -p $PIDFILE $DAEMON) + if [ -n "$pid" ] ; then + return 1 + fi + start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$GROUP \ + --exec $DAEMON -- $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + pid=$(pidofproc -p $PIDFILE $DAEMON) + if [ -z "$pid" ] ; then + return 1 + fi + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --name $NAME --user $USER + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + rm -f $PIDFILE + return "$RETVAL" +} + case "$1" in start) - echo -n "Starting $DESC: " - start-stop-daemon --quiet --start -c $USER:$GROUP \ - --pidfile $RUNDIR/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS - echo "$NAME." + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 1) [ "$VERBOSE" != no ] && log_progress_msg "is running" ; log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac ;; stop) - echo -n "Stopping $DESC: " - start-stop-daemon --quiet --oknodo --stop -u $USER \ - --pidfile $RUNDIR/$NAME.pid - echo "$NAME." + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 1) [ "$VERBOSE" != no ] && log_progress_msg "is stopped" ; log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac ;; restart|force-reload) - echo -n "Restarting $DESC: " - start-stop-daemon --quiet --oknodo --stop -u $USER \ - --pidfile $RUNDIR/$NAME.pid - sleep 1 - start-stop-daemon --quiet --start -c $USER:$GROUP \ - --pidfile $RUNDIR/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS - echo "$NAME." + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Old process is still running + *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + [ "$VERBOSE" != no ] && log_end_msg 1 + ;; + esac + ;; + status) + status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? + exit $? ;; *) N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload}" >&2 + echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 exit 1 ;; esac