mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-27 00:38:27 +00:00
Add --stopped and --online to wait command
This commit is contained in:
parent
784d9f3092
commit
d2719fb452
@ -404,14 +404,22 @@ instances.
|
|||||||
`remove-cronjob <command>`::
|
`remove-cronjob <command>`::
|
||||||
Removes a cron job previously installed by `install-cronjob`
|
Removes a cron job previously installed by `install-cronjob`
|
||||||
|
|
||||||
`wait {--any|--all}`::
|
`wait`::
|
||||||
Waits until any or all instances are stopped
|
Waits until any or all instances are stopped or online
|
||||||
|
Defaults to any stopped
|
||||||
|
|
||||||
`--any`;;
|
`--any`;;
|
||||||
Waits until any specified instance is stopped
|
Waits until any specified instance is in specified state
|
||||||
|
|
||||||
`--all`;;
|
`--all`;;
|
||||||
Waits until all specified instances are stopped
|
Waits until all specified instances are in specified state
|
||||||
|
|
||||||
|
`--stopped`;;
|
||||||
|
Waits until instances are stopped
|
||||||
|
|
||||||
|
`--online`;;
|
||||||
|
Waits until instances are online
|
||||||
|
|
||||||
|
|
||||||
Configuration files
|
Configuration files
|
||||||
-------------------
|
-------------------
|
||||||
|
|||||||
@ -3056,15 +3056,27 @@ printStatus(){
|
|||||||
doWait(){
|
doWait(){
|
||||||
local waitall=
|
local waitall=
|
||||||
local waitany=
|
local waitany=
|
||||||
|
local waitonline=
|
||||||
|
local waitstopped=
|
||||||
declare -A pidfiles
|
declare -A pidfiles
|
||||||
|
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--all) waitall=1; ;;
|
--all) waitall=1; ;;
|
||||||
--any) waitany=1; ;;
|
--any) waitany=1; ;;
|
||||||
|
--online) waitonline=1; ;;
|
||||||
|
--stopped) waitstopped=1; ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ -z "${waitany}" && -z "${waitall}" ]]; then
|
||||||
|
waitany=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${waitonline}" && -z "${waitstopped}" ]]; then
|
||||||
|
waitstopped=1
|
||||||
|
fi
|
||||||
|
|
||||||
for instance in "${instances[@]}"; do
|
for instance in "${instances[@]}"; do
|
||||||
pidfile="$(useConfig "$instance"; echo "${arkserverroot}/${arkmanagerpidfile}")"
|
pidfile="$(useConfig "$instance"; echo "${arkserverroot}/${arkmanagerpidfile}")"
|
||||||
pidfiles[$instance]="$pidfile"
|
pidfiles[$instance]="$pidfile"
|
||||||
@ -3077,18 +3089,31 @@ doWait(){
|
|||||||
while sleep 5; do
|
while sleep 5; do
|
||||||
anyrunning=0
|
anyrunning=0
|
||||||
allrunning=1
|
allrunning=1
|
||||||
|
anyonline=0
|
||||||
|
allonline=1
|
||||||
for instance in "${instances[@]}"; do
|
for instance in "${instances[@]}"; do
|
||||||
pidfile="${pidfiles[$instance]}"
|
pidfile="${pidfiles[$instance]}"
|
||||||
if [ -f "${pidfile}" ]; then
|
if [ -f "${pidfile}" ]; then
|
||||||
pid="$(<"${pidfile}")"
|
pid="$(<"${pidfile}")"
|
||||||
if kill -0 "${pid}"; then
|
if kill -0 "${pid}"; then
|
||||||
anyrunning=1
|
anyrunning=1
|
||||||
|
if [ -n "$waitonline" ]; then
|
||||||
|
if (useConfig "$instance"; isTheServerOnline); then
|
||||||
|
anyonline=1
|
||||||
|
else
|
||||||
|
allonline=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
allrunning=0
|
allrunning=0
|
||||||
|
allonline=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ ( "${waitall}" == 1 && "${anyrunning}" == 0 ) || ( "${waitany}" == 1 && "${allrunning}" == 0 ) ]]; then
|
if [[ ( "${waitstopped}" == 1 && "${waitall}" == 1 && "${anyrunning}" == 0 ) ||
|
||||||
|
( "${waitstopped}" == 1 && "${waitany}" == 1 && "${allrunning}" == 0 ) ||
|
||||||
|
( "${waitonline}" == 1 && "${waitall}" == 1 && "${allonline}" == 1 ) ||
|
||||||
|
( "${waitonline}" == 1 && "${waitany}" == 1 && "${anyonline}" == 1 ) ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user