mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-16 12:28:27 +00:00
Add option to allow players to cancel restart
This commit is contained in:
parent
c7053d8a93
commit
e1b2cdb8c8
@ -1040,6 +1040,28 @@ printWarnMessage(){
|
||||
doBroadcastWithEcho "$msg"
|
||||
}
|
||||
|
||||
#
|
||||
# Checks if a player has requested an update cancel in the last 5 minutes
|
||||
#
|
||||
isUpdateCancelRequested(){
|
||||
if [ -n "$chatCommandRestartCancel" ]; then
|
||||
local canceltime="$(
|
||||
find ~/ARK/server1/ShooterGame/Saved/Logs -name 'ServerGame.*.log' -mmin -5 -print0 |
|
||||
xargs -0 grep -F -e "${chatCommandRestartCancel}" |
|
||||
sed 's@^[[]\(....\)\.\(..\)\.\(..\)-\(..\)\.\(..\)\.\(..\):.*@\1-\2-\3 \4:\5:\6 UTC@' |
|
||||
head -n1)"
|
||||
if [ -n canceltime ]; then
|
||||
canceltime="$(date +%s --date="${canceltime}")"
|
||||
local timenow="$(date +%s --date="now - 5 minutes")"
|
||||
if (( canceltime > timenow )); then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Waits for a configurable number of minutes before updating the server
|
||||
#
|
||||
@ -1107,6 +1129,10 @@ doWarn(){
|
||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
||||
return 0
|
||||
fi
|
||||
if isUpdateCancelRequested; then
|
||||
doBroadcastWithEcho "Restart cancelled by player request"
|
||||
return 1
|
||||
fi
|
||||
wait $sleeppid
|
||||
if (( $min > $warninterval )); then
|
||||
sleep 1m &
|
||||
@ -1136,6 +1162,10 @@ doWarn(){
|
||||
rm -f "${arkserverroot}/.ark-warn.lock"
|
||||
return 0
|
||||
fi
|
||||
if isUpdateCancelRequested; then
|
||||
doBroadcastWithEcho "Restart cancelled by player request"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
wait $sleeppid
|
||||
warnseconds=$warninterval
|
||||
|
||||
@ -32,6 +32,10 @@ msgWarnRestartMinutes="This ARK server will shutdown for a restart in %d minutes
|
||||
msgWarnRestartSeconds="This ARK server will shutdown for a restart in %d seconds"
|
||||
msgWarnShutdownMinutes="This ARK server will shutdown in %d minutes"
|
||||
msgWarnShutdownSeconds="This ARK server will shutdown in %d seconds"
|
||||
msgWarnCancelled="Restart cancelled by player request"
|
||||
|
||||
# Restart cancel chat command
|
||||
#chatCommandRestartCancel="/cancelupdate"
|
||||
|
||||
# ARK server common options - use ark_<optionname>=<value>
|
||||
# comment out these values if you want to define them
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user