1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
#!/bin/bash
#
# BOOTH daemon init script for SUSE Linux based distributions
# (almost LSB-compliant, except for s/startproc/start_daemon/ etc.)
#
# booth-arbitrator BOOTH arbitrator daemon
#
# chkconfig: - 20 20
# processname: boothd
# pidfile: /var/run/booth.pid
# description: Cluster Ticket Registry
### BEGIN INIT INFO
# Provides: booth
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 6
# Short-Description: start and stop BOOTH arbitrator daemon
### END INIT INFO
prog="boothd"
exec="/usr/sbin/$prog"
CONF_DIR=/etc/booth
BOOTH_DAEMON_STARTED=0
BOOTH_DAEMON_STARTING=1
BOOTH_DAEMON_EXIST=2
BOOTH_DAEMON_NOT_RUNNING=3
BOOTH_ERROR_GENERIC=4
OCF_ERR_GENERIC=1
OCF_NOT_RUNNING=7
. /etc/rc.status
check_status() {
local rc
rc=$BOOTH_ERROR_GENERIC
eval `"$exec" status "${cnf:+-c$cnf}" ; echo rc=$?`
case $rc in
0)
# shellcheck disable=SC2154
case "$booth_state" in
started) return $BOOTH_DAEMON_STARTED;;
starting) return $BOOTH_DAEMON_STARTING;;
*) return $BOOTH_ERROR_GENERIC;;
esac
;;
$OCF_NOT_RUNNING) return $BOOTH_DAEMON_NOT_RUNNING;;
$OCF_ERR_GENERIC) return $BOOTH_ERROR_GENERIC;;
*) return $BOOTH_ERROR_GENERIC;;
esac
}
status() {
printf "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
echo "stopped"
return 3
fi
}
start() {
local rc
[ -x $exec ] || exit 5
check_status; rc=$?
case "$rc" in
$BOOTH_DAEMON_STARTED|$BOOTH_DAEMON_STARTING|$BOOTH_DAEMON_EXIST)
echo "BOOTH daemon is running - PID $booth_lockpid for $booth_cfg_name, $booth_addr_string:$booth_port"
return 0
;;
$BOOTH_ERROR_GENERIC|$BOOTH_DAEMON_NOT_RUNNING)
printf "Starting BOOTH arbitrator daemon: "
startproc $exec start "${cnf:+-c$cnf}"
rc_status -v
;;
*) return 1;;
esac
}
stop() {
local rc wait_time
wait_time=5
check_status; rc=$?
case $rc in
$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
printf "Stopping BOOTH arbitrator daemon: "
# $exec stop "${cnf:+-c$cnf}"
# sleep 1
pkill -TERM -s $booth_lockpid boothd
sleep 0.1
check_status; rc=$?
while [ $rc -ne $BOOTH_DAEMON_NOT_RUNNING -a $wait_time -gt 0 ]
do
wait_time=$((wait_time-1))
sleep 1
check_status; rc=$?
done
if [ $rc -ne $BOOTH_DAEMON_NOT_RUNNING ]; then
pkill -KILL -s $booth_lockpid boothd
sleep 1
check_status; rc=$?
fi
test $rc -eq $BOOTH_DAEMON_NOT_RUNNING
rc_status -v
}
foreach() {
local cnf
local rc=0
for cnf in ${BOOTH_CONF_FILE:-$CONF_DIR/*.conf} ; do
"$@"
rc=$((rc|$?))
done
return $rc
}
restart() {
stop
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|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
|