1
0

for-upstream.improve-init-scripts.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. Subject: Improve init scripts
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Forwarded: not-yet
  4. Last-Update: 2024-06-19
  5. --- a/contrib/persistence/vblade.init.in
  6. +++ b/contrib/persistence/vblade.init.in
  7. @@ -8,7 +8,7 @@
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: vblade exports
  11. -# Description: Manage all vlbade exports defined in
  12. +# Description: Manage all vblade exports defined in
  13. # /etc/vblade.conf.d/
  14. ### END INIT INFO
  15. @@ -98,6 +98,10 @@
  16. --exec $ionice "$VBLADE" -- \
  17. $shelf $slot $netif $filename $options \
  18. || return 2
  19. + sleep 1
  20. + start-stop-daemon --start --quiet \
  21. + --pidfile "$PIDFILE" --exec "$VBLADE" --test > /dev/null \
  22. + && return 2
  23. [% ELSIF control == 'daemon' -%]
  24. "$DAEMON" \
  25. --running \
  26. @@ -112,6 +116,12 @@
  27. --stdout daemon.notice \
  28. --stderr daemon.err -- \
  29. $VBLADE $options $shelf $slot $netif $filename || return 2
  30. + sleep 1
  31. + "$DAEMON" \
  32. + --running \
  33. + --name "$INSTANCE" \
  34. + --pidfiles "$PIDDIR" \
  35. + || return 2
  36. [% END -%]
  37. }
  38. @@ -168,7 +178,10 @@
  39. do_start "$INSTANCE" "$CONFIG"
  40. case "$?" in
  41. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  42. - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  43. + 2)
  44. + [ "$VERBOSE" != no ] && log_end_msg 1
  45. + EXIT=1
  46. + ;;
  47. esac
  48. ;;
  49. stop)
  50. @@ -176,7 +189,10 @@
  51. do_stop "$INSTANCE"
  52. case "$?" in
  53. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  54. - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  55. + 2)
  56. + [ "$VERBOSE" != no ] && log_end_msg 1
  57. + EXIT=1
  58. + ;;
  59. esac
  60. ;;
  61. status)
  62. --- a/contrib/persistence/vblade.init.lsb-daemon
  63. +++ b/contrib/persistence/vblade.init.lsb-daemon
  64. @@ -22,13 +22,23 @@
  65. [ -x "$VBLADE" ] || exit 0
  66. [ -x "$DAEMON" ] || exit 0
  67. +. /usr/lib/lsb/init-functions
  68. +
  69. mkdir -p "$PIDDIR"
  70. # Load the VERBOSE setting and other rcS variables
  71. -. /lib/init/vars.sh
  72. +. /usr/lib/init/vars.sh
  73. # Define LSB functions
  74. -. /lib/lsb/init-functions
  75. +. /usr/lib/lsb/init-functions
  76. +
  77. +missing () {
  78. + local MESSAGE
  79. +
  80. + MESSAGE="Did not define $1"
  81. + [ "$VERBOSE" != no ] && log_daemon_msg "$INSTANCE.conf" "$MESSAGE"
  82. + return 1
  83. +}
  84. # Start a vblade instance
  85. #
  86. @@ -37,8 +47,10 @@
  87. # 1 if daemon was already running
  88. # 2 if daemon could not be started
  89. do_start () {
  90. - local INSTANCE="$1"
  91. - local CONFIG="$2"
  92. + local INSTANCE
  93. + local CONFIG
  94. + INSTANCE="$1"
  95. + CONFIG="$2"
  96. sh -n "$CONFIG" 2>/dev/null || return 2
  97. @@ -51,10 +63,10 @@
  98. . "$CONFIG"
  99. - [ "$netif" ] || return 2
  100. - [ "$shelf" ] || return 2
  101. - [ "$slot" ] || return 2
  102. - [ "$filename" ] || return 2
  103. + [ "$netif" ] || missing netif || return 2
  104. + [ "$shelf" ] || missing shelf || return 2
  105. + [ "$slot" ] || missing slot || return 2
  106. + [ "$filename" ] || missing filename || return 2
  107. if [ "$ionice" ] ; then
  108. if [ -x "$IONICE" ] ; then
  109. @@ -77,6 +89,12 @@
  110. --stdout daemon.notice \
  111. --stderr daemon.err -- \
  112. $VBLADE $options $shelf $slot $netif $filename || return 2
  113. + sleep 1
  114. + "$DAEMON" \
  115. + --running \
  116. + --name "$INSTANCE" \
  117. + --pidfiles "$PIDDIR" \
  118. + || return 2
  119. }
  120. # Stop a vblade instance
  121. @@ -99,12 +117,14 @@
  122. --pidfiles "$PIDDIR" \
  123. --stop || return 2
  124. # Wait until the process is gone
  125. - for i in $(seq 1 10) ; do
  126. + for i in $(seq 1 3) ; do
  127. "$DAEMON" \
  128. --running \
  129. --name "$INSTANCE" \
  130. --pidfiles "$PIDDIR" || return 0
  131. + sleep 1
  132. done
  133. + # If it still didn't stop..
  134. return 2
  135. }
  136. @@ -121,7 +141,10 @@
  137. do_start "$INSTANCE" "$CONFIG"
  138. case "$?" in
  139. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  140. - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  141. + 2)
  142. + [ "$VERBOSE" != no ] && log_end_msg 1
  143. + EXIT=1
  144. + ;;
  145. esac
  146. ;;
  147. stop)
  148. @@ -129,7 +152,10 @@
  149. do_stop "$INSTANCE"
  150. case "$?" in
  151. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  152. - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  153. + 2)
  154. + [ "$VERBOSE" != no ] && log_end_msg 1
  155. + EXIT=1
  156. + ;;
  157. esac
  158. ;;
  159. status)