Skip to content

Commit

Permalink
restart and monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Jun 16, 2024
1 parent c0ba721 commit 227647c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
18 changes: 17 additions & 1 deletion lgsm/modules/command_monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions lgsm/modules/command_restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions lgsm/modules/command_stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 227647c

Please sign in to comment.