From 6876d60cdd17a7336c35df2e1769f9da0a98a324 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 22 Jul 2014 15:48:27 +0100 Subject: Fix Debian bug #238921 about argument handling in init script --- debian/plptools.init | 102 +++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 56 deletions(-) (limited to 'debian/plptools.init') diff --git a/debian/plptools.init b/debian/plptools.init index cb66707..6124c9b 100644 --- a/debian/plptools.init +++ b/debian/plptools.init @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/bash ### BEGIN INIT INFO # Provides: plptools # Required-Start: $remote_fs $syslog @@ -28,88 +28,78 @@ test -f $CONFIG && . $CONFIG || exit 0 set -e +plptools-run-daemon () { + daemon=$1 + shift + # Get rid of empty first argument caused by leading white space or empty arguments + if test "$1" = ""; then shift; fi + echo -n "Starting $DESC ($daemon): " + start-stop-daemon --start --quiet \ + --exec "$daemon" -- "$@" && \ + echo -n "done" || echo -n "failed" + echo "." +} + case "$1" in - start) + start) if test "$START_NCPD" = "yes" ; then - echo -n "Starting $DESC ($NCPD): " - start-stop-daemon --start --quiet \ - --exec $NCPD -- $NCPD_ARGS && \ - echo -n "done" || echo -n "failed" - echo "." - sleep 1 + plptools-run-daemon "$NCPD" "${NCPD_ARGS[@]}" + sleep 1 fi if test "$START_PLPFUSE" = "yes" ; then - echo -n "Starting $DESC ($PLPFUSE): " - start-stop-daemon --start --quiet \ - --exec $PLPFUSE -- $PLPFUSE_ARGS $MOUNTPOINT && \ - echo -n "done" || echo -n "failed" - echo "." + plptools-run-daemon "$PLPFUSE" "${PLPFUSE_ARGS[@]}" "$MOUNTPOINT" fi if test "$START_PLPPRINTD" = "yes" ; then - echo -n "Starting $DESC ($PLPPRINTD): " - start-stop-daemon --start --quiet \ - --exec $PLPPRINTD -- $PLPPRINTD_ARGS && \ - echo -n "done" || echo -n "failed" - echo "." + plptools-run-daemon "$PLPPRINTD" "${PLPPRINTD_ARGS[@]}" fi ;; - stop) + stop) if test "$START_PLPFUSE" = "yes" ; then - echo -n "Stopping $DESC ($PLPFUSE): " - if [ "$(uname)" = Linux ]; then - fusermount -z -u $MOUNTPOINT || true - elif [ "$(uname)" = GNU/kFreeBSD ]; then - umount $MOUNTPOINT || true - else - echo "Port me" >&2 - exit 1 - fi - start-stop-daemon --stop --retry HUP/5/TERM/1 --quiet \ - --exec $PLPFUSE && \ - echo -n "done" || echo -n "already stopped" - echo "." + echo -n "Stopping $DESC ($PLPFUSE): " + if [ "$(uname)" = Linux ]; then + fusermount -z -u "$MOUNTPOINT" || true + elif [ "$(uname)" = GNU/kFreeBSD ]; then + umount "$MOUNTPOINT" || true + else + echo "I don't know how to unmount a FUSE filing system on this OS" >&2 + exit 1 + fi + start-stop-daemon --stop --retry HUP/5/TERM/1 --quiet \ + --exec "$PLPFUSE" && \ + echo -n "done" || echo -n "already stopped" + echo "." fi if test "$START_PLPPRINTD" = "yes" ; then - echo -n "Stopping $DESC ($PLPPRINTD): " - start-stop-daemon --stop --quiet --exec $PLPPRINTD && \ - echo -n "done" || echo -n "already stopped" - echo "." + echo -n "Stopping $DESC ($PLPPRINTD): " + start-stop-daemon --stop --quiet --exec "$PLPPRINTD" && \ + echo -n "done" || echo -n "already stopped" + echo "." fi if test "$START_NCPD" = "yes" ; then - echo -n "Stopping $DESC ($NCPD): " - start-stop-daemon --stop --quiet --exec $NCPD && \ - echo -n "done" || echo -n "already stopped" - echo "." + echo -n "Stopping $DESC ($NCPD): " + start-stop-daemon --stop --quiet --exec "$NCPD" && \ + echo -n "done" || echo -n "already stopped" + echo "." fi - - ;; - reload) ;; - restart|force-reload) - # - # If the "reload" option is implemented, move the "force-reload" - # option to the "reload" entry above. If not, "force-reload" is - # just the same as "restart". - # + restart|force-reload) $0 stop sleep 1 $0 start ;; - status) + status) if "$START_NCPD" = "yes" ; then - status_of_proc "$NCPD" ncpd || exit $? + status_of_proc "$NCPD" ncpd || exit $? fi if "$START_PLPFUSE" = "yes" ; then - status_of_proc "$PLPFUSE" plpfuse || exit $? + status_of_proc "$PLPFUSE" plpfuse || exit $? fi if "$START_PLPPRINTD" = "yes" ; then - status_of_proc "$PLPPRINTD" plpprintd || exit $? + status_of_proc "$PLPPRINTD" plpprintd || exit $? fi - exit 0 ;; - *) + *) N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; -- cgit v1.2.3