Fixed init script not working correctly
authorMitchell Pomery <[email protected]>
Sun, 1 Mar 2015 15:00:00 +0000 (23:00 +0800)
committerMark Tearle <[email protected]>
Sun, 1 Mar 2015 15:51:11 +0000 (23:51 +0800)
bin/init.d/vendserver

index 3390401..438bbf7 100755 (executable)
@@ -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

UCC git Repository :: git.ucc.asn.au