restart and monitor

This commit is contained in:
Daniel Gibbs 2024-06-16 21:31:30 +01:00
parent c0ba7219fd
commit 227647c0cc
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
3 changed files with 36 additions and 9 deletions

View File

@ -110,12 +110,28 @@ fn_monitor_check_stopping() {
}
fn_monitor_check_restart_request() {
if [ -f "${lockdir}/${selfname}-stop-request.lock" ]; then
if [ -f "${lockdir}/${selfname}-restart-request.lock" ]; then
fn_print_dots "Checking restart: "
fn_print_checking_eol
fn_print_info "Checking restart: Restart requested: "
fn_print_info_eol_nl
fn_script_log_info "Checking restart: Restart requested"
if [ "${stoponlyifnoplayers}" == "on" ]; then
if [ "${querymode}" == "2" ] || [ "${querymode}" == "3" ]; then
for queryip in "${queryips[@]}"; do
query_gamedig.sh
if [ "${querystatus}" == "0" ]; then
if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
fn_print_info_nl "${gdplayers} players are on the server: restart postponed"
fn_script_log_info "${gdplayers} players are on the server: restart postponed"
echo "${gdplayers}" > "${lockdir:?}/${selfname}-player-numbers.lock"
date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
core_exit.sh
fi
fi
done
fi
fi
command_restart.sh
core_exit.sh
fi

View File

@ -11,6 +11,22 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_firstcommand_set
info_game.sh
if [ "${stoponlyifnoplayers}" == "on" ]; then
if [ "${querymode}" == "2" ] || [ "${querymode}" == "3" ]; then
for queryip in "${queryips[@]}"; do
query_gamedig.sh
if [ "${querystatus}" == "0" ]; then
if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
fn_print_info_nl "${gdplayers} players are on the server: restart postponed"
fn_script_log_info "${gdplayers} players are on the server: restart postponed"
echo "${gdplayers}" > "${lockdir:?}/${selfname}-player-numbers.lock"
date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
core_exit.sh
fi
fi
done
fi
fi
exitbypass=1
command_stop.sh
command_start.sh

View File

@ -18,15 +18,10 @@ fn_stop_players_online() {
query_gamedig.sh
if [ "${querystatus}" == "0" ]; then
if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
fn_print_info_nl "Server will not stop while ${gdplayers} players are on the server"
fn_script_log_info "Server will not stop while ${gdplayers} players are on the server"
date '+%s' > "${lockdir:?}/${selfname}-stop-request.lock"
fn_print_info_nl "${gdplayers} players are on the server: stop prevented"
fn_script_log_info "${gdplayers} players are on the server: stop prevented"
echo "${gdplayers}" > "${lockdir:?}/${selfname}-player-numbers.lock"
core_exit.sh
else
if [ -f "${lockdir:?}/${selfname}-stop-request.lock" ]; then
rm -f "${lockdir:?}/${selfname}-stop-request.lock"
fi
break
fi
fi
done