فهرست منبع

feat: tmux uniqueness (#4296)

* refactor: refactor tmux session handling

- Updated the code to use the variable `socketname` instead of `sessionname` when interacting with tmux sessions.
- Added logic to create a unique socket name using a UID if it doesn't already exist.
- Refactored multiple functions (`fn_start_jk2`, `fn_start_tmux`, `fn_stop_graceful_ctrlc`, `fn_stop_graceful_cmd`, `fn_stop_graceful_goldsrc`, `fn_stop_graceful_avorion`, and `fn_stop_tmux`) to use the new socket name for tmux commands.

This commit improves the readability and maintainability of the code by separating the concept of session names from socket names, allowing for more flexibility in managing tmux sessions.

* feat: stop server when generating uid

this should prevent issues when migrating to using uid

* 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

* refactor: improve backup and update monitoring

The code in `command_monitor.sh` has been refactored to enhance the monitoring of backups and updates. The conditions for checking if a backup or update is running have been modified to include additional checks using `pgrep`. This change improves the accuracy of the monitoring process.

* refactor: improve logging in core_exit.sh

- Changed the grep command to include the -a flag to handle non-text files
- Updated sed command to remove "modulefile=" from the output and redirect it to dev-debug-module-order.log

* refactor: improve code readability and remove redundant code

- Refactored the `fn_monitor_check_starting` function to check for stale lockfiles and print appropriate messages.
- Refactored the `fn_monitor_check_stopping` function to check for stale lockfiles and print appropriate messages.
- Removed redundant code that deletes the update lockfile in `command_update.sh` and `command_validate.sh`.
- Improved code readability by removing unnecessary comments.

* feat: add exitbypass flag to prevent lingering tmux sessions

The code changes in `command_start.sh` include adding an `exitbypass` flag to prevent lingering tmux sessions. This flag is used to stop the running server before creating a unique uid for the tmux socket name.

* refactor: Refactor lockfile names for consistency and clarity

- Renamed "${lockdir}/${selfname}-laststart.lock" to "${lockdir}/${selfname}-last-started.lock"
- Renamed "${lockdir}/backup.lock" to "${lockdir}/stopping.lock"
- Renamed "${lockdir}/${selfname}-start.lock" to "${lockdir}/${selfname}-started.lock"
- Renamed "${lockdir}/${selfname}-starting.lock" to "${lockdir}/${selfname}-stopping.lock"

This commit refactors the lockfile names in the codebase for better consistency and clarity. The changes make it easier to understand the purpose of each lockfile and improve readability.

* refactor: refactor check_last_update.sh, command_backup.sh, command_debug.sh, command_mods_remove.sh, command_monitor.sh, command_start.sh, command_stop.sh, command_ts3_server_pass.sh and core_steamcmd.sh

- Refactored code to improve readability and maintainability.
- Renamed variables for clarity.
- Removed unnecessary comments and unused code.
- Fixed typos and formatting issues.

* refactor: update lock file path in core_steamcmd.sh

The lock file path in the core_steamcmd.sh script has been updated to use the correct variable. This change ensures that the lock file is created in the correct directory.

* refactor: improve file deletion in command_stop.sh

The code change refactors the file deletion process in the command_stop.sh script. Instead of using an empty redirect, it now directly removes the specified lock file. This improves clarity and ensures proper cleanup when stopping a command.

* refactor: update lockfile name in command_monitor.sh

The lockfile name has been changed from "${selfname}-started.lock" to "${selfname}-monitoring.lock" in the fn_monitor_check_lockfile function. The code has also been refactored to remove unnecessary checks and fixes for the lockfile.

* refactor: simplify start and stop command checks

The code in `command_start.sh` and `command_stop.sh` has been refactored to simplify the checks for the start and stop commands. Instead of checking if `exitbypass` is empty, it now directly checks if `firstcommandname` matches specific values ("START", "RESTART" for start command, and "STOP" for stop command). This change improves readability and reduces unnecessary conditions.

* refactor: simplify lockfile names and remove duplicate code

- Renamed lockfiles from "${selfname}-started.lock" to "started.lock", "${selfname}-starting.lock" to "starting.lock", "${selfname}-stopping.lock" to "stopping.lock", and "${selfname}-update.lock" to "update.lock".
- Removed duplicate code for removing stale lockfiles in fn_monitor_check_starting(), fn_monitor_check_stopping(), fn_monitor_check_backup(), fn_monitor_check_update(), update_factorio.sh, update_jediknight2.sh, update_minecraft.sh, update_minecraft_bedrock.sh, update_mta.sh, update_papermc.sh, update_ts3.sh, update_ut99.sh, and update_vintagestory.sh.
- Updated references to the renamed lockfiles in the respective functions.

* fix: corrected commandname

* fix: commandname skeleton

* refactor: improve file path handling in check_last_update.sh

The code changes refactor the file path handling in check_last_update.sh to use the correct lock directory. This ensures that the last update time is correctly retrieved and compared with the last start time.

* feat: add update lock file

Add functionality to create an update lock file when validating and updating SteamCMD. This prevents potential conflicts with customised files.

- Create a lock file with the current timestamp in the "command_validate.sh" script
- Create a lock file with the current timestamp in the "update_steamcmd.sh" script

* refactor: rename libgcc_s.so.1 backup file

The code has been refactored to improve clarity and readability. The variable `libgccc_so` has been renamed to `libgccc_so.bak` for better understanding of its purpose. This change ensures that the backup file for libgcc_s.so.1 is correctly named and easily identifiable.

* refactor: improve logging and error handling in command_monitor.sh

- Added error handling for PIDs with identical tmux sessions running, killing them and restarting the server.
- Added error handling for PIDs with the same tmux session and socket names running, killing them and restarting the server.
Daniel Gibbs 2 سال پیش
والد
کامیت
4ddd8ee184

+ 7 - 7
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

+ 1 - 1
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}")

+ 20 - 8
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

+ 1 - 1
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

+ 6 - 6
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

+ 1 - 1
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

+ 148 - 47
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

+ 1 - 1
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

+ 1 - 1
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

+ 3 - 0
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

+ 48 - 51
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

+ 21 - 9
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

+ 2 - 2
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

+ 3 - 0
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

+ 4 - 1
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

+ 1 - 1
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
 }

+ 4 - 1
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"

+ 1 - 1
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

+ 13 - 0
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"

+ 1 - 1
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

+ 4 - 1
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"

+ 4 - 1
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"

+ 4 - 1
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"

+ 4 - 1
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"

+ 4 - 1
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"

+ 4 - 1
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"

+ 3 - 2
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

+ 4 - 1
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"

+ 4 - 1
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"

+ 4 - 1
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"

+ 2 - 1
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"