From bebd1393c36f360b0a5e16289d699f02369f61fd Mon Sep 17 00:00:00 2001 From: Mitchell Pomery Date: Sun, 1 Mar 2015 23:00:00 +0800 Subject: [PATCH] Fixed init script not working correctly --- bin/init.d/vendserver | 58 ++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/bin/init.d/vendserver b/bin/init.d/vendserver index 3390401..438bbf7 100755 --- a/bin/init.d/vendserver +++ b/bin/init.d/vendserver @@ -19,43 +19,45 @@ PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME DAEMON_ARGS="" -# Gracefully exit if the package has been removed. -test -x $DAEMON || exit 0 +# Say something and gracefully exit if the package has been removed. +if ! test -x $DAEMON; then + echo "Failed to find the executable $DAEMON" + exit 1 +fi + d_start() { - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --nicelevel 5 \ - --exec $DAEMON -- -d -sdaemon --pid-file=$PIDFILE \ + start-stop-daemon --start --pidfile $PIDFILE --nicelevel 5 \ + --startas $DAEMON -- -d -sdaemon --pid-file=$PIDFILE \ $DAEMON_ARGS } d_stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE \ - --name $NAME + start-stop-daemon --stop --pidfile $PIDFILE } case "$1" in - start) - echo -n "Starting $DESC: $NAME" - d_start - echo "." - ;; - stop) - echo -n "Stopping $DESC: $NAME" - d_stop - echo "." - ;; - restart|force-reload) - echo -n "Restarting $DESC: $NAME" - d_stop - sleep 1 - d_start - echo "." - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 - exit 1 - ;; + start) + echo -n "Starting $DESC: $NAME\n" + d_start + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME\n" + d_stop + echo "." + ;; + restart|force-reload) + echo -n "Restarting $DESC: $NAME\n" + d_stop + sleep 1 + d_start + echo "." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; esac exit 0 -- 2.20.1