| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 | 
							- Subject: Improve init scripts
 
- Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
 
- Forwarded: not-yet
 
- Last-Update: 2024-06-19
 
- --- a/contrib/persistence/vblade.init.in
 
- +++ b/contrib/persistence/vblade.init.in
 
- @@ -8,7 +8,7 @@
 
-  # Default-Start:     2 3 4 5
 
-  # Default-Stop:      0 1 6
 
-  # Short-Description: vblade exports
 
- -# Description:       Manage all vlbade exports defined in
 
- +# Description:       Manage all vblade exports defined in
 
-  #                    /etc/vblade.conf.d/
 
-  ### END INIT INFO
 
-  
 
- @@ -98,6 +98,10 @@
 
-          --exec $ionice "$VBLADE" -- \
 
-          $shelf $slot $netif $filename $options \
 
-          || return 2
 
- +    sleep 1
 
- +    start-stop-daemon --start --quiet \
 
- +        --pidfile "$PIDFILE" --exec "$VBLADE" --test > /dev/null \
 
- +        && return 2
 
-  [% ELSIF control == 'daemon' -%]
 
-      "$DAEMON" \
 
-          --running \
 
- @@ -112,6 +116,12 @@
 
-          --stdout daemon.notice \
 
-          --stderr daemon.err -- \
 
-          $VBLADE $options $shelf $slot $netif $filename || return 2
 
- +    sleep 1
 
- +    "$DAEMON" \
 
- +        --running \
 
- +        --name "$INSTANCE" \
 
- +        --pidfiles "$PIDDIR" \
 
- +        || return 2
 
-  [% END -%]
 
-  }
 
-  
 
- @@ -168,7 +178,10 @@
 
-              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)
 
- @@ -176,7 +189,10 @@
 
-              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)
 
- --- a/contrib/persistence/vblade.init.lsb-daemon
 
- +++ b/contrib/persistence/vblade.init.lsb-daemon
 
- @@ -22,13 +22,23 @@
 
-  [ -x "$VBLADE" ] || exit 0
 
-  [ -x "$DAEMON" ] || exit 0
 
-  
 
- +. /usr/lib/lsb/init-functions
 
- +
 
-  mkdir -p "$PIDDIR"
 
-  
 
-  # Load the VERBOSE setting and other rcS variables
 
- -. /lib/init/vars.sh
 
- +. /usr/lib/init/vars.sh
 
-  
 
-  # Define LSB functions
 
- -. /lib/lsb/init-functions
 
- +. /usr/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
 
-  #
 
- @@ -37,8 +47,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 +63,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 +89,12 @@
 
-          --stdout daemon.notice \
 
-          --stderr daemon.err -- \
 
-          $VBLADE $options $shelf $slot $netif $filename || return 2
 
- +    sleep 1
 
- +    "$DAEMON" \
 
- +        --running \
 
- +        --name "$INSTANCE" \
 
- +        --pidfiles "$PIDDIR" \
 
- +        || return 2
 
-  }
 
-  
 
-  # Stop a vblade instance
 
- @@ -99,12 +117,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 +141,10 @@
 
-              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)
 
- @@ -129,7 +152,10 @@
 
-              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)
 
 
  |