From 0e8e1a35db959581ec19124dff245a82b70ad81e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 28 Jul 2023 23:48:55 +0100 Subject: [PATCH] refactor: lockfile handling - Removed unnecessary function fn_start_jk2() - Removed unused variable startparameters in fn_start_tmux() - Added comments to clarify code functionality - Renamed lockfile from "${lockdir}/${selfname}.lock" to "${lockdir}/${selfname}-start.lock" - Updated log messages and log file names to include timestamp --- lgsm/modules/command_debug.sh | 10 +- lgsm/modules/command_monitor.sh | 113 +++++++++++++++-------- lgsm/modules/command_start.sh | 58 +++--------- lgsm/modules/command_stop.sh | 4 +- lgsm/modules/command_update.sh | 3 + lgsm/modules/command_validate.sh | 3 + lgsm/modules/core_steamcmd.sh | 3 + lgsm/modules/fix_ts3.sh | 13 +++ lgsm/modules/update_factorio.sh | 3 + lgsm/modules/update_jediknight2.sh | 4 + lgsm/modules/update_minecraft.sh | 3 + lgsm/modules/update_minecraft_bedrock.sh | 3 + lgsm/modules/update_mta.sh | 3 + lgsm/modules/update_papermc.sh | 3 + lgsm/modules/update_ts3.sh | 3 + lgsm/modules/update_ut99.sh | 3 + lgsm/modules/update_vintagestory.sh | 3 + linuxgsm.sh | 2 +- 18 files changed, 146 insertions(+), 91 deletions(-) diff --git a/lgsm/modules/command_debug.sh b/lgsm/modules/command_debug.sh index 52efd04db..fb3b9c99e 100644 --- a/lgsm/modules/command_debug.sh +++ b/lgsm/modules/command_debug.sh @@ -13,7 +13,7 @@ fn_firstcommand_set # Trap to remove lockfile on quit. fn_lockfile_trap() { # Remove lockfile. - rm -f "${lockdir:?}/${selfname}.lock" + rm -f "${lockdir:?}/${selfname}-start.lock" # resets terminal. Servers can sometimes mess up the terminal on exit. reset fn_print_dots "Stopping debug" @@ -99,11 +99,11 @@ fn_script_log_info "Starting debug" fn_print_ok_nl "Starting debug" # Create lockfile. -date '+%s' > "${lockdir}/${selfname}.lock" -echo "${version}" >> "${lockdir}/${selfname}.lock" -echo "${port}" >> "${lockdir}/${selfname}.lock" +date '+%s' > "${lockdir}/${selfname}-start.lock" +echo "${version}" >> "${lockdir}/${selfname}-start.lock" +echo "${port}" >> "${lockdir}/${selfname}-start.lock" fn_script_log_info "Lockfile generated" -fn_script_log_info "${lockdir}/${selfname}.lock" +fn_script_log_info "${lockdir}/${selfname}-start.lock" if [ "${shortname}" == "av" ]; then cd "${systemdir}" || exit diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index 5edd7298e..733689de3 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -13,13 +13,10 @@ fn_firstcommand_set fn_monitor_check_lockfile() { # Monitor does not run if lockfile is not found. - if [ ! -f "${lockdir}/${selfname}.lock" ]; then + if [ ! -f "${lockdir}/${selfname}-start.lock" ]; then fn_print_dots "Checking lockfile: " fn_print_checking_eol fn_script_log_info "Checking lockfile: CHECKING" - fn_monitor_check_update - fn_monitor_check_backup - fn_monitor_check_debug fn_print_error "Checking lockfile: No lockfile found: " fn_print_error_eol_nl fn_script_log_error "Checking lockfile: No lockfile found: ERROR" @@ -28,62 +25,92 @@ fn_monitor_check_lockfile() { fi # Fix if lockfile is not unix time or contains letters - if [ -f "${lockdir}/${selfname}.lock" ] && [[ "$(head -n 1 "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then - date '+%s' > "${lockdir}/${selfname}.lock" - echo "${version}" >> "${lockdir}/${selfname}.lock" - echo "${port}" >> "${lockdir}/${selfname}.lock" + if [ -f "${lockdir}/${selfname}-start.lock" ] && [[ "$(head -n 1 "${lockdir}/${selfname}-start.lock")" =~ [A-Za-z] ]]; then + date '+%s' > "${lockdir}/${selfname}-start.lock" + echo "${version}" >> "${lockdir}/${selfname}-start.lock" + echo "${port}" >> "${lockdir}/${selfname}-start.lock" fi } -fn_monitor_check_backup() { - # Monitor will check if backup is running. - if [ "$(pgrep "${selfname} backup" | wc -l)" != "0" ] || [ "$(pgrep "${selfname} b" | wc -l)" != "0" ]; then - fn_print_info "Checking lockfile: LinuxGSM is currently running a backup: " +fn_monitor_check_install() { + # Monitor will check if update is running. + if [ "$(pgrep -fc -u "${USER}" "${selfname} install")" != "0" ] || [ "$(pgrep -fc -u "${USER}" "${selfname} i")" != "0" ] || [ "$(pgrep -fc -u "${USER}" "${selfname} auto-install")" != "0" ] || [ "$(pgrep -fc -u "${USER}" "${selfname} ai")" != "0" ]; then + fn_print_dots "Checking for installer: " + fn_print_checking_eol + fn_script_log_info "Checking for installer: CHECKING" + fn_print_info "Checking for installer: LinuxGSM is currently installing: " fn_print_info_eol - fn_script_log_info "Checking lockfile: LinuxGSM is currently running a backup" + fn_script_log_pass "Checking for installer: LinuxGSM is currently installing" core_exit.sh fi } fn_monitor_check_debug() { - # Monitor will check if backup is running. - if [ "$(pgrep -fc "${selfname} backup")" != "0" ] || [ "$(pgrep -fc "${selfname} b")" != "0" ]; then - fn_print_info "Checking lockfile: LinuxGSM is currently in debug mode: " + # Monitor will check if debug is running. + if [ "$(pgrep -fc -u "${USER}" "${selfname} debug")" != "0" ] || [ "$(pgrep -fc -u "${USER}" "${selfname} d")" != "0" ]; then + fn_print_info "Checking debug: LinuxGSM is currently in debug mode: " fn_print_info_eol - fn_script_log_pass "Checking lockfile: LinuxGSM is currently in debug mode" + fn_script_log_pass "Checking debug: LinuxGSM is currently in debug mode" core_exit.sh fi } -fn_monitor_check_install() { - # Monitor will check if update is running. - if [ "$(pgrep -fc "${selfname} install")" != "0" ] || [ "$(pgrep -fc "${selfname} i")" != "0" ] || [ "$(pgrep -fc "${selfname} auto-install")" != "0" ] || [ "$(pgrep -fc "${selfname} ai")" != "0" ]; then - fn_print_dots "Checking for installer: " - fn_print_checking_eol - fn_script_log_info "Checking for installer: CHECKING" - fn_print_info "Checking for installer: LinuxGSM is currently installing: " +fn_monitor_check_backup() { + # Remove stale lockfile. + if [ -f "${lockdir}/backup.lock" ]; then + if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then + fn_print_warn "Checking backup: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Checking backup: Removing stale lockfile" + rm -f "${lockdir}/backup.lock" + fi + fi + + # Monitor will check if backup is running. + if [ -f "${lockdir}/backup.lock" ]; then + fn_print_info "Checking backup: LinuxGSM is currently running a backup: " fn_print_info_eol - fn_script_log_pass "Checking for installer: LinuxGSM is currently installing" + fn_script_log_info "Checking backup: LinuxGSM is currently running a backup" core_exit.sh fi } +# This includes all update related commands. fn_monitor_check_update() { - # Specific check for docker. Will ignore the command watch -n 1800 ./csgoserver update - monitorps=0 - if [ "$(pgrep -fc "n*${selfname} update")" != "0" ]; then - monitorps="$((monitorps - 1))" - fi - # Monitor will check if an update is running. - if [ "$(pgrep -fc "${selfname} update")" != "0" ] || [ "$(pgrep -fc "${selfname} u")" != "0" ] || [ "$(pgrep -fc "${selfname} validate")" != "0" ] || [ "$(pgrep -fc "${selfname} v")" != "0" ]; then - monitorps="$((monitorps + 2))" - if [ "${monitorps}" != "0" ]; then - fn_print_info_nl "Checking lockfile: LinuxGSM is currently updating: " - fn_print_info_eol - fn_script_log_pass "Checking lockfile: LinuxGSM is currently updating" - core_exit.sh + # Remove stale lockfile. + if [ -f "${lockdir}/${selfname}-update.lock" ]; then + if [ "$(find "${lockdir}/${selfname}-update.lock" -mmin +15)" ]; then + fn_print_warn "Checking update: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Checking update: Removing stale lockfile" + rm -f "${lockdir}/${selfname}-update.lock" fi fi + + if [ -f "${lockdir}/${selfname}-update.lock" ]; then + fn_print_info_nl "Checking update: LinuxGSM is currently updating: " + fn_print_info_eol + fn_script_log_pass "Checking update: LinuxGSM is currently updating" + core_exit.sh + fi +} + +fn_monitor_check_update_source(){ + if [ -f "${consolelogdir}/${selfname}-console.log" ] && [ "${engine}" == "source" ]; then + if grep -q "Your server needs to be restarted in order to receive the latest update." "${consolelogdir}/${selfname}-console.log"; then + fn_print_dots "Checking update: " + fn_print_checking_eol + fn_script_log_info "Checking update: CHECKING" + fn_print_ok "Checking update: " + fn_print_ok_eol_nl + fn_script_log_pass "Checking update: Monitor is restarting ${selfname} to apply update" + alert="restart" + alert.sh + fn_script_log_info "Checking update: Monitor is restarting ${selfname} to apply update" + command_restart.sh + core_exit.sh + fi + fi } fn_monitor_check_session() { @@ -147,12 +174,12 @@ fn_monitor_query() { fn_print_querying_eol fn_script_log_info "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : QUERYING" # querydelay - if [ "$(head -n 1 "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then + if [ "$(head -n 1 "${lockdir}/${selfname}-start.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: " fn_print_delay_eol_nl fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY" fn_script_log_info "Query bypassed: ${gameservername} started less than ${querydelay} minutes ago" - fn_script_log_info "Server started: $(date -d @$(head -n 1 "${lockdir}/${selfname}.lock"))" + fn_script_log_info "Server started: $(date -d @$(head -n 1 "${lockdir}/${selfname}-start.lock"))" fn_script_log_info "Current time: $(date)" monitorpass=1 core_exit.sh @@ -271,8 +298,14 @@ core_logs.sh info_game.sh # query pre-checks +fn_monitor_check_update_source +fn_monitor_check_update +fn_monitor_check_backup +fn_monitor_check_debug fn_monitor_check_lockfile + fn_monitor_check_session + # Monitor will not continue if session only check. if [ "${querymode}" != "1" ]; then fn_monitor_check_queryport diff --git a/lgsm/modules/command_start.sh b/lgsm/modules/command_start.sh index 9b0c2f213..6cb0ee8eb 100644 --- a/lgsm/modules/command_start.sh +++ b/lgsm/modules/command_start.sh @@ -11,28 +11,6 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" addtimestamp="gawk '{ print strftime(\\\"[$logtimestampformat]\\\"), \\\$0 }'" fn_firstcommand_set -fn_start_teamspeak3() { - if [ ! -f "${servercfgfullpath}" ]; then - fn_print_warn_nl "${servercfgfullpath} is missing" - fn_script_log_warn "${servercfgfullpath} is missing" - echo " * Creating blank ${servercfg}" - fn_script_log_info "Creating blank ${servercfg}" - fn_sleep_time - echo " * ${servercfg} can remain blank by default." - fn_script_log_info "${servercfgfullpath} can remain blank by default." - fn_sleep_time - echo " * ${servercfg} is located in ${servercfgfullpath}." - fn_script_log_info "${servercfg} is located in ${servercfgfullpath}." - sleep 5 - touch "${servercfgfullpath}" - fi - # Accept license. - if [ ! -f "${executabledir}/.ts3server_license_accepted" ]; then - install_eula.sh - fi - fn_start_tmux -} - # This will allow the Jedi Knight 2 version to be printed in console on start. # Used to allow update to detect JK2MV server version. fn_start_jk2() { @@ -41,9 +19,6 @@ fn_start_jk2() { } fn_start_tmux() { - if [ "${parmsbypass}" ]; then - startparameters="" - fi # check for tmux size variables. if [[ "${servercfgtmuxwidth}" =~ ^[0-9]+$ ]]; then sessionwidth="${servercfgtmuxwidth}" @@ -68,14 +43,15 @@ fn_start_tmux() { mv "${consolelog}" "${consolelogdate}" fi - # Create lockfile - date '+%s' > "${lockdir}/${selfname}.lock" - echo "${version}" >> "${lockdir}/${selfname}.lock" - echo "${port}" >> "${lockdir}/${selfname}.lock" + # Create start lockfile that exists only when the server is running. + date '+%s' > "${lockdir}/${selfname}-start.lock" + echo "${version}" >> "${lockdir}/${selfname}-start.lock" + echo "${port}" >> "${lockdir}/${selfname}-start.lock" fn_reload_startparameters - # create uid to ensure unique tmux socket + # Create uid to ensure unique tmux socket name. if [ ! -f "${datadir}/${selfname}.uid" ]; then + # stop running server (if running) to prevent lingering tmux sessions. command_stop.sh uid=$(date '+%s' | sha1sum | head -c 8) echo "${uid}" > "${datadir}/${selfname}.uid" @@ -101,7 +77,7 @@ fn_start_tmux() { fn_script_log "tmux version: master (user compiled)" echo -e "tmux version: master (user compiled)" >> "${consolelog}" if [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then - if [ "$logtimestamp" == "on" ]; then + if [ "${logtimestamp}" == "on" ]; then tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" else tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" @@ -122,7 +98,7 @@ fn_start_tmux() { Currently installed: $(tmux -V)" > "${consolelog}" # Console logging enable or not set. elif [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then - if [ "$logtimestamp" == "on" ]; then + if [ "${logtimestamp}" == "on" ]; then tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" else tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" @@ -135,7 +111,7 @@ fn_start_tmux() { # Console logging disabled. if [ "${consolelogging}" == "off" ]; then - echo -e "Console logging disabled by user" >> "${consolelog}" + echo -e "Console logging disabled in settings" >> "${consolelog}" fn_script_log_info "Console logging disabled by user" fi fn_sleep_time @@ -195,8 +171,8 @@ fn_start_tmux() { check.sh -# Is the server already started. -# $status comes from check_status.sh, which is run by check.sh for this command +# If the server already started dont start again. +# $status comes from check_status.sh, which is run by check.sh for the command. if [ "${status}" != "0" ]; then fn_print_dots "${servername}" fn_print_info_nl "${servername} is already running" @@ -205,13 +181,12 @@ if [ "${status}" != "0" ]; then core_exit.sh fi fi -if [ -z "${fixbypass}" ]; then - fix.sh -fi + +fix.sh info_game.sh core_logs.sh -# Will check for updates is updateonstart is yes. +# Will check for updates if updateonstart is yes. if [ "${updateonstart}" == "yes" ] || [ "${updateonstart}" == "1" ] || [ "${updateonstart}" == "on" ]; then exitbypass=1 unset updateonstart @@ -220,10 +195,7 @@ if [ "${updateonstart}" == "yes" ] || [ "${updateonstart}" == "1" ] || [ "${upda fi fn_print_dots "${servername}" - -if [ "${shortname}" == "ts3" ]; then - fn_start_teamspeak3 -elif [ "${shortname}" == "jk2" ]; then +if [ "${shortname}" == "jk2" ]; then fn_start_jk2 else fn_start_tmux diff --git a/lgsm/modules/command_stop.sh b/lgsm/modules/command_stop.sh index e19b87f6e..a6910902f 100644 --- a/lgsm/modules/command_stop.sh +++ b/lgsm/modules/command_stop.sh @@ -274,8 +274,8 @@ fn_print_dots "${servername}" info_game.sh fn_stop_pre_check # Remove lockfile. -if [ -f "${lockdir}/${selfname}.lock" ]; then - rm -f "${lockdir:?}/${selfname}.lock" +if [ -f "${lockdir}/${selfname}-start.lock" ]; then + rm -f "${lockdir:?}/${selfname}-start.lock" fi if [ -z "${exitbypass}" ]; then diff --git a/lgsm/modules/command_update.sh b/lgsm/modules/command_update.sh index 5993609c0..1285b8dce 100644 --- a/lgsm/modules/command_update.sh +++ b/lgsm/modules/command_update.sh @@ -37,4 +37,7 @@ else update_steamcmd.sh fi +# remove update lockfile +rm -f "${lockdir}/${selfname}-update.lock" + core_exit.sh diff --git a/lgsm/modules/command_validate.sh b/lgsm/modules/command_validate.sh index 23ee92a26..9705e4d14 100644 --- a/lgsm/modules/command_validate.sh +++ b/lgsm/modules/command_validate.sh @@ -46,4 +46,7 @@ else fn_validate fi +# remove update lockfile +rm -f "${lockdir}/${selfname}-update.lock" + core_exit.sh diff --git a/lgsm/modules/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index 02074620d..99aad8695 100644 --- a/lgsm/modules/core_steamcmd.sh +++ b/lgsm/modules/core_steamcmd.sh @@ -204,7 +204,10 @@ fn_update_steamcmd_remotebuild() { fn_update_steamcmd_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/fix_ts3.sh b/lgsm/modules/fix_ts3.sh index 9eb728f48..3d0a6760f 100644 --- a/lgsm/modules/fix_ts3.sh +++ b/lgsm/modules/fix_ts3.sh @@ -7,6 +7,19 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +# Creates a blank ts3server.ini if it does not exist. +if [ ! -f "${servercfgfullpath}" ]; then + fixname="create blank ${servercfg}" + fn_fix_msg_start + touch "${servercfgfullpath}" + fn_fix_msg_end +fi + +# Accept license. +if [ ! -f "${executabledir}/.ts3server_license_accepted" ]; then + install_eula.sh +fi + # Fixes: makes libmariadb2 available #1924. if [ ! -f "${serverfiles}/libmariadb.so.2" ]; then fixname="libmariadb.so.2" diff --git a/lgsm/modules/update_factorio.sh b/lgsm/modules/update_factorio.sh index 2af9916aa..458888519 100644 --- a/lgsm/modules/update_factorio.sh +++ b/lgsm/modules/update_factorio.sh @@ -64,7 +64,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_jediknight2.sh b/lgsm/modules/update_jediknight2.sh index d455a2722..7fa4b4bd7 100644 --- a/lgsm/modules/update_jediknight2.sh +++ b/lgsm/modules/update_jediknight2.sh @@ -61,7 +61,11 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" + rm -f "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_minecraft.sh b/lgsm/modules/update_minecraft.sh index e764e846e..429791818 100644 --- a/lgsm/modules/update_minecraft.sh +++ b/lgsm/modules/update_minecraft.sh @@ -75,7 +75,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_minecraft_bedrock.sh b/lgsm/modules/update_minecraft_bedrock.sh index 3c3885a9d..f79b28496 100644 --- a/lgsm/modules/update_minecraft_bedrock.sh +++ b/lgsm/modules/update_minecraft_bedrock.sh @@ -80,7 +80,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_mta.sh b/lgsm/modules/update_mta.sh index 16b8278c7..c7e821083 100644 --- a/lgsm/modules/update_mta.sh +++ b/lgsm/modules/update_mta.sh @@ -59,7 +59,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" if [ "${forceupdate}" == "1" ]; then # forceupdate bypasses checks, useful for small build changes mtaupdatestatus="forced" diff --git a/lgsm/modules/update_papermc.sh b/lgsm/modules/update_papermc.sh index b70a2d69d..7a23d6001 100644 --- a/lgsm/modules/update_papermc.sh +++ b/lgsm/modules/update_papermc.sh @@ -85,7 +85,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_ts3.sh b/lgsm/modules/update_ts3.sh index 30dc9e513..3110e8e8f 100644 --- a/lgsm/modules/update_ts3.sh +++ b/lgsm/modules/update_ts3.sh @@ -68,7 +68,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_ut99.sh b/lgsm/modules/update_ut99.sh index 909286196..dce5db92b 100644 --- a/lgsm/modules/update_ut99.sh +++ b/lgsm/modules/update_ut99.sh @@ -62,7 +62,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/lgsm/modules/update_vintagestory.sh b/lgsm/modules/update_vintagestory.sh index 8fbc49044..ef0f87cc8 100644 --- a/lgsm/modules/update_vintagestory.sh +++ b/lgsm/modules/update_vintagestory.sh @@ -69,7 +69,10 @@ fn_update_remotebuild() { fn_update_compare() { fn_print_dots "Checking for update: ${remotelocation}" + # Update has been found or force update. if [ "${localbuild}" != "${remotebuildversion}" ] || [ "${forceupdate}" == "1" ]; then + # Create update lockfile. + date '+%s' > "${lockdir}/${selfname}-update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" diff --git a/linuxgsm.sh b/linuxgsm.sh index 3c71d288f..331a61822 100755 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -26,7 +26,6 @@ gameservername="core" commandname="CORE" rootdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") selfname=$(basename "$(readlink -f "${BASH_SOURCE[0]}")") -sessionname=$(echo "${selfname}" | cut -f1 -d".") lgsmdir="${rootdir}/lgsm" [ -n "${LGSM_LOGDIR}" ] && logdir="${LGSM_LOGDIR}" || logdir="${rootdir}/log" lgsmlogdir="${logdir}/lgsm" @@ -36,6 +35,7 @@ modulesdir="${lgsmdir}/modules" tmpdir="${lgsmdir}/tmp" datadir="${lgsmdir}/data" lockdir="${lgsmdir}/lock" +sessionname="${selfname}" [ -f "${datadir}/${selfname}.uid" ] && socketname="${sessionname}-$(cat "${datadir}/${selfname}.uid")" || socketname="${sessionname}" serverlist="${datadir}/serverlist.csv" serverlistmenu="${datadir}/serverlistmenu.csv"