Browse Source

Improve init script: Print missing declarations, sleep while waiting for shutdown

Christoph Biedl 3 years ago
parent
commit
8a8ce9f6c9
1 changed files with 62 additions and 3 deletions
  1. 62 3
      debian/patches/improve-init-scripts.patch

+ 62 - 3
debian/patches/improve-init-scripts.patch

@@ -64,7 +64,50 @@ Forwarded: not-yet
          status)
          status)
 --- a/contrib/persistence/vblade.init.lsb-daemon
 --- a/contrib/persistence/vblade.init.lsb-daemon
 +++ b/contrib/persistence/vblade.init.lsb-daemon
 +++ b/contrib/persistence/vblade.init.lsb-daemon
-@@ -77,6 +77,12 @@
+@@ -30,6 +30,14 @@
+ # Define LSB functions
+ . /lib/lsb/init-functions
+ 
++missing () {
++    local MESSAGE
++
++    MESSAGE="Did not define $1"
++    [ "$VERBOSE" != no ] && log_daemon_msg "$INSTANCE.conf" "$MESSAGE"
++    return 1
++}
++
+ # Start a vblade instance
+ #
+ # Return
+@@ -37,8 +45,10 @@
+ #   1 if daemon was already running
+ #   2 if daemon could not be started
+ do_start () {
+-    local INSTANCE="$1"
+-    local CONFIG="$2"
++    local INSTANCE
++    local CONFIG
++    INSTANCE="$1"
++    CONFIG="$2"
+ 
+     sh -n "$CONFIG" 2>/dev/null || return 2
+ 
+@@ -51,10 +61,10 @@
+ 
+     . "$CONFIG"
+ 
+-    [ "$netif" ] || return 2
+-    [ "$shelf" ] || return 2
+-    [ "$slot" ] || return 2
+-    [ "$filename" ] || return 2
++    [ "$netif" ] || missing netif || return 2
++    [ "$shelf" ] || missing shelf || return 2
++    [ "$slot" ] || missing slot || return 2
++    [ "$filename" ] || missing filename || return 2
+ 
+     if [ "$ionice" ] ; then
+         if [ -x "$IONICE" ] ; then
+@@ -77,6 +87,12 @@
          --stdout daemon.notice \
          --stdout daemon.notice \
          --stderr daemon.err -- \
          --stderr daemon.err -- \
          $VBLADE $options $shelf $slot $netif $filename || return 2
          $VBLADE $options $shelf $slot $netif $filename || return 2
@@ -77,7 +120,23 @@ Forwarded: not-yet
  }
  }
  
  
  # Stop a vblade instance
  # Stop a vblade instance
-@@ -121,7 +127,10 @@
+@@ -99,12 +115,14 @@
+         --pidfiles "$PIDDIR" \
+         --stop || return 2
+     # Wait until the process is gone
+-    for i in $(seq 1 10) ; do
++    for i in $(seq 1 3) ; do
+         "$DAEMON" \
+             --running \
+             --name "$INSTANCE" \
+             --pidfiles "$PIDDIR" || return 0
++        sleep 1
+     done
++    # If it still didn't stop..
+     return 2
+ }
+ 
+@@ -121,7 +139,10 @@
              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 ;;
@@ -89,7 +148,7 @@ Forwarded: not-yet
              esac
              esac
              ;;
              ;;
          stop)
          stop)
-@@ -129,7 +138,10 @@
+@@ -129,7 +150,10 @@
              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 ;;