reopen 446793 tags: patch hi!
i just upgraded lenny, and an upgrade to thttpd 2.25b-5 failed because thttpd wasn't running and the init stop failed. i'd suggest a test for the existence of the pidfile. thttpd seems just to write the pidfile but doesn't take care of removing it. so i'd also suggest some pidfile-handling. in case of thttpd exiting on its own, the pidfile will still be there. a second-best solution (after thttpd itself taking care of removing the pidfile) might be to call thttpd in a subshell with an appended ' -D; rm -f "$PIDFILE"'? and while i was at it, an exact pid grep is nicer. and not relying on filenames not having to be quoted, too. i guess i just got kind of carried away... :) regards, Chris
diff -pruN thttpd-2.25b.orig/debian/thttpd.init.d thttpd-2.25b/debian/thttpd.init.d --- thttpd-2.25b.orig/debian/thttpd.init.d 2008-05-02 12:44:43.000000000 +0200 +++ thttpd-2.25b/debian/thttpd.init.d 2008-05-02 14:31:56.000000000 +0200 @@ -19,26 +19,34 @@ NAME=thttpd CONFFILE=/etc/thttpd/thttpd.conf PIDFILE=/var/run/thttpd.pid -OPTIONS="-C $CONFFILE -i $PIDFILE" +OPTIONS="-C \"$CONFFILE\" -i \"$PIDFILE\"" -test -x $DAEMON || exit 0 -test -f $CONFFILE || exit 1 +test -x "$DAEMON" || exit 0 +test -f "$CONFFILE" || exit 1 set -e case "$1" in start) echo -n "Starting $DESC: " - start-stop-daemon -S -q -p $PIDFILE -x $DAEMON -- $OPTIONS + eval start-stop-daemon -S -q -p \"\$PIDFILE\" -x \"\$DAEMON\" -- $OPTIONS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " - if ps ax | grep "$(cat $PIDFILE)" | grep -qv grep + if [ -r "$PIDFILE" ] then - start-stop-daemon -K -q -p $PIDFILE -x $DAEMON --signal 10 + if ps ax | grep "^[ ]*$(cat "$PIDFILE")[ ]\+" | grep -qv grep + then + if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON" --signal 10 + then + rm -f "$PIDFILE" >/dev/null 2>&1 + fi + else + rm -f "$PIDFILE" >/dev/null 2>&1 + fi fi echo "$NAME." @@ -46,12 +54,12 @@ case "$1" in force-stop) echo -n "Stopping $DESC: " - start-stop-daemon -K -q -p $PIDFILE -x $DAEMON + start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON" echo "$NAME." ;; force-reload) - if start-stop-daemon -K -q -p $PIDFILE -x $DAEMON --test + if start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON" --test then $0 restart fi @@ -59,14 +67,14 @@ case "$1" in restart) echo -n "Restarting $DESC: " - start-stop-daemon -K -q -p $PIDFILE -x $DAEMON --signal 10 + start-stop-daemon -K -q -p "$PIDFILE" -x "$DAEMON" --signal 10 sleep 1 - start-stop-daemon -S -q -p $PIDFILE -x $DAEMON -- $OPTIONS + start-stop-daemon -S -q -p "$PIDFILE" -x "$DAEMON" -- $OPTIONS echo "$NAME." ;; *) - N=/etc/init.d/$NAME + N=/etc/init.d/"$NAME" echo "Usage: $N {start|stop|force-stop|restart|force-reload}" >&2 exit 1 ;;