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