Browse Source

Improve init script

* Fix daemon definition and typos
* Check daemon was really started
* Exit non-zero if start or stop failed
Christoph Biedl 3 years ago
parent
commit
65bf2a7316
1 changed files with 15 additions and 6 deletions
  1. 15 6
      debian/softflowd.init

+ 15 - 6
debian/softflowd.init

@@ -57,15 +57,18 @@ do_start () {
     local PIDFILE="$PIDDIR$INSTANCE.pid"
     local CTLSOCK="$PIDDIR$INSTANCE.ctl"
     start-stop-daemon --start --quiet \
-        --pidfile "$PIDFILE" --exec "$VBLADE" --test > /dev/null \
+        --pidfile "$PIDFILE" --exec "$SOFTFLOWD" --test > /dev/null \
         || return 1
     start-stop-daemon --start --quiet \
         --pidfile "$PIDFILE" \
-        --exec $ionice "$SOFTFLOWD" -- \
+        --exec "$SOFTFLOWD" -- \
         -p "$PIDFILE" -c "$CTLSOCK" \
         -i "$interface" $options \
         || return 2
-
+    sleep 1
+    start-stop-daemon --start --quiet \
+        --pidfile "$PIDFILE" --exec "$SOFTFLOWD" --test > /dev/null \
+        && return 2
 }
 
 # Stop a softflowd instance
@@ -101,7 +104,10 @@ do_action () {
             do_start "$INSTANCE" "$CONFIG"
             case "$?" in
                 0|1)    [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-                2)      [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+                2)
+                    [ "$VERBOSE" != no ] && log_end_msg 1
+                    EXIT=1
+                    ;;
             esac
             ;;
         stop)
@@ -109,7 +115,10 @@ do_action () {
             do_stop "$INSTANCE"
             case "$?" in
                 0|1)    [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-                2)      [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+                2)
+                    [ "$VERBOSE" != no ] && log_end_msg 1
+                    EXIT=1
+                    ;;
             esac
             ;;
         status)
@@ -136,7 +145,7 @@ do_action () {
                 esac
             ;;
         *)
-            echo "Usage: /etc/init.d/softflowd {start|stop|status|restart|force-reload} [<export> ...]" >&2
+            echo "Usage: /etc/init.d/softflowd {start|stop|status|restart|force-reload} [<instance> ...]" >&2
             exit 3
             ;;
     esac