Просмотр исходного кода

fix(log): allow logs to correctly display primary command (#2969)

Daniel Gibbs 5 лет назад
Родитель
Сommit
d327e93880
48 измененных файлов с 207 добавлено и 249 удалено
  1. 1 1
      lgsm/functions/alert.sh
  2. 1 1
      lgsm/functions/check_last_update.sh
  3. 1 1
      lgsm/functions/check_version.sh
  4. 6 8
      lgsm/functions/command_backup.sh
  5. 6 7
      lgsm/functions/command_console.sh
  6. 5 7
      lgsm/functions/command_debug.sh
  7. 4 6
      lgsm/functions/command_details.sh
  8. 4 6
      lgsm/functions/command_dev_clear_functions.sh
  9. 4 6
      lgsm/functions/command_dev_debug.sh
  10. 4 6
      lgsm/functions/command_dev_detect_deps.sh
  11. 4 6
      lgsm/functions/command_dev_detect_glibc.sh
  12. 4 6
      lgsm/functions/command_dev_detect_ldd.sh
  13. 4 6
      lgsm/functions/command_dev_query_raw.sh
  14. 4 6
      lgsm/functions/command_donate.sh
  15. 4 6
      lgsm/functions/command_fastdl.sh
  16. 5 7
      lgsm/functions/command_install.sh
  17. 4 6
      lgsm/functions/command_install_resources_mta.sh
  18. 4 6
      lgsm/functions/command_mods_install.sh
  19. 5 7
      lgsm/functions/command_mods_remove.sh
  20. 4 6
      lgsm/functions/command_mods_update.sh
  21. 5 7
      lgsm/functions/command_monitor.sh
  22. 4 6
      lgsm/functions/command_postdetails.sh
  23. 5 7
      lgsm/functions/command_restart.sh
  24. 5 7
      lgsm/functions/command_start.sh
  25. 4 6
      lgsm/functions/command_stop.sh
  26. 4 6
      lgsm/functions/command_test_alert.sh
  27. 8 10
      lgsm/functions/command_ts3_server_pass.sh
  28. 4 6
      lgsm/functions/command_update.sh
  29. 4 6
      lgsm/functions/command_update_linuxgsm.sh
  30. 6 8
      lgsm/functions/command_validate.sh
  31. 6 8
      lgsm/functions/command_wipe.sh
  32. 4 6
      lgsm/functions/compress_unreal2_maps.sh
  33. 4 6
      lgsm/functions/compress_ut99_maps.sh
  34. 17 0
      lgsm/functions/core_messages.sh
  35. 4 4
      lgsm/functions/fix_kf.sh
  36. 2 2
      lgsm/functions/fix_kf2.sh
  37. 4 4
      lgsm/functions/fix_ro.sh
  38. 4 4
      lgsm/functions/fix_ut2k4.sh
  39. 2 2
      lgsm/functions/fix_ut3.sh
  40. 2 2
      lgsm/functions/fix_wurm.sh
  41. 1 1
      lgsm/functions/install_modules.sh
  42. 4 4
      lgsm/functions/update_factorio.sh
  43. 5 5
      lgsm/functions/update_minecraft.sh
  44. 6 6
      lgsm/functions/update_minecraft_bedrock.sh
  45. 4 4
      lgsm/functions/update_mta.sh
  46. 3 3
      lgsm/functions/update_mumble.sh
  47. 4 4
      lgsm/functions/update_steamcmd.sh
  48. 4 4
      lgsm/functions/update_ts3.sh

+ 1 - 1
lgsm/functions/alert.sh

@@ -99,7 +99,7 @@ fn_alert_log
 if [ "${postalert}" == "on" ]&&[ -n "${postalert}" ]; then
 	exitbypass=1
 	command_postdetails.sh
-	fn_commandname
+	fn_firstcommand_reset
 elif [ "${postalert}" != "on" ]&&[ "${commandname}" == "TEST-ALERT" ]; then
 	fn_print_warn_nl "More Info not enabled"
 	fn_script_log_warn "More Info alerts not enabled"

+ 1 - 1
lgsm/functions/check_last_update.sh

@@ -20,6 +20,6 @@ if [ -f "${lockdir}/lastupdate.lock" ]&&[ "${status}" != "0" ]; 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
-		fn_commandname
+		fn_firstcommand_reset
 	fi
 fi

+ 1 - 1
lgsm/functions/check_version.sh

@@ -16,5 +16,5 @@ if [ -n "${modulesversion}" ]&&[ -n "${version}" ]&&[ "${version}" != "${modules
 	fn_sleep_time
 	fn_script_log_error "LinuxGSM Version mismatch: ${selfname}: ${version}: modules: ${modulesversion}"
 	command_update_linuxgsm.sh
-	fn_commandname
+	fn_firstcommand_reset
 fi

+ 6 - 8
lgsm/functions/command_backup.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Creates a .tar.gz file in the backup directory.
 
-fn_commandname(){
-	commandname="BACKUP"
-	commandaction="Backing up"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="BACKUP"
+commandaction="Backing up"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 
@@ -77,7 +75,7 @@ fn_backup_stop_server(){
 		startserver="1"
 		exitbypass=1
 		command_stop.sh
-		fn_commandname
+		fn_firstcommand_reset
 	fi
 }
 
@@ -252,7 +250,7 @@ fn_backup_start_server(){
 	if [ -n "${startserver}" ]; then
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 	fi
 }
 

+ 6 - 7
lgsm/functions/command_console.sh

@@ -4,12 +4,11 @@
 # Website: https://linuxgsm.com
 # Description: Gives access to the server tmux console.
 
-fn_commandname(){
-	commandname="CONSOLE"
-	commandaction="Access console"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+
+commandname="CONSOLE"
+commandaction="Access console"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 fn_print_header
@@ -38,7 +37,7 @@ else
 	if fn_prompt_yn "Do you want to start the server?" Y; then
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 	fi
 fi
 

+ 5 - 7
lgsm/functions/command_debug.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Runs the server without tmux and directly from the terminal.
 
-fn_commandname(){
-	commandname="DEBUG"
-	commandaction="Debuging"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEBUG"
+commandaction="Debuging"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 # Trap to remove lockfile on quit.
 fn_lockfile_trap(){
@@ -91,7 +89,7 @@ fn_print_info_nl "Stopping any running servers"
 fn_script_log_info "Stopping any running servers"
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset
 unset exitbypass
 fn_print_dots "Starting debug"
 fn_script_log_info "Starting debug"

+ 4 - 6
lgsm/functions/command_details.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Displays server information.
 
-fn_commandname(){
-	commandname="DETAILS"
-	commandaction="Viewing details"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DETAILS"
+commandaction="Viewing details"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 # Run checks and gathers details to display.
 check.sh

+ 4 - 6
lgsm/functions/command_dev_clear_functions.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Deletes the contents of the functions dir.
 
-fn_commandname(){
-	commandname="DEV-CLEAR-MODULES"
-	commandaction="Clearing modules"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-CLEAR-MODULES"
+commandaction="Clearing modules"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 echo -e "================================="
 echo -e "Clear Functions"

+ 4 - 6
lgsm/functions/command_dev_debug.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Dev only: Enables debugging log to be saved to dev-debug.log.
 
-fn_commandname(){
-	commandname="DEV-DEBUG"
-	commandaction="Developer debug"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-DEBUG"
+commandaction="Developer debug"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_reset
 
 if [ -f "${rootdir}/.dev-debug" ]; then
 	rm "${rootdir:?}/.dev-debug"

+ 4 - 6
lgsm/functions/command_dev_detect_deps.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Detects dependencies the server binary requires.
 
-fn_commandname(){
-	commandname="DEV-DETECT-DEPS"
-	commandaction="Developer detect deps"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-DETECT-DEPS"
+commandaction="Developer detect deps"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 echo -e "================================="
 echo -e "Dependencies Checker"

+ 4 - 6
lgsm/functions/command_dev_detect_glibc.sh

@@ -5,12 +5,10 @@
 # Description: Automatically detects the version of GLIBC that is required.
 # Can check a file or directory recursively.
 
-fn_commandname(){
-	commandname="DEV-DETECT-GLIBC"
-	commandaction="Developer detect glibc"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-DETECT-GLIBC"
+commandaction="Developer detect glibc"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 echo -e "================================="
 echo -e "glibc Requirements Checker"

+ 4 - 6
lgsm/functions/command_dev_detect_ldd.sh

@@ -5,12 +5,10 @@
 # Description: Automatically detects required deps using ldd.
 # Can check a file or directory recursively.
 
-fn_commandname(){
-	commandname="DEV-DETECT-LDD"
-	commandaction="Developer detect ldd"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-DETECT-LDD"
+commandaction="Developer detect ldd"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 echo -e "================================="
 echo -e "Shared Object dependencies Checker"

+ 4 - 6
lgsm/functions/command_dev_query_raw.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Raw gamedig output of the server.
 
-fn_commandname(){
-	commandname="DEV-QUERY-RAW"
-	commandaction="Developer query raw"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEV-QUERY-RAW"
+commandaction="Developer query raw"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 info_config.sh

+ 4 - 6
lgsm/functions/command_donate.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Shows ways to donate.
 
-fn_commandname(){
-  commandname="DONATE"
-  commandaction="Donate"
-  functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DONATE"
+commandaction="Donate"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_print_ascii_logo
 echo -e "${lightyellow}Support LinuxGSM${default}"

+ 4 - 6
lgsm/functions/command_fastdl.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Creates a FastDL directory.
 
-fn_commandname(){
-	commandname="FASTDL"
-	commandaction="Fastdl"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="FASTDL"
+commandaction="Fastdl"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 

+ 5 - 7
lgsm/functions/command_install.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Overall function for the installer.
 
-fn_commandname(){
-	commandname="INSTALL"
-	commandaction="Installing"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="INSTALL"
+commandaction="Installing"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 if [ "$(whoami)" = "root" ]; then
@@ -45,7 +43,7 @@ else
 		install_ts3db.sh
 	elif [ "${shortname}" == "mta" ]; then
 		command_install_resources_mta.sh
-		fn_commandname
+		fn_firstcommand_reset
 	fi
 
 	fix.sh

+ 4 - 6
lgsm/functions/command_install_resources_mta.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Installs the default resources for Multi Theft Auto.
 
-fn_commandname(){
-	commandname="DEFAULT-RESOURCES"
-	commandaction="Default Resources"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="DEFAULT-RESOURCES"
+commandaction="Default Resources"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_install_resources(){
 	echo -e ""

+ 4 - 6
lgsm/functions/command_mods_install.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: List and installs available mods along with mods_list.sh and mods_core.sh.
 
-fn_commandname(){
-	commandname="MODS-INSTALL"
-	commandaction="Installing mods"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MODS-INSTALL"
+commandaction="Installing mods"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 mods_core.sh

+ 5 - 7
lgsm/functions/command_mods_remove.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Uninstall mods along with mods_list.sh and mods_core.sh.
 
-fn_commandname(){
-	commandname="MODS-REMOVE"
-	commandaction="Removing mods"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MODS-REMOVE"
+commandaction="Removing mods"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 mods_core.sh
@@ -126,7 +124,7 @@ if [ "${engine}" == "unity3d" ]&&[[ "${modprettyname}" == *"Oxide"* ]]; then
 	fn_script_log "Validating to restore original ${gamename} files replaced by Oxide"
 	exitbypass="1"
 	command_validate.sh
-	fn_commandname
+	fn_firstcommand_reset
 	unset exitbypass
 fi
 echo -e "${modprettyname} removed"

+ 4 - 6
lgsm/functions/command_mods_update.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Updates installed mods along with mods_list.sh and mods_core.sh.
 
-fn_commandname(){
-	commandname="MODS-UPDATE"
-	commandaction="Updating mods"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MODS-UPDATE"
+commandaction="Updating mods"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 mods_core.sh

+ 5 - 7
lgsm/functions/command_monitor.sh

@@ -6,12 +6,10 @@
 # Description: Monitors server by checking for running processes
 # then passes to gamedig and gsquery.
 
-fn_commandname(){
-	commandname="MONITOR"
-	commandaction="Monitoring"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MONITOR"
+commandaction="Monitoring"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_monitor_check_lockfile(){
 	# Monitor does not run it lockfile is not found.
@@ -173,7 +171,7 @@ for queryattempt in {1..5}; do
 				alert="restartquery"
 				alert.sh
 				command_restart.sh
-				fn_commandname
+				fn_firstcommand_reset
 				core_exit.sh
 			fi
 		elif [ "${querymethod}" ==  "gamedig" ]; then

+ 4 - 6
lgsm/functions/command_postdetails.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Strips sensitive information out of Details output
 
-fn_commandname(){
-	commandname="POST-DETAILS"
-	commandaction="Posting details"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="POST-DETAILS"
+commandaction="Posting details"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 # Set posttarget to the appropriately-defined post destination.
 

+ 5 - 7
lgsm/functions/command_restart.sh

@@ -4,16 +4,14 @@
 # Website: https://linuxgsm.com
 # Description: Restarts the server.
 
-fn_commandname(){
-  commandname="MODS-INSTALL"
-  commandaction="Restarting"
-  functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MODS-INSTALL"
+commandaction="Restarting"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 info_config.sh
 exitbypass=1
 command_stop.sh
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 core_exit.sh

+ 5 - 7
lgsm/functions/command_start.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Starts the server.
 
-fn_commandname(){
-	commandname="START"
-	commandaction="Starting"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="START"
+commandaction="Starting"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_start_teamspeak3(){
 	if [ ! -f "${servercfgfullpath}" ]; then
@@ -191,7 +189,7 @@ if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateon
 	exitbypass=1
 	unset updateonstart
 	command_update.sh
-	fn_commandname
+	fn_firstcommand_reset
 fi
 
 fn_print_dots "${servername}"

+ 4 - 6
lgsm/functions/command_stop.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Stops the server.
 
-fn_commandname(){
-	commandname="STOP"
-	commandaction="Stopping"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="STOP"
+commandaction="Stopping"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 # Attempts graceful shutdown by sending 'CTRL+c'.
 fn_stop_graceful_ctrlc(){

+ 4 - 6
lgsm/functions/command_test_alert.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Sends a test alert.
 
-fn_commandname(){
-  commandname="TEST-ALERT"
-  commandaction="Sending Alert"
-  functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="TEST-ALERT"
+commandaction="Sending Alert"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_print_dots "${servername}"
 check.sh

+ 8 - 10
lgsm/functions/command_ts3_server_pass.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Changes TS3 serveradmin password.
 
-fn_commandname(){
-	commandname="CHANGE-PASSWORD"
-	commandaction="Changing password"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="CHANGE-PASSWORD"
+commandaction="Changing password"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_serveradmin_password_prompt(){
 	fn_print_header
@@ -31,7 +29,7 @@ fn_serveradmin_password_set(){
 	ts3serverpass="1"
 	exitbypass="1"
 	command_start.sh
-	fn_commandname
+	fn_firstcommand_reset
 	fn_print_ok_nl "New password applied"
 	fn_script_log_pass "New ServerAdmin password applied"
 }
@@ -43,16 +41,16 @@ if [ "${status}" != "0" ]; then
 	# Stop any running server.
 	exitbypass="1"
 	command_stop.sh
-	fn_commandname
+	fn_firstcommand_reset
 	fn_serveradmin_password_set
 	parms="serveradmin_password=\"${newpassword}\" inifile=\"${servercfgfullpath}\" > /dev/null 2>&1"
 	ts3serverpass="0"
 	command_restart.sh
-	fn_commandname
+	fn_firstcommand_reset
 else
 	fn_serveradmin_password_set
 	command_stop.sh
-	fn_commandname
+	fn_firstcommand_reset
 fi
 
 core_exit.sh

+ 4 - 6
lgsm/functions/command_update.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Handles updating of servers.
 
-fn_commandname(){
-	commandname="UPDATE"
-	commandaction="Updating"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="UPDATE"
+commandaction="Updating"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_print_dots ""
 check.sh

+ 4 - 6
lgsm/functions/command_update_linuxgsm.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
-fn_commandname(){
-	commandname="UPDATE-LGSM"
-	commandaction="Updating LinuxGSM"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="UPDATE-LGSM"
+commandaction="Updating LinuxGSM"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 

+ 6 - 8
lgsm/functions/command_validate.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Runs a server validation.
 
-fn_commandname(){
-	commandname="VALIDATE"
-	commandaction="Validating"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="VALIDATE"
+commandaction="Validating"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 fn_validate(){
 	fn_print_warn "Validate might overwrite some customised files"
@@ -38,11 +36,11 @@ if [ "${status}" != "0" ]; then
 	fn_print_restart_warning
 	exitbypass=1
 	command_stop.sh
-	fn_commandname
+	fn_firstcommand_reset
 	fn_validate
 	exitbypass=1
 	command_start.sh
-	fn_commandname
+	fn_firstcommand_reset
 else
 	fn_validate
 fi

+ 6 - 8
lgsm/functions/command_wipe.sh

@@ -5,12 +5,10 @@
 # Website: https://linuxgsm.com
 # Description: Wipes server data, useful after updates for some games like Rust
 
-fn_commandname(){
-	commandname="WIPE"
-	commandaction="Wiping"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="WIPE"
+commandaction="Wiping"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 # Provides an exit code upon error.
 fn_wipe_exit_code(){
@@ -198,11 +196,11 @@ if [ -d "${serveridentitydir}/storage" ]||[ -d "${serveridentitydir}/user" ]||[
 		fn_stop_warning
 		exitbypass=1
 		command_stop.sh
-		fn_commandname
+		fn_firstcommand_reset
 		fn_wipe_server_files
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 	else
 		fn_wipe_server_files
 	fi

+ 4 - 6
lgsm/functions/compress_unreal2_maps.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Compresses unreal maps.
 
-fn_commandname(){
-	commandname="MAP-COMPRESSOR"
-	commandaction="Compressing maps"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MAP-COMPRESSOR"
+commandaction="Compressing maps"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 fn_print_header

+ 4 - 6
lgsm/functions/compress_ut99_maps.sh

@@ -4,12 +4,10 @@
 # Website: https://linuxgsm.com
 # Description: Compresses unreal maps.
 
-fn_commandname(){
-	commandname="MAP-COMPRESSOR"
-	commandaction="Compressing maps"
-	functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
-}
-fn_commandname
+commandname="MAP-COMPRESSOR"
+commandaction="Compressing maps"
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+fn_firstcommand_set
 
 check.sh
 fn_print_header

+ 17 - 0
lgsm/functions/core_messages.sh

@@ -544,3 +544,20 @@ fn_print_restart_warning(){
 	done
 	fn_print_warn_nl "${selfname} will be restarted"
 }
+
+# Functions below are used to ensure that logs and UI correctly reflect the command it is actually running.
+# Useful when a command has to call upon another command causing the other command to overrite commandname variables
+
+# Used to remember the command that ran first.
+fn_firstcommand_set(){
+	if [ -z "${firstcommandname}" ]; then
+		firstcommandname="${commandname}"
+		firstcommandaction="${commandaction}"
+	fi
+}
+
+# Used to reset commandname variables to the command the script ran first.
+fn_firstcommand_reset(){
+	commandname="${firstcommandname}"
+	commandaction="${firstcommandaction}"
+}

+ 4 - 4
lgsm/functions/fix_kf.sh

@@ -21,15 +21,15 @@ echo -e "forcing server restart..."
 fn_sleep_time
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset

+ 2 - 2
lgsm/functions/fix_kf2.sh

@@ -14,8 +14,8 @@ fn_print_information "starting ${gamename} server to generate configs."
 fn_sleep_time
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 10
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset

+ 4 - 4
lgsm/functions/fix_ro.sh

@@ -24,15 +24,15 @@ echo -e "forcing server restart..."
 fn_sleep_time
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset

+ 4 - 4
lgsm/functions/fix_ut2k4.sh

@@ -21,15 +21,15 @@ echo -e "forcing server restart."
 fn_sleep_time
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 5
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset

+ 2 - 2
lgsm/functions/fix_ut3.sh

@@ -14,8 +14,8 @@ fn_print_information "starting ${gamename} server to generate configs."
 fn_sleep_time
 exitbypass=1
 command_start.sh
-fn_commandname
+fn_firstcommand_reset
 sleep 10
 exitbypass=1
 command_stop.sh
-fn_commandname
+fn_firstcommand_reset

+ 2 - 2
lgsm/functions/fix_wurm.sh

@@ -18,10 +18,10 @@ if [ ! -d "${serverfiles}/Creative" ]; then
 	fixbypass=1
 	exitbypass=1
 	command_start.sh
-	fn_commandname
+	fn_firstcommand_reset
 	sleep 10
 	exitbypass=1
 	command_stop.sh
-	fn_commandname
+	fn_firstcommand_reset
 	unset parmsbypass
 fi

+ 1 - 1
lgsm/functions/install_modules.sh

@@ -14,4 +14,4 @@ cp "${tmpdir}/LinuxGSM-master/lgsm/functions"/*.sh "${functionsdir}"
 cp "${tmpdir}/LinuxGSM-master/lgsm/functions"/*.py "${functionsdir}"
 chmod +x "${functionsdir}"/*
 command_update_linuxgsm.sh
-fn_commandname
+fn_firstcommand_reset

+ 4 - 4
lgsm/functions/update_factorio.sh

@@ -96,21 +96,21 @@ fn_update_factorio_compare(){
 			fn_update_factorio_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_factorio_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"

+ 5 - 5
lgsm/functions/update_minecraft.sh

@@ -44,10 +44,10 @@ fn_update_minecraft_localbuild(){
 		fn_script_log_info "Forcing server restart"
 		exitbypass=1
 		command_stop.sh
-		fn_commandname
+		fn_firstcommand_reset
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 		totalseconds=0
 		# Check again, allow time to generate logs.
 		while [ ! -f "${serverfiles}/logs/latest.log" ]; do
@@ -159,18 +159,18 @@ fn_update_minecraft_compare(){
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_minecraft_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"

+ 6 - 6
lgsm/functions/update_minecraft_bedrock.sh

@@ -47,16 +47,16 @@ fn_update_minecraft_localbuild(){
 		if [ "${status}" == "0" ]; then
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 			sleep 3
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 	fi
 
@@ -126,18 +126,18 @@ fn_update_minecraft_compare(){
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_minecraft_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"

+ 4 - 4
lgsm/functions/update_mta.sh

@@ -40,7 +40,7 @@ fn_update_mta_localbuild(){
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 		totalseconds=0
 		# Check again, allow time to generate logs.
 		while [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; do
@@ -155,18 +155,18 @@ fn_update_mta_compare(){
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_mta_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"

+ 3 - 3
lgsm/functions/update_mumble.sh

@@ -91,18 +91,18 @@ fn_update_mumble_compare(){
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_mumble_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"

+ 4 - 4
lgsm/functions/update_steamcmd.sh

@@ -106,12 +106,12 @@ fn_update_steamcmd_compare(){
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_dl_steamcmd
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"
@@ -203,12 +203,12 @@ if [ "${forceupdate}" == "1" ]; then
 		fn_print_restart_warning
 		exitbypass=1
 		command_stop.sh
-		fn_commandname
+		fn_firstcommand_reset
 		fn_dl_steamcmd
 		date +%s > "${lockdir}/lastupdate.lock"
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 	else
 		fn_dl_steamcmd
 		date +%s > "${lockdir}/lastupdate.lock"

+ 4 - 4
lgsm/functions/update_ts3.sh

@@ -44,7 +44,7 @@ fn_update_ts3_localbuild(){
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		fn_commandname
+		fn_firstcommand_reset
 		totalseconds=0
 		# Check again, allow time to generate logs.
 		while [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; do
@@ -153,18 +153,18 @@ fn_update_ts3_compare(){
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 		# If server started.
 		else
 			fn_print_restart_warning
 			exitbypass=1
 			command_stop.sh
-			fn_commandname
+			fn_firstcommand_reset
 			exitbypass=1
 			fn_update_ts3_dl
 			exitbypass=1
 			command_start.sh
-			fn_commandname
+			fn_firstcommand_reset
 		fi
 		date +%s > "${lockdir}/lastupdate.lock"
 		alert="update"