aboutsummaryrefslogtreecommitdiffstats
path: root/debian/plptools.init
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2014-07-22 15:48:27 +0100
committerReuben Thomas <rrt@sc3d.org>2014-07-22 15:48:27 +0100
commit6876d60cdd17a7336c35df2e1769f9da0a98a324 (patch)
treea8c67e174610c13854a05a1a35a32a7104e94bbd /debian/plptools.init
parentd7ca70692a35637e9efeae051951af7f30a05640 (diff)
downloadplptools-6876d60cdd17a7336c35df2e1769f9da0a98a324.tar.gz
plptools-6876d60cdd17a7336c35df2e1769f9da0a98a324.tar.bz2
plptools-6876d60cdd17a7336c35df2e1769f9da0a98a324.zip
Fix Debian bug #238921 about argument handling in init script
Diffstat (limited to 'debian/plptools.init')
-rw-r--r--debian/plptools.init102
1 files changed, 46 insertions, 56 deletions
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
;;