diff --git a/lgsm/modules/check_last_update.sh b/lgsm/modules/check_last_update.sh index d4f2d8f89..02d17c975 100644 --- a/lgsm/modules/check_last_update.sh +++ b/lgsm/modules/check_last_update.sh @@ -3,21 +3,21 @@ # Author: Daniel Gibbs # Contributors: http://linuxgsm.com/contrib # Website: https://linuxgsm.com -# Description: Checks lock file to see when last update happened. +# Description: Checks Lockfile to see when last update happened. # Will reboot server if instance not rebooted since update. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -if [ -f "${lockdir}/${selfname}-laststart.lock" ]; then - laststart=$(cat "${lockdir}/${selfname}-laststart.lock") +if [ -f "${lockdir}/${selfname}-last-started.lock" ]; then + laststart=$(cat "${lockdir}/${selfname}-last-started.lock") fi -if [ -f "${lockdir}/lastupdate.lock" ]; then - lastupdate=$(cat "${lockdir}/lastupdate.lock") +if [ -f "${lockdir}/last-updated.lock" ]; then + lastupdate=$(cat "${lockdir}/last-updated.lock") fi check_status.sh -if [ -f "${lockdir}/lastupdate.lock" ] && [ "${status}" != "0" ]; then - if [ ! -f "${lockdir}/${selfname}-laststart.lock" ] || [ "${laststart}" -lt "${lastupdate}" ]; then +if [ -f "${lockdir}/last-updated.lock" ] && [ "${status}" != "0" ]; then + if [ ! -f "${lockdir}/${selfname}-last-started.lock" ] || [ "${laststart}" -lt "${lastupdate}" ]; then fn_print_info "${selfname} has not been restarted since last update" fn_script_log_info "${selfname} has not been restarted since last update" command_restart.sh diff --git a/lgsm/modules/check_status.sh b/lgsm/modules/check_status.sh index 6edd4151b..906675e81 100644 --- a/lgsm/modules/check_status.sh +++ b/lgsm/modules/check_status.sh @@ -7,4 +7,4 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" -status=$(tmux -L "${sessionname}" list-sessions -F "#{session_name}" 2> /dev/null | grep -Ecx "^${sessionname}") +status=$(tmux -L "${socketname}" list-sessions -F "#{session_name}" 2> /dev/null | grep -Ecx "^${sessionname}") diff --git a/lgsm/modules/command_backup.sh b/lgsm/modules/command_backup.sh index 1973eb95f..b63c82625 100644 --- a/lgsm/modules/command_backup.sh +++ b/lgsm/modules/command_backup.sh @@ -22,7 +22,7 @@ fn_backup_trap() { echo -en "backup ${backupname}.tar.gz..." fn_print_removed_eol_nl fn_script_log_info "Backup ${backupname}.tar.gz: REMOVED" - # Remove lock file. + # Remove backup lockfile. rm -f "${lockdir:?}/backup.lock" fn_backup_start_server unset exitbypass @@ -31,9 +31,21 @@ fn_backup_trap() { # Check if a backup is pending or has been aborted using backup.lock. fn_backup_check_lockfile() { + # Remove stale lockfile. if [ -f "${lockdir}/backup.lock" ]; then - fn_print_info_nl "Lock file found: Backup is currently running" - fn_script_log_error "Lock file found: Backup is currently running: ${lockdir}/backup.lock" + if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then + fn_print_dots "Lockfile found: " + fn_print_checking_eol + fn_print_warn "Lockfile found: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Lockfile found: Removing stale lockfile" + rm -f "${lockdir:?}/backup.lock" + fi + fi + + if [ -f "${lockdir}/backup.lock" ]; then + fn_print_info_nl "Lockfile found: Backup is currently running" + fn_script_log_error "Lockfile found: Backup is currently running: ${lockdir}/backup.lock" core_exit.sh fi } @@ -117,8 +129,8 @@ fn_backup_migrate_olddir() { fn_backup_create_lockfile() { # Create lockfile. - date '+%s' > "${lockdir}/backup.lock" - fn_script_log_info "Lockfile generated" + date '+%s' > "${lockdir:?}/backup.lock" + fn_script_log_info "Backup lockfile generated" fn_script_log_info "${lockdir}/backup.lock" # trap to remove lockfile on quit. trap fn_backup_trap INT @@ -140,7 +152,7 @@ fn_backup_compression() { core_exit.sh fi - tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}/backup.lock" ./. + tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}" --exclude "${lockdir}" ./. local exitcode=$? if [ "${exitcode}" != 0 ]; then fn_print_fail_eol @@ -153,8 +165,6 @@ fn_backup_compression() { fn_print_ok_nl "Completed: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fn_script_log_pass "Backup created: ${backupname}.tar.gz, total size $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}')" fi - # Remove lock file - rm -f "${lockdir:?}/backup.lock" } # Clear old backups according to maxbackups and maxbackupdays variables. @@ -265,4 +275,6 @@ fn_backup_compression fn_backup_prune fn_backup_start_server +# Remove backup lockfile. +rm -f "${lockdir:?}/backup.lock" core_exit.sh diff --git a/lgsm/modules/command_console.sh b/lgsm/modules/command_console.sh index 95945dbe3..a5d49d7f2 100644 --- a/lgsm/modules/command_console.sh +++ b/lgsm/modules/command_console.sh @@ -42,7 +42,7 @@ check_status.sh if [ "${status}" != "0" ]; then fn_print_ok_nl "Accessing console" fn_script_log_pass "Console accessed" - tmux -L "${sessionname}" attach-session -t "${sessionname}" + tmux -L "${socketname}" attach-session -t "${sessionname}" fn_print_ok_nl "Closing console" fn_script_log_pass "Console closed" else diff --git a/lgsm/modules/command_debug.sh b/lgsm/modules/command_debug.sh index 52efd04db..c544e3e2a 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}-started.lock" # resets terminal. Servers can sometimes mess up the terminal on exit. reset fn_print_dots "Stopping debug" @@ -98,12 +98,12 @@ fn_print_dots "Starting debug" 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" +# Create started lockfile. +date '+%s' > "${lockdir:?}/${selfname}-started.lock" +echo "${version}" >> "${lockdir}/${selfname}-started.lock" +echo "${port}" >> "${lockdir}/${selfname}-started.lock" fn_script_log_info "Lockfile generated" -fn_script_log_info "${lockdir}/${selfname}.lock" +fn_script_log_info "${lockdir}/${selfname}-started.lock" if [ "${shortname}" == "av" ]; then cd "${systemdir}" || exit diff --git a/lgsm/modules/command_mods_remove.sh b/lgsm/modules/command_mods_remove.sh index 08095c8e8..8f9ea3739 100644 --- a/lgsm/modules/command_mods_remove.sh +++ b/lgsm/modules/command_mods_remove.sh @@ -131,7 +131,7 @@ fi if [ "${engine}" == "unity3d" ] && [[ "${modprettyname}" == *"Oxide"* ]]; then fn_print_information_nl "Validating to restore original ${gamename} files replaced by Oxide" fn_script_log "Validating to restore original ${gamename} files replaced by Oxide" - exitbypass="1" + exitbypass=1 command_validate.sh fn_firstcommand_reset unset exitbypass diff --git a/lgsm/modules/command_monitor.sh b/lgsm/modules/command_monitor.sh index 5edd7298e..c64df9fda 100644 --- a/lgsm/modules/command_monitor.sh +++ b/lgsm/modules/command_monitor.sh @@ -11,87 +11,181 @@ commandaction="Monitoring" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set -fn_monitor_check_lockfile() { +fn_monitor_check_monitoring() { # Monitor does not run if lockfile is not found. - if [ ! -f "${lockdir}/${selfname}.lock" ]; then + if [ ! -f "${lockdir}/${selfname}-monitoring.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" echo -e "* Start ${selfname} to run monitor." core_exit.sh 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" +fn_monitor_check_install() { + 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 installer: " + fn_print_checking_eol + fn_script_log_info "Checking installer: CHECKING" + fn_print_info "Checking installer: Installer is : " + fn_print_info_eol + fn_script_log_pass "Checking installer: LinuxGSM is installing" + core_exit.sh 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_debug() { + if [ "$(pgrep -fc -u "${USER}" "${selfname} debug")" != "0" ] || [ "$(pgrep -fc -u "${USER}" "${selfname} d")" != "0" ]; then + fn_print_dots "Checking debug: " + fn_print_checking_eol + fn_print_info "Checking debug: Debug is running: " fn_print_info_eol - fn_script_log_info "Checking lockfile: LinuxGSM is currently running a backup" + fn_script_log_pass "Checking debug: Debug is running" 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: " +fn_monitor_check_starting(){ + # Remove stale lockfile. + if [ -f "${lockdir}/${selfname}-starting.lock" ]; then + if [ "$(find "${lockdir}/${selfname}-starting.lock" -mmin +5)" ]; then + fn_print_dots "Checking start: " + fn_print_checking_eol + fn_print_warn "Checking start: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Checking start: Removing stale lockfile" + rm -f "${lockdir:?}/${selfname}-starting.lock" + fi + fi + + if [ -f "${lockdir}/${selfname}-starting.lock" ] && [[ "$(pgrep -fc -u "${USER}" "${selfname} start")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} s")" != "0" ]]; then + fn_print_dots "Checking start: " + fn_print_checking_eol + fn_print_info "Checking start: LinuxGSM is starting: " fn_print_info_eol - fn_script_log_pass "Checking lockfile: LinuxGSM is currently in debug mode" + fn_script_log_info "Checking backup: LinuxGSM is starting" 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_monitor_check_stopping(){ + # Remove stale lockfile. + if [ -f "${lockdir}/${selfname}-stopping.lock" ]; then + if [ "$(find "${lockdir}/${selfname}-stopping.lock" -mmin +5)" ]; then + fn_print_dots "Checking stop: " + fn_print_checking_eol + fn_print_warn "Checking stop: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Checking stop: Removing stale lockfile" + rm -f "${lockdir:?}/${selfname}-stopping.lock" + fi + fi + + if [ -f "${lockdir}/${selfname}-stopping.lock" ] && [[ "$(pgrep -fc -u "${USER}" "${selfname} stop")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} s")" != "0" ]]; then + fn_print_dots "Checking stop: " 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 "Checking stop: LinuxGSM is stopping: " fn_print_info_eol - fn_script_log_pass "Checking for installer: LinuxGSM is currently installing" + fn_script_log_info "Checking backup: LinuxGSM is stopping" core_exit.sh fi } -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))" +fn_monitor_check_backup() { + # Remove stale lockfile. + if [ -f "${lockdir}/backup.lock" ]; then + if [ "$(find "${lockdir}/backup.lock" -mmin +60)" ]; then + fn_print_dots "Checking backup: " + fn_print_checking_eol + 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 + + if [ -f "${lockdir}/backup.lock" ] && [[ "$(pgrep -fc -u "${USER}" "${selfname} backup")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} b")" != "0" ]]; then + fn_print_dots "Checking backup: " + fn_print_checking_eol + fn_print_info "Checking backup: Backup is running: " + fn_print_info_eol + fn_script_log_info "Checking backup: Backup is running" + core_exit.sh 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 +} + +fn_monitor_check_update() { + # Remove stale lockfile. + if [ -f "${lockdir}/update.lock" ]; then + if [ "$(find "${lockdir}/update.lock" -mmin +15)" ]; then + fn_print_dots "Checking update: " + fn_print_checking_eol + fn_print_warn "Checking update: Removing stale lockfile: " + fn_print_warn_eol + fn_script_log_warn "Checking update: Removing stale lockfile" + rm -f "${lockdir:?}/update.lock" fi fi + + if [ -f "${lockdir}/update.lock" ] && [[ "$(pgrep -fc -u "${USER}" "${selfname} update")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} validate")" != "0" || "$(pgrep -fc -u "${USER}" "${selfname} v")" != "0" || "$(pgrep -fc force-update "${USER}" "${selfname} fu")" != "0" ]]; then + fn_print_dots "Checking update: " + fn_print_checking_eol + fn_print_info "Checking update: LinuxGSM is updating the game server: " + fn_print_info_eol + fn_script_log_pass "Checking update: LinuxGSM is updating the game server" + core_exit.sh + fi +} + +# Source engine games may display a messages to indicate the server needs restarting. +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_info "Checking update: Monitor is restarting ${selfname} to apply update" + alert="restart" + alert.sh + command_restart.sh + core_exit.sh + fi + fi } fn_monitor_check_session() { fn_print_dots "Checking session: " fn_print_checking_eol fn_script_log_info "Checking session: CHECKING" - # uses status var from check_status.sh - if [ "${status}" != "0" ]; then + # Tmux session width and height needs to be reviewed as may no longer be required. + sessionwidth="80" + sessionheight="23" + # Check for PIDS with identical tmux sessions running. + if [ "$(pgrep -fc "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" -ge "2" ]; then + fn_print_error "Checking session: " + fn_print_error_eol_nl + fn_script_log_error "Checking session: ERROR" + fn_script_log_error "Checking session: There are PIDS with identical tmux sessions running" + fn_script_log_error "Checking session: Killing all tmux sessions with the socketname name ${socketname} and session name ${sessionname}" + pkill -f "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}" + command_restart.sh + core_exit.sh + # Check for tmux pids with the same tmux session and socket names. This will reduce issues with migration to release v23.5.0. #4296 + elif [ "$(pgrep -fc -u "${USER}" "tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}")" != "0" ]; then + fn_print_error "Checking session: " + fn_print_error_eol_nl + fn_script_log_error "Checking session: ERROR" + fn_script_log_error "Checking session: PIDS with the same tmux session and socket names are running" + fn_script_log_error "Checking session: Killing session with the socketname name ${sessionname} and session name ${sessionname}" + pkill -f "tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}" + command_restart.sh + core_exit.sh + elif [ "${status}" != "0" ]; then fn_print_ok "Checking session: " fn_print_ok_eol_nl fn_script_log_pass "Checking session: OK" @@ -107,8 +201,8 @@ fn_monitor_check_session() { fi } +# Monitor will check queryport is set before continuing. fn_monitor_check_queryport() { - # Monitor will check queryport is set before continuing. if [ -z "${queryport}" ] || [ "${queryport}" == "0" ]; then fn_print_dots "Checking port: " fn_print_checking_eol @@ -133,7 +227,7 @@ fn_query_gsquery() { } fn_query_tcp() { - bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}'' > /dev/null 2>&1 + bash -c "exec 3<> /dev/tcp/'${queryip}'/'${queryport}'" > /dev/null 2>&1 querystatus="$?" } @@ -147,12 +241,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}-started.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}-started.lock")")" fn_script_log_info "Current time: $(date)" monitorpass=1 core_exit.sh @@ -271,8 +365,15 @@ core_logs.sh info_game.sh # query pre-checks -fn_monitor_check_lockfile +fn_monitor_check_update_source +fn_monitor_check_update +fn_monitor_check_backup +fn_monitor_check_debug +fn_monitor_check_monitoring +fn_monitor_check_starting +fn_monitor_check_stopping 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_restart.sh b/lgsm/modules/command_restart.sh index b7bb1f3e3..ed60a5555 100644 --- a/lgsm/modules/command_restart.sh +++ b/lgsm/modules/command_restart.sh @@ -5,7 +5,7 @@ # Website: https://linuxgsm.com # Description: Restarts the server. -commandname="MODS-INSTALL" +commandname="RESTART" commandaction="Restarting" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_firstcommand_set diff --git a/lgsm/modules/command_send.sh b/lgsm/modules/command_send.sh index 9f7c20dbb..e3dafd693 100644 --- a/lgsm/modules/command_send.sh +++ b/lgsm/modules/command_send.sh @@ -26,7 +26,7 @@ if [ "${status}" != "0" ]; then fi echo "" fn_print_dots "Sending command to console: \"${commandtosend}\"" - tmux -L "${sessionname}" send-keys -t "${servicename}" "${commandtosend}" ENTER + tmux -L "${socketname}" send-keys -t "${servicename}" "${commandtosend}" ENTER fn_print_ok_nl "Sending command to console: \"${commandtosend}\"" fn_script_log_pass "Command \"${commandtosend}\" sent to console" else diff --git a/lgsm/modules/command_skeleton.sh b/lgsm/modules/command_skeleton.sh index 01a7f4e7e..9e7c19a6a 100644 --- a/lgsm/modules/command_skeleton.sh +++ b/lgsm/modules/command_skeleton.sh @@ -5,7 +5,10 @@ # Website: https://linuxgsm.com # Description: Creates an copy of a game servers directorys. +commandname="SKELETON" +commandaction="Skeleton" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" +fn_firstcommand_set fn_print_dots "Creating skeleton directory" check.sh diff --git a/lgsm/modules/command_start.sh b/lgsm/modules/command_start.sh index b9f8fa51c..1302d0d99 100644 --- a/lgsm/modules/command_start.sh +++ b/lgsm/modules/command_start.sh @@ -11,39 +11,14 @@ 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() { fn_start_tmux - tmux -L "${sessionname}" end -t "${sessionname}" version ENTER > /dev/null 2>&1 + tmux -L "${socketname}" end -t "${sessionname}" version ENTER > /dev/null 2>&1 } fn_start_tmux() { - if [ "${parmsbypass}" ]; then - startparameters="" - fi # check for tmux size variables. if [[ "${servercfgtmuxwidth}" =~ ^[0-9]+$ ]]; then sessionwidth="${servercfgtmuxwidth}" @@ -68,35 +43,41 @@ 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 a starting lockfile that only exists while the start command is running. + date '+%s' > "${lockdir:?}/${selfname}-starting.lock" + fn_reload_startparameters + # Create uid to ensure unique tmux socket name. + if [ ! -f "${datadir}/${selfname}.uid" ]; then + # stop running server (if running) to prevent lingering tmux sessions. + exitbypass=1 + command_stop.sh + uid=$(date '+%s' | sha1sum | head -c 8) + echo "${uid}" > "${datadir}/${selfname}.uid" + socketname="${sessionname}-$(cat "${datadir}/${selfname}.uid")" + fi + if [ "${shortname}" == "av" ]; then cd "${systemdir}" || exit else cd "${executabledir}" || exit fi - tmux -L "${sessionname}" new-session -d -x "${sessionwidth}" -y "${sessionheight}" -s "${sessionname}" "${preexecutable} ${executable} ${startparameters}" 2> "${lgsmlogdir}/.${selfname}-tmux-error.tmp" + tmux -L "${socketname}" new-session -d -x "${sessionwidth}" -y "${sessionheight}" -s "${sessionname}" "${preexecutable} ${executable} ${startparameters}" 2> "${lgsmlogdir}/.${selfname}-tmux-error.tmp" # Create logfile. touch "${consolelog}" - # Create last start lock file - date +%s > "${lockdir}/${selfname}-laststart.lock" - # tmux compiled from source will return "master", therefore ignore it. if [ "${tmuxv}" == "master" ]; then 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 - tmux -L "${sessionname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" + if [ "${logtimestamp}" == "on" ]; then + tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" else - tmux -L "${sessionname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" + tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" fi fi @@ -114,10 +95,10 @@ fn_start_tmux() { Currently installed: $(tmux -V)" > "${consolelog}" # Console logging enable or not set. elif [ "${consolelogging}" == "on" ] || [ -z "${consolelogging}" ]; then - if [ "$logtimestamp" == "on" ]; then - tmux -L "${sessionname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" + if [ "${logtimestamp}" == "on" ]; then + tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec bash -c \"cat | $addtimestamp\" >> '${consolelog}'" else - tmux -L "${sessionname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" + tmux -L "${socketname}" pipe-pane -o -t "${sessionname}" "exec cat >> '${consolelog}'" fi fi else @@ -127,7 +108,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 @@ -176,8 +157,20 @@ fn_start_tmux() { fi fi fi + # Remove starting lockfile when command ends. + rm -f "${lockdir:?}/${selfname}-starting.lock" core_exit.sh else + # Create start lockfile that exists only when the server is running. + date '+%s' > "${lockdir:?}/${selfname}-started.lock" + echo "${version}" >> "${lockdir}/${selfname}-started.lock" + echo "${port}" >> "${lockdir}/${selfname}-started.lock" + fn_print_ok "${servername}" + fn_script_log_pass "Started ${servername}" + + # Create last started Lockfile. + date +%s > "${lockdir}/${selfname}-last-started.lock" + fn_print_ok "${servername}" fn_script_log_pass "Started ${servername}" fi @@ -187,23 +180,28 @@ 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 user ran the start command monitor will become enabled. +if [ "${firstcommandname}" == "START" ]||[ "${firstcommandname}" == "RESTART" ]; then + date '+%s' > "${lockdir:?}/${selfname}-monitoring.lock" +fi + +# If the server already started dont start again. if [ "${status}" != "0" ]; then fn_print_dots "${servername}" fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" if [ -z "${exitbypass}" ]; then + # Remove starting lockfile when command ends. + rm -f "${lockdir:?}/${selfname}-starting.lock" 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 @@ -212,13 +210,12 @@ 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 fi +# Remove starting lockfile when command ends. +rm -f "${lockdir:?}/${selfname}-starting.lock" core_exit.sh diff --git a/lgsm/modules/command_stop.sh b/lgsm/modules/command_stop.sh index a0cc18076..dc716216f 100644 --- a/lgsm/modules/command_stop.sh +++ b/lgsm/modules/command_stop.sh @@ -15,7 +15,7 @@ fn_stop_graceful_ctrlc() { fn_print_dots "Graceful: CTRL+c" fn_script_log_info "Graceful: CTRL+c" # Sends quit. - tmux -L "${sessionname}" send-keys -t "${sessionname}" C-c > /dev/null 2>&1 + tmux -L "${socketname}" send-keys -t "${sessionname}" C-c > /dev/null 2>&1 # Waits up to 30 seconds giving the server time to shutdown gracefuly. for seconds in {1..30}; do check_status.sh @@ -43,7 +43,7 @@ fn_stop_graceful_cmd() { fn_print_dots "Graceful: sending \"${1}\"" fn_script_log_info "Graceful: sending \"${1}\"" # Sends specific stop command. - tmux -L "${sessionname}" send -t "${sessionname}" ENTER "${1}" ENTER > /dev/null 2>&1 + tmux -L "${socketname}" send -t "${sessionname}" ENTER "${1}" ENTER > /dev/null 2>&1 # Waits up to ${seconds} seconds giving the server time to shutdown gracefully. for ((seconds = 1; seconds <= ${2}; seconds++)); do check_status.sh @@ -71,7 +71,7 @@ fn_stop_graceful_goldsrc() { fn_print_dots "Graceful: sending \"quit\"" fn_script_log_info "Graceful: sending \"quit\"" # sends quit - tmux -L "${sessionname}" send -t "${sessionname}" quit ENTER > /dev/null 2>&1 + tmux -L "${socketname}" send -t "${sessionname}" quit ENTER > /dev/null 2>&1 # Waits 3 seconds as goldsrc servers restart with the quit command. for seconds in {1..3}; do sleep 1 @@ -184,10 +184,10 @@ fn_stop_graceful_avorion() { fn_print_dots "Graceful: /save /stop" fn_script_log_info "Graceful: /save /stop" # Sends /save. - tmux -L "${sessionname}" send-keys -t "${sessionname}" /save ENTER > /dev/null 2>&1 + tmux -L "${socketname}" send-keys -t "${sessionname}" /save ENTER > /dev/null 2>&1 sleep 5 # Sends /quit. - tmux -L "${sessionname}" send-keys -t "${sessionname}" /stop ENTER > /dev/null 2>&1 + tmux -L "${socketname}" send-keys -t "${sessionname}" /stop ENTER > /dev/null 2>&1 # Waits up to 30 seconds giving the server time to shutdown gracefuly. for seconds in {1..30}; do check_status.sh @@ -240,7 +240,7 @@ fn_stop_tmux() { fn_print_dots "${servername}" fn_script_log_info "tmux kill-session: ${sessionname}: ${servername}" # Kill tmux session. - tmux -L "${sessionname}" kill-session -t "${sessionname}" > /dev/null 2>&1 + tmux -L "${socketname}" kill-session -t "${sessionname}" > /dev/null 2>&1 sleep 0.5 check_status.sh if [ "${status}" == "0" ]; then @@ -269,15 +269,27 @@ fn_stop_pre_check() { } check.sh + +# Create a stopping lockfile that only exists while the stop command is running. +date '+%s' > "${lockdir:?}/${selfname}-stopping.lock" + fn_print_dots "${servername}" info_game.sh fn_stop_pre_check -# Remove lockfile. -if [ -f "${lockdir}/${selfname}.lock" ]; then - rm -f "${lockdir:?}/${selfname}.lock" + +# Remove started lockfile. +rm -f "${lockdir:?}/${selfname}-started.lock" + +# If user ran the stop command monitor will become disabled. +if [ "${firstcommandname}" == "STOP" ];then + rm -f "${lockdir:?}/${selfname}-monitoring.lock" fi + +# Remove stopping lockfile. +rm -f "${lockdir:?}/${selfname}-stopping.lock" + if [ -z "${exitbypass}" ]; then core_exit.sh fi diff --git a/lgsm/modules/command_ts3_server_pass.sh b/lgsm/modules/command_ts3_server_pass.sh index 4814ab142..0223a877c 100644 --- a/lgsm/modules/command_ts3_server_pass.sh +++ b/lgsm/modules/command_ts3_server_pass.sh @@ -28,7 +28,7 @@ fn_serveradmin_password_prompt() { fn_serveradmin_password_set() { # Start server in "new password mode". ts3serverpass="1" - exitbypass="1" + exitbypass=1 command_start.sh fn_firstcommand_reset fn_print_ok_nl "New password applied" @@ -40,7 +40,7 @@ check.sh fn_serveradmin_password_prompt if [ "${status}" != "0" ]; then # Stop any running server. - exitbypass="1" + exitbypass=1 command_stop.sh fn_firstcommand_reset fn_serveradmin_password_set diff --git a/lgsm/modules/command_update.sh b/lgsm/modules/command_update.sh index 5993609c0..62221d5e6 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:?}/update.lock" + core_exit.sh diff --git a/lgsm/modules/command_validate.sh b/lgsm/modules/command_validate.sh index 23ee92a26..f4a6250f3 100644 --- a/lgsm/modules/command_validate.sh +++ b/lgsm/modules/command_validate.sh @@ -23,7 +23,7 @@ fn_validate() { fi done fn_print_warn_nl "Validate might overwrite some customised files" - + date '+%s' > "${lockdir:?}/update.lock" fn_dl_steamcmd } @@ -46,4 +46,7 @@ else fn_validate fi +# remove update lockfile +rm -f "${lockdir:?}/update.lock" + core_exit.sh diff --git a/lgsm/modules/core_exit.sh b/lgsm/modules/core_exit.sh index d43f0555a..a66744b19 100644 --- a/lgsm/modules/core_exit.sh +++ b/lgsm/modules/core_exit.sh @@ -12,7 +12,7 @@ fn_exit_dev_debug() { echo -e "" echo -e "${moduleselfname} exiting with code: ${exitcode}" if [ -f "${rootdir}/dev-debug.log" ]; then - grep "modulefile=" "${rootdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" + grep -a "modulefile=" "${rootdir}/dev-debug.log" | sed 's/modulefile=//g' > "${rootdir}/dev-debug-module-order.log" fi fi } diff --git a/lgsm/modules/core_steamcmd.sh b/lgsm/modules/core_steamcmd.sh index 02074620d..54de61b7c 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -248,7 +251,7 @@ fn_update_steamcmd_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir:?}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/fix_csgo.sh b/lgsm/modules/fix_csgo.sh index eb8cc9560..01b02c4e0 100644 --- a/lgsm/modules/fix_csgo.sh +++ b/lgsm/modules/fix_csgo.sh @@ -37,6 +37,6 @@ libgccc_so="${serverfiles}/bin/libgcc_s.so.1" if [ -f "${libgccc_so}" ]; then fixname="libgcc_s.so.1 move away" fn_fix_msg_start - mv -v "${libgccc_so}" "${libgccc_so}.bck" + mv "${libgccc_so}" "${libgccc_so}.bak" fn_fix_msg_end fi 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/info_distro.sh b/lgsm/modules/info_distro.sh index ee84d39f2..b375f8c02 100644 --- a/lgsm/modules/info_distro.sh +++ b/lgsm/modules/info_distro.sh @@ -10,7 +10,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" ### Game Server pid if [ "${status}" == "1" ]; then - gameserverpid="$(tmux -L "${sessionname}" list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $NF}')" + gameserverpid="$(tmux -L "${socketname}" list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $NF}')" if [ "${engine}" == "source" ]; then srcdslinuxpid="$(ps -ef | grep -v grep | grep "${gameserverpid}" | grep srcds_linux | awk '{print $2}')" elif [ "${engine}" == "goldsrc" ]; then diff --git a/lgsm/modules/update_factorio.sh b/lgsm/modules/update_factorio.sh index 2af9916aa..f7fb06c7d 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -117,7 +120,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_jediknight2.sh b/lgsm/modules/update_jediknight2.sh index d455a2722..e67b0c02b 100644 --- a/lgsm/modules/update_jediknight2.sh +++ b/lgsm/modules/update_jediknight2.sh @@ -61,7 +61,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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -114,7 +117,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_minecraft.sh b/lgsm/modules/update_minecraft.sh index e764e846e..cfdf7e057 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -128,7 +131,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_minecraft_bedrock.sh b/lgsm/modules/update_minecraft_bedrock.sh index 3c3885a9d..92bffca31 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -133,7 +136,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_mta.sh b/lgsm/modules/update_mta.sh index 16b8278c7..eab77c748 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:?}/update.lock" if [ "${forceupdate}" == "1" ]; then # forceupdate bypasses checks, useful for small build changes mtaupdatestatus="forced" @@ -118,7 +121,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_papermc.sh b/lgsm/modules/update_papermc.sh index b70a2d69d..2438c2d86 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -138,7 +141,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_steamcmd.sh b/lgsm/modules/update_steamcmd.sh index 401da43a8..20a85ab93 100644 --- a/lgsm/modules/update_steamcmd.sh +++ b/lgsm/modules/update_steamcmd.sh @@ -23,14 +23,15 @@ if [ "${forceupdate}" == "1" ]; then exitbypass=1 command_stop.sh fn_firstcommand_reset + date '+%s' > "${lockdir:?}/update.lock" fn_dl_steamcmd - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" exitbypass=1 command_start.sh fn_firstcommand_reset else fn_dl_steamcmd - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" fi else fn_update_steamcmd_localbuild diff --git a/lgsm/modules/update_ts3.sh b/lgsm/modules/update_ts3.sh index 30dc9e513..b031d2b34 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -121,7 +124,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_ut99.sh b/lgsm/modules/update_ut99.sh index 909286196..1ff84a060 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -115,7 +118,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/lgsm/modules/update_vintagestory.sh b/lgsm/modules/update_vintagestory.sh index d186d19aa..21e2d0e63 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:?}/update.lock" fn_print_ok_nl "Checking for update: ${remotelocation}" echo -en "\n" echo -e "Update available" @@ -122,7 +125,7 @@ fn_update_compare() { fn_firstcommand_reset fi unset exitbypass - date +%s > "${lockdir}/lastupdate.lock" + date +%s > "${lockdir}/last-updated.lock" alert="update" elif [ "${commandname}" == "CHECK-UPDATE" ]; then alert="check-update" diff --git a/linuxgsm.sh b/linuxgsm.sh index 52d12faca..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,8 @@ 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" [ -n "${LGSM_CONFIG}" ] && configdir="${LGSM_CONFIG}" || configdir="${lgsmdir}/config-lgsm"