Skip to content

Commit f43a846

Browse files
committed
refactor: improve monitor check update function
The `fn_monitor_check_update` function has been refactored to improve readability and efficiency. Specifically, a specific check for docker has been added to ignore the command "watch -n 1800 ./csgoserver update". Additionally, the logic for updating the `monitorps` variable has been simplified.
1 parent 6716839 commit f43a846

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lgsm/modules/command_monitor.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ fn_monitor_check_install() {
6969
}
7070

7171
fn_monitor_check_update() {
72+
# Specific check for docker. Will ignore the command watch -n 1800 ./csgoserver update
73+
monitorps=0
74+
if [ "$(pgrep -fc "n*${selfname} update")" != "0" ]; then
75+
monitorps="$((monitorps - 1))"
76+
fi
7277
# Monitor will check if an update is running.
7378
if [ "$(pgrep -fc "${selfname} update")" != "0" ] || [ "$(pgrep -fc "${selfname} u")" != "0" ] || [ "$(pgrep -fc "${selfname} validate")" != "0" ] || [ "$(pgrep -fc "${selfname} v")" != "0" ]; then
74-
# Specific check for docker. Will ignore the command watch -n 1800 ./csgoserver update
75-
if [ "$(pgrep -fc "n*${selfname} update")" == "0" ]; then
76-
fn_print_info_nl "Checking lockfile: LinuxGSM is currently checking for updates: "
79+
monitorps="$((monitorps + 2))"
80+
if [ "${monitorps}" != "0" ]; then
81+
fn_print_info_nl "Checking lockfile: LinuxGSM is currently updating: "
7782
fn_print_info_eol
78-
fn_script_log_pass "Checking lockfile: LinuxGSM is currently checking for updates"
83+
fn_script_log_pass "Checking lockfile: LinuxGSM is currently updating"
7984
core_exit.sh
8085
fi
8186
fi

0 commit comments

Comments
 (0)