booth/SOURCES/0009-maint-lsb-polish-arbitrator-s-initscript-fix-condres.patch

146 lines
3.7 KiB
Diff
Raw Normal View History

2019-08-05 15:53:32 +00:00
From 5703061ba7142509647eb6ee8a0155464677b45a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 19 Jul 2018 18:45:59 +0200
Subject: [PATCH 1/3] maint: lsb: polish arbitrator's initscript, fix
condrestart
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- previously, condrestart/try-restart (regardless whether "multi-tenant"
or not) would not work as expected
- make it apparent the script is in fact not fully LSB-compliant
- suppress some ShellCheck issues, mostly related to the fact that
some variables are injected based on "boothd status" invocation,
also drop an unused variable (see commits 8732542 + 054dafa
[until which it might have been useful] + 9e6359f)
- fix whitespace issues + normalize indentation of "case - esac"
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
---
script/lsb/booth-arbitrator | 64 ++++++++++++++++++++++---------------
1 file changed, 38 insertions(+), 26 deletions(-)
diff --git a/script/lsb/booth-arbitrator b/script/lsb/booth-arbitrator
index d90fe4b..3cdafc0 100755
--- a/script/lsb/booth-arbitrator
+++ b/script/lsb/booth-arbitrator
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# BOOTH daemon init script for LSB-compliant Linux distributions.
+# BOOTH daemon init script for SUSE Linux based distributions
+# (almost LSB-compliant, except for s/startproc/start_daemon/ etc.)
#
# booth-arbitrator BOOTH arbitrator daemon
#
@@ -40,12 +41,13 @@ check_status() {
rc=$BOOTH_ERROR_GENERIC
eval `"$exec" status "${cnf:+-c$cnf}" ; echo rc=$?`
- case $rc in
+ case $rc in
0)
- case "$booth_state" in
+ # shellcheck disable=SC2154
+ case "$booth_state" in
started) return $BOOTH_DAEMON_STARTED;;
starting) return $BOOTH_DAEMON_STARTING;;
- *) return $BOOTH_ERROR_GENERIC;;
+ *) return $BOOTH_ERROR_GENERIC;;
esac
;;
$OCF_NOT_RUNNING) return $BOOTH_DAEMON_NOT_RUNNING;;
@@ -57,6 +59,7 @@ check_status() {
status() {
echo -n "BOOTH daemon is "
if check_status; then
+ # shellcheck disable=SC2154
echo "running - PID $booth_lockpid for $booth_cfg_name, $booth_addr_string:$booth_port"
return 0
else
@@ -90,16 +93,15 @@ stop() {
wait_time=5
check_status; rc=$?
case $rc in
- $BOOTH_DAEMON_STARTED);;
- $BOOTH_DAEMON_STARTING);;
- $BOOTH_DAEMON_EXIST);;
+ $BOOTH_DAEMON_STARTED|$BOOTH_DAEMON_STARTING|$BOOTH_DAEMON_EXIST)
+ ;;
$BOOTH_DAEMON_NOT_RUNNING)
echo "BOOTH arbitrator daemon is not running."
return 0
- ;;
+ ;;
*) return 1;;
esac
-
+
echo -n $"Stopping BOOTH arbitrator daemon: "
# $exec stop "${cnf:+-c$cnf}"
# sleep 1
@@ -122,11 +124,10 @@ stop() {
}
foreach() {
- local cnf cnf_base
+ local cnf
local rc=0
for cnf in ${BOOTH_CONF_FILE:-$CONF_DIR/*.conf} ; do
- cnf_base=`basename $cnf`
"$@"
rc=$((rc|$?))
done
@@ -138,20 +139,31 @@ restart() {
start
}
+condrestart() {
+ local rc
+
+ check_status; rc=$?
+
+ case "$rc" in
+ $BOOTH_DAEMON_STARTED|$BOOTH_DAEMON_STARTING|$BOOTH_DAEMON_EXIST)
+ # shellcheck disable=SC2154
+ [ ! -f "$booth_lockfile" ] || restart
+ ;;
+ esac
+}
+
case "$1" in
- start|stop|restart)
- foreach $1
- ;;
- reload|force-reload)
- foreach restart
- ;;
- condrestart|try-restart)
- [ ! -f "$booth_lockfile" ] || restart
- ;;
- status)
- foreach status
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|status}"
- exit 2
+start|stop|restart|condrestart|status)
+ foreach $1
+ ;;
+reload|force-reload)
+ foreach restart
+ ;;
+try-restart)
+ foreach condrestart
+ ;;
+*)
+ echo $"Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|status}"
+ exit 2
+ ;;
esac
--
2.18.0.rc2