4
0
Эх сурвалжийг харах

feat(update): Update command refactor

* Update update_factorio.sh

* feat(core): add error eol message

* fix(alert): resolve typo with script messages

* fix(check): add debug to executable check

* fix(general): correct commandname

* fix(general): change to lowercase

* fix(general): remove not required exitcodes

* fix(general): remove not required exitcodes


fix(general): remove not required exitcodes

* fix(check): a minor refactor

* feat(linuxgsm): Clear tmp directory


added script log

* feat(update: Factorio update now checks current build from executable

* feat(update: Factorio update now checks current build from executable


sqush

* moved executable dir

* feat(update): refactor of fctrserver updater

* changed to directory


squash

* corrected build details in log file

* corrected build details in log file

* more changes to logging

* altered log messages

* Re-worded current>local latest>remote

* Re-worded current>local latest>remote

* corrected logging

* corrected fn_script_log_fatal

* altered message to error from fatal

* improves messages

* minor tidy

* correct script log message

* code tidy

* feat(mumble): refactor mumble updater

* feat(mtaserver): refactor mtaserver updater

* feat(mcserver): refactor mcserver updater

* feat(fctrserver): refactor fctrserver updater

* tidy up  script wording

* corrected function name

* bug fixes for mcserver updater

* add sleep to allow mcserver time to generate log file

* increase timer to 30 seconds

* increased to 60 seconds

* changed back to red

* add check for log file delay to allow time to generate

* further refactor improvements

* mtaserver: curl now uses to get info from version.h

* minor tidy

* refactor ts3 updater

* corrected server arch

* refactor

* refactor updaters

* refactor updaters

* removed app_info_print
Daniel Gibbs 7 жил өмнө
parent
commit
a79feaf34c

+ 9 - 9
lgsm/functions/alert.sh

@@ -106,10 +106,10 @@ elif [ "${postalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert
 	fn_script_log_warn "More Info alerts not enabled"
 elif [ -z "${posttarget}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "posttarget not set"
-	fn_script_error_warn "posttarget not set"
+	fn_script_error "posttarget not set"
 elif [ -z "${postdays}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "postdays not set"
-	fn_script_error_warn "postdays not set"
+	fn_script_error "postdays not set"
 fi
 
 if [ "${discordalert}" == "on" ]&&[ -n "${discordalert}" ]; then
@@ -120,7 +120,7 @@ elif [ "${discordalert}" != "on" ]&&[ "${function_selfname}" == "command_test_al
 elif [ -z "${discordtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Discord token not set"
 	echo "	* https://docs.linuxgsm.com/alerts/discord"
-	fn_script_error_warn "Discord token not set"
+	fn_script_error "Discord token not set"
 fi
 
 if [ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then
@@ -141,7 +141,7 @@ elif [ "${iftttalert}" != "on" ]&&[ "${function_selfname}" == "command_test_aler
 elif [ -z "${ifttttoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "IFTTT token not set"
 	echo "	* https://docs.linuxgsm.com/alerts/ifttt"
-	fn_script_error_warn "IFTTT token not set"
+	fn_script_error "IFTTT token not set"
 fi
 
 if [ "${mailgunalert}" == "on" ]&&[ -n "${mailgunalert}" ]; then
@@ -152,7 +152,7 @@ elif [ "${mailgunalert}" != "on" ]&&[ "${function_selfname}" == "command_test_al
 elif [ -z "${mailguntoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Mailgun token not set"
 	echo "	* https://docs.linuxgsm.com/alerts/mailgun"
-	fn_script_error_warn "Mailgun token not set"
+	fn_script_error "Mailgun token not set"
 fi
 
 if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then
@@ -163,7 +163,7 @@ elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test
 elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Pushbullet token not set"
 	echo "	* https://docs.linuxgsm.com/alerts/pushbullet"
-	fn_script_error_warn "Pushbullet token not set"
+	fn_script_error "Pushbullet token not set"
 fi
 
 if [ "${pushoveralert}" == "on" ]&&[ -n "${pushoveralert}" ]; then
@@ -174,7 +174,7 @@ elif [ "${pushoveralert}" != "on" ]&&[ "${function_selfname}" == "command_test_a
 elif [ -z "${pushovertoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Pushover token not set"
 	echo "	* https://docs.linuxgsm.com/alerts/pushover"
-	fn_script_error_warn "Pushover token not set"
+	fn_script_error "Pushover token not set"
 fi
 
 if [ "${telegramalert}" == "on" ]&&[ -n "${telegramtoken}" ]; then
@@ -185,9 +185,9 @@ elif [ "${telegramalert}" != "on" ]&&[ "${function_selfname}" == "command_test_a
 elif [ -z "${telegramtoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Telegram token not set."
 	echo "	* https://docs.linuxgsm.com/alerts/telegram"
-	fn_script_error_warn "Telegram token not set."
+	fn_script_error "Telegram token not set."
 elif [ -z "${telegramchatid}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then
 	fn_print_error_nl "Telegram chat id not set."
 	echo "	* https://docs.linuxgsm.com/alerts/telegram"
-	fn_script_error_warn "Telegram chat id not set."
+	fn_script_error "Telegram chat id not set."
 fi

+ 1 - 1
lgsm/functions/check.sh

@@ -26,7 +26,7 @@ if [ "${function_selfname}" != "command_install.sh" ]&&[ "${function_selfname}"
 	check_system_dir.sh
 fi
 
-local allowed_commands_array=( command_start.sh )
+local allowed_commands_array=( command_start.sh command_debug.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
 	if [ "${allowed_command}" == "${function_selfname}" ]; then

+ 4 - 5
lgsm/functions/check_executable.sh

@@ -2,18 +2,17 @@
 # LinuxGSM check_executable.sh function
 # Author: Daniel Gibbs
 # Website: https://linuxgsm.com
-# Description: Checks if executable exists.
+# Description: Checks if server executable exists.
 
 local commandname="CHECK"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 # Check if executable exists
 if [ ! -f "${executabledir}/${execname}" ]; then
-	fn_script_log_warn "Executable was not found: ${executabledir}/${execname}"
+	fn_print_fatal_nl "executable was not found:"
+	echo " * ${executabledir}/${execname}"
 	if [ -d "${lgsmlogdir}" ]; then
-		fn_print_fail_nl "Executable was not found:"
-		echo " * ${executabledir}/${execname}"
+		fn_script_log_fatal "Executable was not found: ${executabledir}/${execname}"
 	fi
-	exitcode="1"
 	core_exit.sh
 fi

+ 1 - 1
lgsm/functions/check_permissions.sh

@@ -78,7 +78,7 @@ fn_check_permissions(){
 		# Grab the first and second digit for user and group permission
 		userrootdirperm="${rootdirperm:0:1}"
 		grouprootdirperm="${rootdirperm:1:1}"
-		if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
+		if [ "${userrootdirperm}" != "7" ]&&[ "${grouprootdirperm}" != "7" ]; then
 			fn_print_fail_nl "Permissions issues found"
 			fn_script_log_fatal "Permissions issues found"
 			fn_print_information_nl "The following directory does not have the correct permissions:"

+ 2 - 1
lgsm/functions/check_tmuxception.sh

@@ -5,7 +5,7 @@
 # Website: https://linuxgsm.com
 # Description: Checks if run from tmux or screen
 
-local commandname="check"
+local commandname="CHECK"
 
 fn_check_is_in_tmux(){
   if [ -n "${TMUX}" ]; then
@@ -17,6 +17,7 @@ fn_check_is_in_tmux(){
 		core_exit.sh
 	fi
 }
+
 fn_check_is_in_screen(){
 	if [ -n "${STY}" ]; then
 		fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a screen session."

+ 1 - 1
lgsm/functions/command_dev_query_raw.sh

@@ -5,7 +5,7 @@
 # Description: Raw gamedig output of the server.
 
 local commandname="QUERY-RAW"
-local commandaction="QUERY-RAW"
+local commandaction="Query Raw"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 echo "================================="

+ 1 - 1
lgsm/functions/command_mods_remove.sh

@@ -6,7 +6,7 @@
 # Description: Uninstall mods along with mods_list.sh and mods_core.sh.
 
 local commandname="MODS"
-local commandaction="addons/mods"
+local commandaction="Mods Remove"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 check.sh

+ 0 - 1
lgsm/functions/command_monitor.sh

@@ -38,7 +38,6 @@ for queryattempt in {1..5}; do
 		fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
 		fn_print_ok_eol_nl
 		fn_script_log_pass "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt}: OK"
-		exitcode=0
 		monitorpass=1
 		core_exit.sh
 	else

+ 1 - 1
lgsm/functions/command_postdetails.sh

@@ -5,7 +5,7 @@
 # Website: https://linuxgsm.com
 # Description: Strips sensitive information out of Details output
 
-local commandname="postdetails"
+local commandname="POSTDETAILS"
 local commandaction="Postdetails"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 

+ 1 - 1
lgsm/functions/command_update_linuxgsm.sh

@@ -4,7 +4,7 @@
 # Website: https://linuxgsm.com
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
-local commandname="UPDATE LinuxGSM"
+local commandname="UPDATE LINUXGSM"
 local commandaction="Update LinuxGSM"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 

+ 1 - 1
lgsm/functions/command_wipe.sh

@@ -6,7 +6,7 @@
 # Description: Wipes server data, useful after updates for some games like Rust
 
 local commandname="WIPE"
-local commandaction="data wipe"
+local commandaction="Wipe"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 check.sh

+ 42 - 25
lgsm/functions/core_dl.sh

@@ -21,8 +21,24 @@ local commandname="DOWNLOAD"
 local commandaction="Download"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
+# Emptys contents of the LinuxGSM tmpdir.
+fn_clear_tmp(){
+	echo -en "clearing LinuxGSM tmp directory..."
+	if [ -d "${tmpdir}" ]; then
+		rm -rf "${tmpdir}/"*
+		local exitcode=$?
+		if [ ${exitcode} -eq 0 ]; then
+			fn_print_ok_eol_nl
+			fn_script_log_pass "clearing LinuxGSM tmp directory"
+		else
+			fn_print_error_eol_nl
+			fn_script_log_error "clearing LinuxGSM tmp directory"
+		fi
+	fi	
+}
+
 fn_dl_md5(){
-	# Runs MD5 Check if available
+	# Runs MD5 Check if available.
 	if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then
 		echo -en "verifying ${local_filename} with MD5..."
 		sleep 0.5
@@ -31,20 +47,20 @@ fn_dl_md5(){
 			fn_print_fail_eol_nl
 			echo "${local_filename} returned MD5 checksum: ${md5sumcmd}"
 			echo "expected MD5 checksum: ${md5}"
-			fn_script_log_fatal "Verifying ${local_filename} with MD5: FAIL"
+			fn_script_log_fatal "Verifying ${local_filename} with MD5"
 			fn_script_log_info "${local_filename} returned MD5 checksum: ${md5sumcmd}"
 			fn_script_log_info "Expected MD5 checksum: ${md5}"
 			core_exit.sh
 		else
 			fn_print_ok_eol_nl
-			fn_script_log_pass "Verifying ${local_filename} with MD5: OK"
+			fn_script_log_pass "Verifying ${local_filename} with MD5"
 			fn_script_log_info "${local_filename} returned MD5 checksum: ${md5sumcmd}"
 			fn_script_log_info "Expected MD5 checksum: ${md5}"
 		fi
 	fi
 }
 
-# Extracts bzip2, gzip or zip files
+# Extracts bzip2, gzip or zip files.
 # Extracts can be defined in code like so:
 # fn_dl_extract "${local_filedir}" "${local_filename}" "${extractdir}"
 # fn_dl_extract "/home/gameserver/lgsm/tmp" "file.tar.bz2" "/home/gamserver/serverfiles"
@@ -52,7 +68,7 @@ fn_dl_extract(){
 	local_filedir="${1}"
 	local_filename="${2}"
 	extractdir="${3}"
-	# extracts archives
+	# Extracts archives.
 	echo -en "extracting ${local_filename}..."
 	mime=$(file -b --mime-type "${local_filedir}/${local_filename}")
 	if [ ! -d "${extractdir}" ]; then
@@ -70,7 +86,7 @@ fn_dl_extract(){
 	local exitcode=$?
 	if [ ${exitcode} -ne 0 ]; then
 		fn_print_fail_eol_nl
-		fn_script_log_fatal "Extracting download: FAIL"
+		fn_script_log_fatal "Extracting download"
 		if [ -f "${lgsmlog}" ]; then
 			echo "${extractcmd}" >> "${lgsmlog}"
 		fi
@@ -78,11 +94,11 @@ fn_dl_extract(){
 		core_exit.sh
 	else
 		fn_print_ok_eol_nl
-		fn_script_log_pass "Extracting download: OK"
+		fn_script_log_pass "Extracting download"
 	fi
 }
 
-# Trap to remove file download if canceled before completed
+# Trap to remove file download if canceled before completed.
 fn_fetch_trap(){
 	echo ""
 	echo -en "downloading ${local_filename}..."
@@ -105,19 +121,20 @@ fn_fetch_file(){
 	forcedl="${6:-0}"
 	md5="${7:-0}"
 
-	# Download file if missing or download forced
+	# Download file if missing or download forced.
 	if [ ! -f "${local_filedir}/${local_filename}" ]||[ "${forcedl}" == "forcedl" ]; then
 		if [ ! -d "${local_filedir}" ]; then
 			mkdir -p "${local_filedir}"
 		fi
-		# Trap will remove part downloaded files if canceled
+		# Trap will remove part downloaded files if canceled.
 		trap fn_fetch_trap INT
-		# larger files show a progress bar
+		# Larger files show a progress bar.
 		if [ "${local_filename##*.}" == "bz2" ]||[ "${local_filename##*.}" == "gz" ]||[ "${local_filename##*.}" == "zip" ]||[ "${local_filename##*.}" == "jar" ]||[ "${local_filename##*.}" == "xz" ]; then
 			echo -en "downloading ${local_filename}..."
 			sleep 0.5
-			echo -en "downloading ${local_filename}..."
+			echo -en "\033[1K"
 			curlcmd=$(${curlpath} --progress-bar --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}")
+			echo -en "downloading ${local_filename}..."
 		else
 			echo -en "    fetching ${local_filename}...\c"
 			curlcmd=$(${curlpath} -s --fail -L -o "${local_filedir}/${local_filename}" "${remote_fileurl}" 2>&1)
@@ -126,7 +143,7 @@ fn_fetch_file(){
 		if [ ${exitcode} -ne 0 ]; then
 			fn_print_fail_eol_nl
 			if [ -f "${lgsmlog}" ]; then
-				fn_script_log_fatal "Downloading ${local_filename}: FAIL"
+				fn_script_log_fatal "Downloading ${local_filename}"
 				echo -e "${remote_fileurl}" >> "${lgsmlog}"
 				echo "${curlcmd}" >> "${lgsmlog}"
 			fi
@@ -136,12 +153,12 @@ fn_fetch_file(){
 		else
 			fn_print_ok_eol_nl
 			if [ -f "${lgsmlog}" ]; then
-				fn_script_log_pass "Downloading ${local_filename}: OK"
+				fn_script_log_pass "Downloading ${local_filename}"
 			fi
 		fi
-		# Remove trap
+		# Remove trap.
 		trap - INT
-		# Make file executable if chmodx is set
+		# Make file executable if chmodx is set.
 		if [ "${chmodx}" == "chmodx" ]; then
 			chmod +x "${local_filedir}/${local_filename}"
 		fi
@@ -149,15 +166,15 @@ fn_fetch_file(){
 
 	if [ -f "${local_filedir}/${local_filename}" ]; then
 		fn_dl_md5
-		# Execute file if run is set
+		# Execute file if run is set.
 		if [ "${run}" == "run" ]; then
 			source "${local_filedir}/${local_filename}"
 		fi
 	fi
 }
 
-# GitHub file download functions
-# Used to simplify downloading specific files from GitHub
+# GitHub file download functions.
+# Used to simplify downloading specific files from GitHub.
 
 # github_file_url_dir: the directory of the file in the GitHub: lgsm/functions
 # github_file_url_name: the filename of the file to download from GitHub: core_messages.sh
@@ -171,7 +188,7 @@ fn_fetch_file(){
 # forcedl: Optional, force re-download of file even if exists
 # md5: Optional, set an md5 sum and will compare it against the file.
 
-# Fetches any files from the GitHub repo
+# Fetches any files from the GitHub repo.
 fn_fetch_file_github(){
 	github_file_url_dir="${1}"
 	github_file_url_name="${2}"
@@ -184,7 +201,7 @@ fn_fetch_file_github(){
 	run="${5:-0}"
 	forcedl="${6:-0}"
 	md5="${7:-0}"
-	# Passes vars to the file download function
+	# Passes vars to the file download function.
 	fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
 }
 
@@ -200,11 +217,11 @@ fn_fetch_config(){
 	run="norun"
 	forcedl="noforce"
 	md5="nomd5"
-	# Passes vars to the file download function
+	# Passes vars to the file download function.
 	fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
 }
 
-# Fetches functions
+# Fetches functions.
 fn_fetch_function(){
 	github_file_url_dir="lgsm/functions"
 	github_file_url_name="${functionfile}"
@@ -217,7 +234,7 @@ fn_fetch_function(){
 	run="run"
 	forcedl="noforce"
 	md5="nomd5"
-	# Passes vars to the file download function
+	# Passes vars to the file download function.
 	fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
 }
 
@@ -237,7 +254,7 @@ fn_update_function(){
 	fn_fetch_file "${remote_fileurl}" "${local_filedir}" "${local_filename}" "${chmodx}" "${run}" "${forcedl}" "${md5}"
 }
 
-# Defines curl path
+# Defines curl path.
 curlpath=$(command -v curl 2>/dev/null)
 
 if [ "$(basename "${curlpath}")" != "curl" ]; then

+ 0 - 1
lgsm/functions/core_exit.sh

@@ -37,7 +37,6 @@ elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
 	trap - INT
 	exit "${exitcode}"
 else
-	exitcode=0
 	fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
 	fn_exit_dev_debug
 	# remove trap.

+ 5 - 0
lgsm/functions/core_messages.sh

@@ -318,6 +318,11 @@ fn_print_fail_eol_nl(){
 	echo -e "${red}FAIL${default}"
 }
 
+# ERROR
+fn_print_error_eol(){
+	echo -en "${red}ERROR${default}"
+}
+
 # WARN
 fn_print_warn_eol(){
 	echo -en "${red}WARN${default}"

+ 0 - 1
lgsm/functions/fix.sh

@@ -29,7 +29,6 @@ fn_fix_msg_end(){
 	if [ $? -ne 0 ]; then
 		fn_print_error_nl "Applying ${fixname} fix: ${gamename}"
 		fn_script_log_error "Applying ${fixname} fix: ${gamename}"
-		exitcode=2
 	else
 		fn_print_ok_nl "Applying ${fixname} fix: ${gamename}"
 		fn_script_log_pass "Applying ${fixname} fix: ${gamename}"

+ 1 - 1
lgsm/functions/fix_dst.sh

@@ -10,7 +10,7 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer)
 # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS.
-if [ -f "/etc/redhat-release" ] && [ ! -f "${serverfiles}/bin/lib32/libcurl-gnutls.so.4" ]; then
+if [ -f "/etc/redhat-release" ]&&[ ! -f "${serverfiles}/bin/lib32/libcurl-gnutls.so.4" ]; then
 	fixname="libcurl-gnutls.so.4 missing"
 	fn_fix_msg_start
 	ln -s "/usr/lib/libcurl.so.4" "${serverfiles}/bin/lib32/libcurl-gnutls.so.4"

+ 1 - 1
lgsm/functions/fix_tf2.sh

@@ -9,7 +9,7 @@ local commandaction="Fix"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 # Fixes: Team Fortress 2 Segmentation fault for Red-Hat Distros #2062.
-if [ -f "/etc/redhat-release" ] && [ ! -f "${serverfiles}/bin/libcurl-gnutls.so.4" ]; then
+if [ -f "/etc/redhat-release" ]&&[ ! -f "${serverfiles}/bin/libcurl-gnutls.so.4" ]; then
 	fixname="libcurl-gnutls.so.4 missing"
 	fn_fix_msg_start
 	ln -s "/usr/lib/libcurl.so.4" "${serverfiles}/bin/libcurl-gnutls.so.4"

+ 1 - 1
lgsm/functions/info_distro.sh

@@ -224,7 +224,7 @@ fi
 
 # Steam Master Server - checks if detected by master server
 if [ ! "$(command -v jq 2>/dev/null)" ]; then
-	if [ "${ip}" ] && [ "${port}" ]; then
+	if [ "${ip}" ]&&[ "${port}" ]; then
 		if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${shortname}" == "jc2" ]||[ "${shortname}" == "ql" ]; then
 			masterserver=$(${curlpath} -s 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr='${ip}':'${port}'&format=json' | jq '.response.servers[]|.addr' | wc -l)
 			if [ "${steammaster}" == "1" ]; then

+ 1 - 1
lgsm/functions/info_messages.sh

@@ -1059,7 +1059,7 @@ fn_info_message_unreal(){
 		if [ "${engine}" == "unreal" ]; then
 			echo -e "< UdpLink Port (random)\tOUTBOUND\t${udplinkport}+\tudp"
 		fi
-		if [ "${engine}" != "unreal" ] && [ "${appid}" != "223250" ]; then
+		if [ "${engine}" != "unreal" ]&&[ "${appid}" != "223250" ]; then
 			echo -e "> GameSpy query\tINBOUND\t${gsqueryport}\tudp\tOldQueryPortNumber=${gsqueryport}"
 		fi
 		if [ "${appid}" == "215360" ]; then

+ 5 - 5
lgsm/functions/install_server_files.sh

@@ -90,7 +90,7 @@ fn_install_server_files_steamcmd(){
 
 			if [ "${counter}" -le "4" ]; then
 				if [ "${appid}" == "90" ]; then
-					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit
+					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit
 					local exitcode=$?
 				else
 					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${branch} +quit
@@ -98,7 +98,7 @@ fn_install_server_files_steamcmd(){
 				fi
 			elif [ "${counter}" -ge "5" ]; then
 				if [ "${engine}" == "goldsource" ]; then
-					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} validate +quit
+					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} validate +quit
 					local exitcode=$?
 				else
 					${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${branch} validate +quit
@@ -119,7 +119,7 @@ fn_install_server_files_steamcmd(){
 		counter="0"
 		while [ "${counter}" -le "4" ]; do
 			counter=$((counter+1))
-			${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod ${appidmod} +app_update "${appid}" ${branch} validate +quit
+			${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" ${branch} validate +quit
 			local exitcode=$?
 		done
 	fi
@@ -144,8 +144,8 @@ elif [ "${shortname}" == "mumble" ]; then
 elif [ "${shortname}" == "mta" ]; then
 	update_mta.sh
 elif [ "${shortname}" == "fctr" ]; then
-  update_factorio.sh
-  install_factorio_save.sh
+	update_factorio.sh
+	install_factorio_save.sh
 elif [ -z "${appid}" ]||[ "${shortname}" == "ges" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "vs" ]; then
 	if [ "${shortname}" == "ut" ]; then
 		install_unreal_tournament_eula.sh

+ 1 - 1
lgsm/functions/logs.sh

@@ -17,7 +17,7 @@ fi
 
 # For games not displaying a console, and having logs into their game directory
 check_status.sh
-if [ "${status}" != "0" ] && [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then
+if [ "${status}" != "0" ]&&[ "${function_selfname}" == "command_start.sh" ]&&[ -n "${gamelogfile}" ]; then
 	if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then
 		fn_print_info "Moving game logs to ${gamelogdir}"
 		fn_script_log_info "Moving game logs to ${gamelogdir}"

+ 1 - 2
lgsm/functions/mods_core.sh

@@ -6,7 +6,7 @@
 # Description: Core functions for mods list/install/update/remove
 
 local commandname="MODS"
-local commandaction="addons/mods"
+local commandaction="Mods"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 # Files and Directories
@@ -179,7 +179,6 @@ fn_mod_get_info(){
 	if [ "${modinfocommand}" == "0" ]; then
 		fn_script_log_error "Could not find information for ${currentmod}"
 		fn_print_error_nl "Could not find information for ${currentmod}"
-		exitcode="1"
 		core_exit.sh
 	fi
 }

+ 94 - 92
lgsm/functions/update_factorio.sh

@@ -1,7 +1,6 @@
 #!/bin/bash
 # LinuxGSM update_factorio.sh function
 # Author: Daniel Gibbs
-# Contributor: Kristian Polso
 # Website: https://linuxgsm.com
 # Description: Handles updating of Factorio servers.
 
@@ -10,121 +9,115 @@ local commandaction="Update"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 fn_update_factorio_dl(){
-	fn_fetch_file "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" "${tmpdir}" "factorio_headless_${factorioarch}-${availablebuild}.tar.xz"
-	fn_dl_extract "${tmpdir}" "factorio_headless_${factorioarch}-${availablebuild}.tar.xz" "${tmpdir}"
+	fn_fetch_file "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuild}.tar.xz"
+	fn_dl_extract "${tmpdir}" "factorio_headless_${factorioarch}-${remotebuild}.tar.xz" "${tmpdir}"
 	echo -e "copying to ${serverfiles}...\c"
-	fn_script_log "Copying to ${serverfiles}"
 	cp -R "${tmpdir}/factorio/"* "${serverfiles}"
 	local exitcode=$?
 	if [ "${exitcode}" == "0" ]; then
 		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		fn_clear_tmp
 	else
 		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
 	fi
 }
 
-fn_update_factorio_currentbuild(){
-	# Get current build info.
-	# If log file is missing, the server will restart to generate logs.
-
-	if [ -f "${serverfiles}/factorio-current.log" ]; then
-		currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
+fn_update_factorio_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	# Uses executable to find local build.
+	cd "${executabledir}" || exit
+	if [ -f "${executable}" ]; then
+		localbuild=$(${executable} --version | grep "Version:" | awk '{print $2}')
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
+	else
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_error "Checking local build"
 	fi
+	sleep 0.5
+}
 
-	if [ -z "${currentbuild}" ]; then
-		fn_print_error "Checking for update: factorio.com"
-		sleep 0.5
-		if [ ! -f "${serverfiles}/factorio-current.log" ]; then
-			fn_print_error_nl "Checking for update: factorio.com: No logs with server version found"
-			fn_script_log_error "Checking for update: factorio.com: No logs with server version found"
-		elif [ -z "${currentbuild}" ]; then	
-			fn_print_error_nl "Checking for update: factorio.com: Current build version not found"
-			fn_script_log_error "Checking for update: factorio.com: Current build version not found"
-		fi
-		sleep 0.5
-		fn_print_info_nl "Checking for update: factorio.com: Forcing server restart"
-		fn_script_log_info "Checking for update: factorio.com: Forcing server restart"
+fn_update_factorio_remotebuild(){
+	# Gets remote build info.
+	remotebuild=$(${curlpath} -s "https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch}" | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
 		sleep 0.5
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		sleep 0.5
-
-		# Check again and exit if failure.
-		if [ -f "${serverfiles}/factorio-current.log" ]; then
-			currentbuild=$(grep "Loading mod base" "${serverfiles}/factorio-current.log" 2> /dev/null | awk '{print $5}' | tail -1)
-		fi	
-
-		if [ ! -f "${serverfiles}/factorio-current.log" ]; then
-			fn_print_fail_nl "Checking for update: factorio.com: Still No logs with server version found"
-			fn_script_log_fatal "Checking for update: factorio.com: Still No logs with server version found"
-			core_exit.sh
-		elif [ -z "${currentbuild}" ]; then
-			fn_print_fail_nl "Checking for update: factorio.com: Current build version still not found"
-			fn_script_log_fatal "Checking for update: factorio.com: Current build version still not found"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
 			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
 		fi
-	fi
-}
-
-fn_update_factorio_availablebuild(){
-	# Gets latest build info.
-		availablebuild=$(${curlpath} -s https://factorio.com/get-download/${downloadbranch}/headless/${factorioarch} | grep -o '[0-9]\.[0-9]\{1,\}\.[0-9]\{1,\}' | head -1)
-	
-	# Checks if availablebuild variable has been set.
-	if [ -v "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: factorio.com"
-		sleep 0.5
-		fn_print_fail "Checking for update: factorio.com: Not returning version info"
-		fn_script_log_fatal "Failure! Checking for update: factorio.com: Not returning version info"
-		core_exit.sh
-	elif [ "${installer}" == "1" ]; then
-		:
 	else
-		fn_print_ok "Checking for update: factorio.com"
-		fn_script_log_pass "Checking for update: factorio.com"
-		sleep 0.5
-	fi
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
 }
 
 fn_update_factorio_compare(){
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
 	# Removes dots so if statement can compare version numbers.
-	currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
-	availablebuilddigit=$(echo "${availablebuild}" | tr -cd '[:digit:]')
-
-	if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
+	localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
 		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild} ${factorioarch} ${branch} ${default}"
-		echo -e "	Available build: ${green}${availablebuild} ${factorioarch} ${branch}${default}"
-		echo -e ""
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild} ${factorioarch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${factorioarch}${default}"
+		if [ -v "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild} ${factorioarch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${factorioarch}"
+		if [ -v "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
+		fn_script_log_info "${localbuild} > ${remotebuild}"
 		sleep 0.5
-		echo -en "Applying update.\r"
+		echo -en "\n"
+		echo -en "applying update.\r"
 		sleep 1
-		echo -en "Applying update..\r"
+		echo -en "applying update..\r"
 		sleep 1
-		echo -en "Applying update...\r"
+		echo -en "applying update...\r"
 		sleep 1
 		echo -en "\n"
-		fn_script_log "Update available"
-		fn_script_log "Current build: ${currentbuild} ${factorioarch}${branch}"
-		fn_script_log "Available build: ${availablebuild} ${factorioarch}${branch}"
-		fn_script_log "${currentbuild} > ${availablebuild}"
 
 		unset updateonstart
 
 		check_status.sh
+		# If server stopped.
 		if [ "${status}" == "0" ]; then
+			exitbypass=1
 			fn_update_factorio_dl
 			exitbypass=1
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
+		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
+			exitbypass=1
 			fn_update_factorio_dl
 			exitbypass=1
 			command_start.sh
@@ -132,18 +125,28 @@ fn_update_factorio_compare(){
 		alert="update"
 		alert.sh
 	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current build: ${green}${currentbuild} ${factorioarch} ${branch}${default}"
-		echo -e "	Available build: ${green}${availablebuild} ${factorioarch} ${branch}${default}"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_script_log_info "Current build: ${currentbuild} ${factorioarch} ${branch}"
-		fn_script_log_info "Available build: ${availablebuild} ${factorioarch} ${branch}"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild} ${factorioarch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${factorioarch}${default}"
+		if [ -v "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild} ${factorioarch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${factorioarch}"
+		if [ -v "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
 	fi
 }
 
-# Factorio is linux64 only for now.
+# The location where the builds are checked and downloaded.
+remotelocation="mojang.com"
+
+# Game server architecture.
 factorioarch="linux64"
 
 if [ "${branch}" == "stable" ]; then
@@ -153,14 +156,13 @@ elif [ "${branch}" == "experimental" ]; then
 fi
 
 if [ "${installer}" == "1" ]; then
-	fn_update_factorio_availablebuild
+	fn_update_factorio_remotebuild
 	fn_update_factorio_dl
 else
-	# Checks for server update from factorio.com
-	fn_print_dots "Checking for update: factorio.com"
-	fn_script_log_info "Checking for update: factorio.com"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
 	sleep 0.5
-	fn_update_factorio_currentbuild
-	fn_update_factorio_availablebuild
+	fn_update_factorio_localbuild
+	fn_update_factorio_remotebuild
 	fn_update_factorio_compare
 fi

+ 140 - 91
lgsm/functions/update_minecraft.sh

@@ -8,151 +8,200 @@ local commandname="UPDATE"
 local commandaction="Update"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-fn_update_dl(){
+fn_update_minecraft_dl(){
 	latestmcreleaselink=$(${curlpath} -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | jq -r '.latest.release as $latest | .versions[] | select(.id == $latest) | .url')
 	latestmcbuildurl=$(${curlpath} -s "${latestmcreleaselink}" | jq -r '.downloads.server.url')
-	fn_fetch_file "${latestmcbuildurl}" "${tmpdir}" "minecraft_server.${availablebuild}.jar"
+	fn_fetch_file "${latestmcbuildurl}" "${tmpdir}" "minecraft_server.${remotebuild}.jar"
 	echo -e "copying to ${serverfiles}...\c"
-	fn_script_log "Copying to ${serverfiles}"
-	cp "${tmpdir}/minecraft_server.${availablebuild}.jar" "${serverfiles}/minecraft_server.jar"
+	cp "${tmpdir}/minecraft_server.${remotebuild}.jar" "${serverfiles}/minecraft_server.jar"
 	local exitcode=$?
-	chmod u+x "${serverfiles}/minecraft_server.jar"
-	if [ ${exitcode} -eq 0 ]; then
+	if [ "${exitcode}" == "0" ]; then
 		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		chmod u+x "${serverfiles}/minecraft_server.jar"
+		fn_clear_tmp
 	else
 		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
 	fi
 }
 
-fn_update_currentbuild(){
-	# Gets current build info
-	# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
-	if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then
-		fn_print_error "Checking for update: mojang.com"
+fn_update_minecraft_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	# Uses log file to gather info.
+	# Gives time for log file to generate.
+	if [ ! -f "${serverfiles}/logs/latest.log" ]; then
+		fn_print_error "Checking for update: ${remotelocation}: checking local build"
 		sleep 0.5
-		fn_print_error_nl "Checking for update: mojang.com: No logs with server version found"
-		fn_script_log_error "Checking for update: mojang.com: No logs with server version found"
+		fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files"
+		fn_script_log_error "No log file found"
 		sleep 0.5
-		fn_print_info_nl "Checking for update: mojang.com: Forcing server restart"
-		fn_script_log_info "Checking for update: mojang.com: Forcing server restart"
+		fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart"
+		fn_script_log_info "Forcing server restart"
 		sleep 0.5
 		exitbypass=1
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		sleep 0.5
-		# Check again and exit on failure.
-		if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then
-			fn_print_fail_nl "Checking for update: mojang.com: Still No logs with server version found"
-			fn_script_log_fatal "Checking for update: mojang.com: Still No logs with server version found"
-			core_exit.sh
-		fi
+		totalseconds=0
+		# Check again, allow time to generate logs.
+		while [ ! -f "${serverfiles}/logs/latest.log" ]; do
+			sleep 1
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}"
+			if [ -v "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for log file to generate"
+			fi
+
+			if [ "${totalseconds}" -gt "120" ]; then
+				localbuild="0"
+				fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file"
+				fn_script_log_error "Missing log file"
+				fn_script_log_error "Set localbuild to 0"
+				sleep 0.5
+			fi
+			
+			totalseconds=$((totalseconds + 1))
+		done
 	fi
 
-	# Get current build from logs
-	currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
-	if [ -z "${currentbuild}" ]; then
-		fn_print_error_nl "Checking for update: mojang.com: Current build version not found"
-		fn_script_log_error "Checking for update: mojang.com: Current build version not found"
-		sleep 0.5
-		fn_print_info_nl "Checking for update: mojang.com: Forcing server restart"
-		fn_script_log_info "Checking for update: mojang.com: Forcing server restart"
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		currentbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
-		if [ -z "${currentbuild}" ]; then
-			fn_print_fail_nl "Checking for update: mojang.com: Current build version still not found"
-			fn_script_log_fatal "Checking for update: mojang.com: Current build version still not found"
-			core_exit.sh
-		fi
+	if [ -z "${localbuild}" ]; then
+		localbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}')
 	fi
-}
 
-fn_update_availablebuild(){
-	# Gets latest build info.
-	availablebuild=$(${curlpath} -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | jq -r '.latest.release')
-	# Checks if availablebuild variable has been set
-	if [ -z "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: mojang.com"
-		sleep 0.5
-		fn_print_fail "Checking for update: mojang.com: Not returning version info"
-		fn_script_log_fatal "Failure! Checking for update: mojang.com: Not returning version info"
-		core_exit.sh
-	elif [ "${installer}" == "1" ]; then
-		:
+	if [ -z "${localbuild}" ]; then
+		# Gives time for var to generate.
+		end=$((SECONDS+120))
+		totalseconds=0
+		while [ "${SECONDS}" -lt "${end}" ]; do
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}"
+			if [ -z "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for local build to generate"
+			fi		
+			localbuild=$(cat "${serverfiles}/logs/latest.log" 2> /dev/null | grep version | grep -Eo '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}")
+			if [ "${localbuild}" ]; then
+				break
+			fi
+			sleep 1
+			totalseconds=$((totalseconds + 1))
+		done
+	fi
+	
+	if [ -z "${localbuild}" ]; then
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info"
+		fn_script_log_error "Missing local build info"
+		fn_script_log_error "Set localbuild to 0"
 	else
-		fn_print_ok_nl "Checking for update: mojang.com"
-		fn_script_log_pass "Checking for update: mojang.com"
-		sleep 0.5
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
 	fi
+	sleep 0.5
 }
 
-fn_update_compare(){
-	# Removes dots so if can compare version numbers
-	currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
-	availablebuilddigit=$(echo "${availablebuild}" | tr -cd '[:digit:]')
+fn_update_minecraft_remotebuild(){
+	# Gets remote build info.
+	remotebuild=$(${curlpath} -s "https://launchermeta.${remotelocation}/mc/game/version_manifest.json" | jq -r '.latest.release')
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
+		sleep 0.5
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
+}
 
-	if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
+fn_update_minecraft_compare(){
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
 		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild}${default}"
-		echo -e "	Available build: ${green}${availablebuild}${default}"
-		echo -e ""
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
 		sleep 0.5
-		echo -en "Applying update.\r"
+		echo -en "\n"
+		echo -en "applying update.\r"
 		sleep 1
-		echo -en "Applying update..\r"
+		echo -en "applying update..\r"
 		sleep 1
-		echo -en "Applying update...\r"
+		echo -en "applying update...\r"
 		sleep 1
 		echo -en "\n"
-		fn_script_log "Update available"
-		fn_script_log "Current build: ${currentbuild}"
-		fn_script_log "Available build: ${availablebuild}"
-		fn_script_log "${currentbuild} > ${availablebuild}"
 
 		unset updateonstart
 
 		check_status.sh
+		# If server stopped.
 		if [ "${status}" == "0" ]; then
-			fn_update_dl
+			exitbypass=1
+			fn_update_minecraft_dl
 			exitbypass=1
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
+		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
-			fn_update_dl
+			exitbypass=1
+			fn_update_minecraft_dl
 			exitbypass=1
 			command_start.sh
 		fi
 		alert="update"
 		alert.sh
 	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: ${green}${currentbuild}${default}"
-		echo -e "	Available version: ${green}${availablebuild}${default}"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${availablebuild}"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
 	fi
 }
 
+# The location where the builds are checked and downloaded.
+remotelocation="mojang.com"
+
 if [ "${installer}" == "1" ]; then
-	fn_update_availablebuild
-	fn_update_dl
+	fn_update_minecraft_remotebuild
+	fn_update_minecraft_dl
 else
-	# Checks for server update from mojang.com
-	fn_print_dots "Checking for update: mojang.com"
-	fn_script_log_info "Checking for update: mojang.com"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
 	sleep 0.5
-	fn_update_currentbuild
-	fn_update_availablebuild
-	fn_update_compare
+	fn_update_minecraft_localbuild
+	fn_update_minecraft_remotebuild
+	fn_update_minecraft_compare
 fi

+ 137 - 74
lgsm/functions/update_mta.sh

@@ -13,113 +13,174 @@ fn_update_mta_dl(){
 	mkdir "${tmpdir}/multitheftauto_linux_x64-${fullversion}"
 	fn_dl_extract "${tmpdir}" "multitheftauto_linux_x64-${fullversion}.tar.gz" "${tmpdir}/multitheftauto_linux_x64-${fullversion}"
 	echo -e "copying to ${serverfiles}...\c"
-	fn_script_log "Copying to ${serverfiles}"
 	cp -R "${tmpdir}/multitheftauto_linux_x64-${fullversion}/multitheftauto_linux_x64-${fullversion}/"* "${serverfiles}"
 	local exitcode=$?
 	if [ "${exitcode}" == "0" ]; then
 		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		chmod u+x "${serverfiles}/minecraft_server.jar"
+		fn_clear_tmp
 	else
 		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
 	fi
 }
 
-fn_update_mta_currentbuild(){
-	# Gets current build info
-	# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
-	if [ ! -f "${gamelogdir}"/server.log ]; then
-		fn_print_error "Checking for update: linux.mtasa.com"
+fn_update_mta_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	# Uses log file to gather info.
+	# Gives time for log file to generate.
+	if [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; then
+		fn_print_error "Checking for update: ${remotelocation}: checking local build"
 		sleep 0.5
-		fn_print_error_nl "Checking for update: linux.mtasa.com: No logs with server version found"
-		fn_script_log_error "Checking for update: linux.mtasa.com: No logs with server version found"
+		fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files"
+		fn_script_log_error "No log file found"
 		sleep 0.5
-		fn_print_info_nl "Checking for update: linux.mtasa.com: Forcing server restart"
-		fn_script_log_info "Checking for update: linux.mtasa.com: Forcing server restart"
+		fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart"
+		fn_script_log_info "Forcing server restart"
 		sleep 0.5
 		exitbypass=1
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		sleep 0.5
-		# Check again and exit on failure.
-		if [ ! -f "${gamelogdir}"/server.log ]; then
-			fn_print_fail_nl "Checking for update: linux.mtasa.com: Still No logs with server version found"
-			fn_script_log_fatal "Checking for update: linux.mtasa.com: Still No logs with server version found"
-			core_exit.sh
-		fi
+		totalseconds=0
+		# Check again, allow time to generate logs.
+		while [ ! -f "${serverfiles}/mods/deathmatch/logs/server.log" ]; do
+			sleep 1
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}"
+			if [ -v "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for log file to generate"
+			fi
+
+			if [ "${totalseconds}" -gt "120" ]; then
+				localbuild="0"
+				fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file"
+				fn_script_log_error "Missing log file"
+				fn_script_log_error "Set localbuild to 0"
+				sleep 0.5
+			fi
+			
+			totalseconds=$((totalseconds + 1))
+		done
 	fi
 
-	# Get current build from logs
-	currentbuild=$(grep "= Multi Theft Auto: San Andreas v" "${gamelogdir}/server.log" | awk '{ print $7 }' | sed -r 's/^.{1}//' | tail -1)
-	if [ -z "${currentbuild}" ]; then
-		fn_print_error_nl "Checking for update: linux.mtasa.com: Current build version not found"
-		fn_script_log_error "Checking for update: linux.mtasa.com: Current build version not found"
-		sleep 0.5
-		fn_print_info_nl "Checking for update: linux.mtasa.com: Forcing server restart"
-		fn_script_log_info "Checking for update: linux.mtasa.com: Forcing server restart"
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		currentbuild=$(grep "= Multi Theft Auto: San Andreas v" "${gamelogdir}/server.log" | awk '{ print $7 }' | sed -r 's/^.{1}//' | tail -1)
-		if [ -z "${currentbuild}" ]; then
-			fn_print_fail_nl "Checking for update: linux.mtasa.com: Current build version still not found"
-			fn_script_log_fatal "Checking for update: linux.mtasa.com: Current build version still not found"
-			core_exit.sh
-		fi
+	if [ -z "${localbuild}" ]; then
+		localbuild=$(grep "= Multi Theft Auto: San Andreas v" "${serverfiles}/mods/deathmatch/logs/server.log" | awk '{ print $7 }' | sed -r 's/^.{1}//' | tail -1)
+	fi
+
+	if [ -z "${localbuild}" ]; then
+		# Gives time for var to generate.
+		end=$((SECONDS+120))
+		totalseconds=0
+		while [ "${SECONDS}" -lt "${end}" ]; do
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}"
+			if [ -z "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for local build to generate"
+			fi		
+			localbuild=$(grep "= Multi Theft Auto: San Andreas v" "${serverfiles}/mods/deathmatch/logs/server.log" | awk '{ print $7 }' | sed -r 's/^.{1}//' | tail -1)
+			if [ "${localbuild}" ]; then
+				break
+			fi
+			sleep 1
+			totalseconds=$((totalseconds + 1))
+		done
+	fi
+	
+	if [ -z "${localbuild}" ]; then
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info"
+		fn_script_log_error "Missing local build info"
+		fn_script_log_error "Set localbuild to 0"
+	else
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
 	fi
+	sleep 0.5
 }
 
-fn_mta_get_availablebuild(){
-	fn_fetch_file "https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h" "${tmpdir}" "version.h" # we need to find latest stable version here
-	local majorversion="$(grep "#define MTASA_VERSION_MAJOR" "${tmpdir}/version.h" | awk '{ print $3 }' | sed 's/\r//g')"
-	local minorversion="$(grep "#define MTASA_VERSION_MINOR" "${tmpdir}/version.h" | awk '{ print $3 }' | sed 's/\r//g')"
-	local maintenanceversion="$(grep "#define MTASA_VERSION_MAINTENANCE" "${tmpdir}/version.h" | awk '{ print $3 }' | sed 's/\r//g')"
-	numversion="${majorversion}${minorversion}${maintenanceversion}"
-	fullversion="${majorversion}.${minorversion}.${maintenanceversion}"
-	rm -f "${tmpdir}/version.h"
+fn_update_mta_remotebuild(){
+	# Gets remote build info.
+	local majorversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAJOR" | awk '{ print $3 }' | sed 's/\r//g')"
+	local minorversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MINOR" | awk '{ print $3 }' | sed 's/\r//g')"
+	local maintenanceversion="$(curl -s https://raw.githubusercontent.com/multitheftauto/mtasa-blue/master/Server/version.h | grep "#define MTASA_VERSION_MAINTENANCE" | awk '{ print $3 }' | sed 's/\r//g')"
+	remotebuild="${majorversion}.${minorversion}.${maintenanceversion}"
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
+		sleep 0.5
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
 }
 
 fn_update_mta_compare(){
-	# Removes dots so if can compare version numbers
-	currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
-	if [ "${currentbuilddigit}" -ne "${numversion}" ]||[ "${forceupdate}" == "1" ]; then
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
 		if [ "${forceupdate}" == "1" ]; then
 			# forceupdate bypasses checks, useful for small build changes
-			mta_update_string="forced"
+			mtaupdatestatus="forced"
 		else
-			mta_update_string="available"
+			mtaupdatestatus="available"
 		fi
-		echo -e "\n"
-		echo -e "Update ${mta_update_string}:"
 		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild} ${default}"
-		echo -e "	Available build: ${green}${fullversion} ${default}"
-		echo -e ""
+		echo -en "\n"
+		echo -e "Update ${mtaupdatestatus}:"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
 		sleep 0.5
-		echo -en "Applying update.\r"
+		echo -en "\n"
+		echo -en "applying update.\r"
 		sleep 1
-		echo -en "Applying update..\r"
+		echo -en "applying update..\r"
 		sleep 1
-		echo -en "Applying update...\r"
+		echo -en "applying update...\r"
 		sleep 1
 		echo -en "\n"
-		fn_script_log "Update ${mta_update_string}"
-		fn_script_log "Current build: ${currentbuild}"
-		fn_script_log "Available build: ${fullversion}"
-		fn_script_log "${currentbuild} > ${fullversion}"
 
 		unset updateonstart
 
 		check_status.sh
+		# If server stopped.
 		if [ "${status}" == "0" ]; then
+			exitbypass=1
 			fn_update_mta_dl
 			exitbypass=1
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
+		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
+			exitbypass=1
 			fn_update_mta_dl
 			exitbypass=1
 			command_start.sh
@@ -127,27 +188,29 @@ fn_update_mta_compare(){
 		alert="update"
 		alert.sh
 	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "       Current version: ${green}${currentbuild}${default}"
-		echo -e "       Available version: ${green}${fullversion}${default}"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${fullversion}"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
 	fi
 }
 
+# The location where the builds are checked and downloaded.
+remotelocation="linux.mtasa.com"
 
 if [ "${installer}" == "1" ]; then
-	fn_mta_get_availablebuild
+	fn_update_mta_remotebuild
 	fn_update_mta_dl
 else
-	# Checks for server update from linux.mtasa.com using the github repo.
-	fn_print_dots "Checking for update: linux.mtasa.com"
-	fn_script_log_info "Checking for update: linux.mtasa.com"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
 	sleep 0.5
-	fn_update_mta_currentbuild
-	fn_mta_get_availablebuild
+	fn_update_mta_localbuild
+	fn_update_mta_remotebuild
 	fn_update_mta_compare
 fi

+ 88 - 103
lgsm/functions/update_mumble.sh

@@ -1,137 +1,117 @@
 #!/bin/bash
 # LinuxGSM update_mumble.sh function
 # Author: Daniel Gibbs
-# Contributor: UltimateByte
 # Website: https://linuxgsm.com
-# Description: Handles updating of mumble servers.
+# Description: Handles updating of Mumble servers.
 
 local commandname="UPDATE"
 local commandaction="Update"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 fn_update_mumble_dl(){
-	fn_fetch_file "https://github.com/mumble-voip/mumble/releases/download/${availablebuild}/murmur-static_${mumblearch}-${availablebuild}.tar.bz2" "${tmpdir}" "murmur-static_${mumblearch}-${availablebuild}.tar.bz2"
-	fn_dl_extract "${tmpdir}" "murmur-static_${mumblearch}-${availablebuild}.tar.bz2" "${tmpdir}"
+	fn_fetch_file "https://github.com/mumble-voip/mumble/releases/download/${remotebuild}/murmur-static_${mumblearch}-${remotebuild}.tar.bz2" "${tmpdir}" "murmur-static_${mumblearch}-${remotebuild}.tar.bz2"
+	fn_dl_extract "${tmpdir}" "murmur-static_${mumblearch}-${remotebuild}.tar.bz2" "${tmpdir}"
 	echo -e "copying to ${serverfiles}...\c"
-	fn_script_log "Copying to ${serverfiles}"
-	cp -R "${tmpdir}/murmur-static_${mumblearch}-${availablebuild}/"* "${serverfiles}"
+	cp -R "${tmpdir}/murmur-static_${mumblearch}-${remotebuild}/"* "${serverfiles}"
 	local exitcode=$?
-	if [ ${exitcode} -eq 0 ]; then
+	if [ "${exitcode}" == "0" ]; then
 		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		fn_clear_tmp
 	else
 		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
 	fi
 }
 
-fn_update_mumble_currentbuild(){
-	# Gets current build info
-	# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
-	if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then
-		fn_print_error "Checking for update: GitHub"
-		sleep 0.5
-		fn_print_error_nl "Checking for update: GitHub: No logs with server version found"
-		fn_script_log_error "Checking for update: GitHub: No logs with server version found"
-		sleep 0.5
-		fn_print_info_nl "Checking for update: GitHub: Forcing server restart"
-		fn_script_log_info "Checking for update: GitHub: Forcing server restart"
-		sleep 0.5
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		sleep 0.5
-		# Check again and exit on failure.
-		if [ ! -f "${consolelogdir}/${servicename}-console.log" ]; then
-			fn_print_fail_nl "Checking for update: GitHub: Still No logs with server version found"
-			fn_script_log_fatal "Checking for update: GitHub: Still No logs with server version found"
-			core_exit.sh
-		fi
+fn_update_mumble_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	# Uses executable to find local build.
+	cd "${executabledir}" || exit
+	if [ -f "${executable}" ]; then
+		localbuild=$(${executable} -version 2>&1 >/dev/null | awk '{print $5}')
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
+	else
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_error "Checking local build"
 	fi
+	sleep 0.5
+}
 
-	# Get current build from logs
-	currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | grep -E 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
-	if [ -z "${currentbuild}" ]; then
-		fn_print_error_nl "Checking for update: GitHub: Current build version not found"
-		fn_script_log_error "Checking for update: GitHub: Current build version not found"
+fn_update_mumble_remotebuild(){
+	# Gets remote build info.
+	remotebuild=$(${curlpath} -s "https://api.github.com/repos/mumble-voip/mumble/releases/latest" | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
 		sleep 0.5
-		fn_print_info_nl "Checking for update: GitHub: Forcing server restart"
-		fn_script_log_info "Checking for update: GitHub: Forcing server restart"
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		currentbuild=$(cat "${consolelogdir}"/"${servicename}"-console.log 2> /dev/null | sort | grep -E 'Murmur ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | awk '{print $4}')
-		if [ -z "${currentbuild}" ]; then
-			fn_print_fail_nl "Checking for update: GitHub: Current build version still not found"
-			fn_script_log_fatal "Checking for update: GitHub: Current build version still not found"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
 			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
 		fi
-	fi
-}
-
-fn_update_mumble_arch(){
-	# Mumble is x86 only for now
-	mumblearch="x86"
-}
-
-fn_update_mumble_availablebuild(){
-	# Gets latest build info.
-	availablebuild=$(${curlpath} -s https://api.github.com/repos/mumble-voip/mumble/releases/latest | grep 'murmur-static_x86.*\.bz2"' | tail -1 | awk -F"/" '{ print $8 }')
-	sleep 0.5
-
-	# Checks if availablebuild variable has been set
-	if [ -z "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: GitHub"
-		sleep 0.5
-		fn_print_fail "Checking for update: GitHub: Not returning version info"
-		fn_script_log_fatal "Failure! Checking for update: GitHub: Not returning version info"
-		core_exit.sh
-	elif [ "${installer}" == "1" ]; then
-		:
 	else
-		fn_print_ok "Checking for update: GitHub"
-		fn_script_log_pass "Checking for update: GitHub"
-		sleep 0.5
-	fi
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
 }
 
 fn_update_mumble_compare(){
-	# Removes dots so if can compare version numbers
-	currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
-	availablebuilddigit=$(echo "${availablebuild}" | tr -cd '[:digit:]')
-
-	if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
 		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild} ${mumblearch}${default}"
-		echo -e "	Available build: ${green}${availablebuild} ${mumblearch}${default}"
-		echo -e ""
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild} ${mumblearch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild} ${mumblearch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${mumblearch}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
 		sleep 0.5
-		echo -en "Applying update.\r"
+		echo -en "\n"
+		echo -en "applying update.\r"
 		sleep 1
-		echo -en "Applying update..\r"
+		echo -en "applying update..\r"
 		sleep 1
-		echo -en "Applying update...\r"
+		echo -en "applying update...\r"
 		sleep 1
 		echo -en "\n"
-		fn_script_log "Update available"
-		fn_script_log "Current build: ${currentbuild}"
-		fn_script_log "Available build: ${availablebuild}"
-		fn_script_log "${currentbuild} > ${availablebuild}"
 
 		unset updateonstart
 
 		check_status.sh
+		# If server stopped.
 		if [ "${status}" == "0" ]; then
+			exitbypass=1
 			fn_update_mumble_dl
 			exitbypass=1
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
+		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
+			exitbypass=1
 			fn_update_mumble_dl
 			exitbypass=1
 			command_start.sh
@@ -139,27 +119,32 @@ fn_update_mumble_compare(){
 		alert="update"
 		alert.sh
 	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: ${green}${currentbuild}${default}"
-		echo -e "	Available version: ${green}${availablebuild}${default}"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${availablebuild}"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild} ${mumblearch}${default}"
+		echo -e "* Remote build: ${green}${remotebuild} ${mumblearch}${default}"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild} ${mumblearch}"
+		fn_script_log_info "Remote build: ${remotebuild} ${mumblearch}"
 	fi
 }
 
-fn_update_mumble_arch
+# The location where the builds are checked and downloaded.
+remotelocation="mumble.info"
+
+# Game server architecture.
+mumblearch="x86"
+
 if [ "${installer}" == "1" ]; then
-	fn_update_mumble_availablebuild
+	fn_update_mumble_remotebuild
 	fn_update_mumble_dl
 else
-	# Checks for server update from github.com
-	fn_print_dots "Checking for update: github.com"
-	fn_script_log_info "Checking for update: github.com"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
 	sleep 0.5
-	fn_update_mumble_currentbuild
-	fn_update_mumble_availablebuild
+	fn_update_mumble_localbuild
+	fn_update_mumble_remotebuild
 	fn_update_mumble_compare
 fi

+ 127 - 154
lgsm/functions/update_steamcmd.sh

@@ -8,16 +8,8 @@ local commandname="UPDATE"
 local commandaction="Update"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
-check.sh
-
 fn_update_steamcmd_dl(){
 	info_config.sh
-	fn_print_dots "SteamCMD"
-	sleep 0.5
-	fn_print_ok_nl "SteamCMD"
-	fn_script_log_info "Starting SteamCMD"
-
-	cd "${steamcmddir}" || exit
 
 	# Detects if unbuffer command is available for 32 bit distributions only.
 	info_distro.sh
@@ -27,17 +19,131 @@ fn_update_steamcmd_dl(){
 
 	cd "${steamcmddir}" || exit
 	if [ "${appid}" == "90" ]; then
-		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_info_print 70 +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit | tee -a "${lgsmlog}"
+		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_set_config 90 mod "${appidmod}" +app_update "${appid}" ${branch} +quit | tee -a "${lgsmlog}"
 	else
 		${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid}" ${branch} +quit | tee -a "${lgsmlog}"
-		if [ "${gamename}" == "Classic Offensive" ]; then
-			${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${serverfiles}" +app_update "${appid_co}" ${branch} +quit | tee -a "${lgsmlog}"
-		fi
 	fi
-
 	fix.sh
 }
 
+fn_update_steamcmd_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	fn_appmanifest_check
+	# Uses appmanifest to find local build.
+	localbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
+
+	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD.
+	if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
+		rm -f "${HOME}/Steam/appcache/appinfo.vdf"
+	fi
+
+	# Set branch for updateinfo.
+	IFS=' ' read -ra branchsplits <<< "${branch}"
+	if [ "${#branchsplits[@]}" -gt 1 ]; then
+		branchname="${branchsplits[1]}"
+	else
+		branchname="public"
+	fi
+	sleep 0.5
+}
+
+fn_update_steamcmd_remotebuild(){
+	# Gets remote build info.
+	cd "${steamcmddir}" || exit
+	remotebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branchname}/d" | grep -m 1 buildid | tr -cd '[:digit:]')
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
+		sleep 0.5
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
+}
+
+fn_update_steamcmd_compare(){
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	if [ "${localbuild}" != "${remotebuild}" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		if [ -v "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		echo -e "https://steamdb.info/app/${appid}/"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		if [ -v "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
+		fn_script_log_info "${localbuild} > ${remotebuild}"
+		sleep 0.5
+		echo -en "\n"
+		echo -en "applying update.\r"
+		sleep 1
+		echo -en "applying update..\r"
+		sleep 1
+		echo -en "applying update...\r"
+		sleep 1
+		echo -en "\n"
+
+		unset updateonstart
+
+		check_status.sh
+		# If server stopped.
+		if [ "${status}" == "0" ]; then
+			fn_update_steamcmd_dl
+		# If server started.
+		else
+			exitbypass=1
+			command_stop.sh
+			exitbypass=1
+			fn_update_steamcmd_dl
+			exitbypass=1
+			command_start.sh
+		fi
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		if [ -v "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		echo -e "https://steamdb.info/app/${appid}/"	
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		if [ -v "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
+	fi
+}
+
 fn_appmanifest_info(){
 	appmanifestfile=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf")
 	appmanifestfilewc=$(find "${serverfiles}" -type f -name "appmanifest_${appid}.acf" | wc -l)
@@ -77,7 +183,6 @@ fn_appmanifest_check(){
 			fn_script_log_info "Forcing update to correct issue"
 			sleep 0.5
 			fn_update_steamcmd_dl
-			fn_update_request_log
 		fi
 	elif [ "${appmanifestfilewc}" -eq "0" ]; then
 		fn_print_error_nl "No appmanifest_${appid}.acf found"
@@ -87,7 +192,6 @@ fn_appmanifest_check(){
 		fn_script_log_info "Forcing update to correct issue"
 		sleep 0.5
 		fn_update_steamcmd_dl
-		fn_update_request_log
 		fn_appmanifest_info
 		if [ "${appmanifestfilewc}" -eq "0" ]; then
 			fn_print_fail_nl "Still no appmanifest_${appid}.acf found"
@@ -97,141 +201,13 @@ fn_appmanifest_check(){
 	fi
 }
 
-fn_update_request_log(){
-	# Checks for server update requests from server logs.
-	fn_print_dots "Checking for update: Server logs"
-	fn_script_log_info "Checking for update: Server logs"
-	sleep 0.5
-	if [ -f "${consolelog}" ]; then
-		requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}")
-	else
-		requestrestart="0"
-	fi
-	if [ "${requestrestart}" -ge "1" ]; then
-		fn_print_ok_nl "Checking for update: Server logs: Update requested"
-		fn_script_log_pass "Checking for update: Server logs: Update requested"
-		sleep 0.5
-		echo -e ""
-		echo -en "Applying update.\r"
-		sleep 1
-		echo -en "Applying update..\r"
-		sleep 1
-		echo -en "Applying update...\r"
-		sleep 1
-		echo -en "\n"
-
-		unset updateonstart
-		check_status.sh
-		if [ "${status}" != "0" ]; then
-			exitbypass=1
-			command_stop.sh
-			fn_update_steamcmd_dl
-			exitbypass=1
-			command_start.sh
-		else
-			fn_update_steamcmd_dl
-		fi
-		alert="update"
-		alert.sh
-	else
-		fn_print_ok "Checking for update: Server logs: No update requested"
-		sleep 0.5
-	fi
-}
-
-fn_update_steamcmd_check(){
-	appid="${1}"
-	fn_appmanifest_check
-	# Checks for server update from SteamCMD
-	fn_print_dots "Checking for update: SteamCMD"
-	fn_script_log_info "Checking for update: SteamCMD"
-	sleep 0.5
-
-	# Gets currentbuild
-	currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\  -f3)
-
-	# Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD
-
-	if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then
-		rm -f "${HOME}/Steam/appcache/appinfo.vdf"
-	fi
-
-	# Set branch for updateinfo
-	IFS=' ' read -ra branchsplits <<< "${branch}"
-	if [ "${#branchsplits[@]}" -gt 1 ]; then
-		branchname="${branchsplits[1]}"
-	else
-		branchname="public"
-	fi
-
-	# Gets availablebuild info
-	cd "${steamcmddir}" || exit
-	availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +quit | sed '1,/branches/d' | sed "1,/${branchname}/d" | grep -m 1 buildid | tr -cd '[:digit:]')
-	if [ -z "${availablebuild}" ]; then
-		fn_print_fail "Checking for update: SteamCMD"
-		sleep 0.5
-		fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info"
-		fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info"
-		core_exit.sh
-	else
-		fn_print_ok "Checking for update: SteamCMD"
-		fn_script_log_pass "Checking for update: SteamCMD"
-		sleep 0.5
-	fi
-
-	if [ "${currentbuild}" != "${availablebuild}" ]; then
-		fn_print_ok "Checking for update: SteamCMD: Update available"
-		fn_script_log_pass "Checking for update: SteamCMD: Update available"
-		echo -e "\n"
-		echo -e "Update available:"
-		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild}${default}"
-		echo -e "	Available build: ${green}${availablebuild}${default}"
-		echo -e "	https://steamdb.info/app/${appid}/"
-		sleep 0.5
-		echo ""
-		echo -en "Applying update.\r"
-		sleep 1
-		echo -en "Applying update..\r"
-		sleep 1
-		echo -en "Applying update...\r"
-		sleep 1
-		echo -en "\n"
-		fn_script_log_info "Update available"
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${availablebuild}"
-		fn_script_log_info "${currentbuild} > ${availablebuild}"
+# The location where the builds are checked and downloaded.
+remotelocation="SteamCMD"
 
-		unset updateonstart
-		check_status.sh
-		if [ "${status}" != "0" ]; then
-			exitbypass=1
-			command_stop.sh
-			fn_update_steamcmd_dl
-			exitbypass=1
-			command_start.sh
-		else
-			fn_update_steamcmd_dl
-		fi
-		alert="update"
-		alert.sh
-	else
-		fn_print_ok "Checking for update: SteamCMD: No update available"
-		fn_script_log_pass "Checking for update: SteamCMD: No update available"
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: ${green}${currentbuild}${default}"
-		echo -e "	Available version: ${green}${availablebuild}${default}"
-		echo -e "	https://steamdb.info/app/${appid}/"
-		echo -e ""
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${availablebuild}"
-	fi
-}
+check.sh
 
-if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
-	# Goldsource servers bypass checks as fn_update_steamcmd_check does not work for appid 90 servers.
-	# forceupdate bypasses checks
+if [ "${forceupdate}" == "1" ]; then
+	# forceupdate bypasses update checks.
 	check_status.sh
 	if [ "${status}" != "0" ]; then
 		exitbypass=1
@@ -243,10 +219,7 @@ if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then
 		fn_update_steamcmd_dl
 	fi
 else
-	fn_update_request_log
-	fn_update_steamcmd_check "${appid}"
-	# will also check for second appid
-	if [ "${gamename}" == "Classic Offensive" ]; then
-		fn_update_steamcmd_check "${appid_co}"
-	fi
+	fn_update_steamcmd_localbuild
+	fn_update_steamcmd_remotebuild
+	fn_update_steamcmd_compare
 fi

+ 146 - 103
lgsm/functions/update_ts3.sh

@@ -2,154 +2,183 @@
 # LinuxGSM command_ts3.sh function
 # Author: Daniel Gibbs
 # Website: https://linuxgsm.com
-# Description: Handles updating of teamspeak 3 servers.
+# Description: Handles updating of Teamspeak 3 servers.
 
 local commandname="UPDATE"
 local commandaction="Update"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 fn_update_ts3_dl(){
-	info_distro.sh
 	if [ "${ts3arch}" == "amd64" ]; then
-		latestts3releaselink=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"')
+		local remotebuildurl=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.mirrors."teamspeak.com"')
 	elif [ "${ts3arch}" == "x86" ]; then
-		latestts3releaselink=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.mirrors."teamspeak.com"')
+		local remotebuildurl=$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.mirrors."teamspeak.com"')
 	fi
-	fn_fetch_file "${latestts3releaselink}" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
-	fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${tmpdir}"
+	fn_fetch_file "${remotebuildurl}" "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2"
+	fn_dl_extract "${tmpdir}" "teamspeak3-server_linux_${ts3arch}-${remotebuild}.tar.bz2" "${tmpdir}"
 	echo -e "copying to ${serverfiles}...\c"
-	fn_script_log "Copying to ${serverfiles}"
 	cp -R "${tmpdir}/teamspeak3-server_linux_${ts3arch}/"* "${serverfiles}"
 	local exitcode=$?
 	if [ "${exitcode}" == "0" ]; then
 		fn_print_ok_eol_nl
+		fn_script_log_pass "Copying to ${serverfiles}"
+		fn_clear_tmp
 	else
 		fn_print_fail_eol_nl
+		fn_script_log_fatal "Copying to ${serverfiles}"
+		core_exit.sh
 	fi
 }
 
-fn_update_ts3_currentbuild(){
-	# Gets current build info
-	# Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
+fn_update_ts3_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking for update: ${remotelocation}: checking local build"
+	sleep 0.5
+	# Uses log file to gather info.
+	# Gives time for log file to generate.
 	if [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log' 2> /dev/null)" ]; then
-		fn_print_error "Checking for update: teamspeak.com"
+		fn_print_error "Checking for update: ${remotelocation}: checking local build"
 		sleep 0.5
-		fn_print_error_nl "Checking for update: teamspeak.com: No logs with server version found"
-		fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found"
+		fn_print_error_nl "Checking for update: ${remotelocation}: checking local build: no log files"
+		fn_script_log_error "No log file found"
 		sleep 0.5
-		fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
-		fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart"
+		fn_print_info_nl "Checking for update: ${remotelocation}: checking local build: forcing server restart"
+		fn_script_log_info "Forcing server restart"
 		sleep 0.5
 		exitbypass=1
 		command_stop.sh
 		exitbypass=1
 		command_start.sh
-		sleep 0.5
-		# Check again and exit on failure.
-		if [ ! -d "${serverfiles}/logs" ]||[ -z "$(find "${serverfiles}/logs/"* -name 'ts3server*_0.log')" ]; then
-			fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found"
-			fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found"
-			core_exit.sh
-		fi
+		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
+			sleep 1
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for log file: ${totalseconds}"
+			if [ -v "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for log file to generate"
+			fi
+
+			if [ "${totalseconds}" -gt "120" ]; then
+				localbuild="0"
+				fn_print_error "Checking for update: ${remotelocation}: waiting for log file: missing log file"
+				fn_script_log_error "Missing log file"
+				fn_script_log_error "Set localbuild to 0"
+				sleep 0.5
+			fi
+			
+			totalseconds=$((totalseconds + 1))
+		done
 	fi
 
-	# Get current build from logs
-	currentbuild="$(cat "$(find "${serverfiles}/logs/"* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | sort -V)"
-	if [ -z "${currentbuild}" ]; then
-		fn_print_error_nl "Checking for update: teamspeak.com: Current build version not found"
-		fn_script_log_error "Checking for update: teamspeak.com: Current build version not found"
-		sleep 0.5
-		fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart"
-		fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart"
-		exitbypass=1
-		command_stop.sh
-		exitbypass=1
-		command_start.sh
-		currentbuild="$(cat "$(find "${serverfiles}/logs/"* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1)" | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | sort -V)"
-		if [ -z "${currentbuild}" ]; then
-			fn_print_fail_nl "Checking for update: teamspeak.com: Current build version still not found"
-			fn_script_log_fatal "Checking for update: teamspeak.com: Current build version still not found"
-			core_exit.sh
-		fi
+	if [ -z "${localbuild}" ]; then
+		localbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}")
 	fi
-}
 
-fn_update_ts3_arch(){
-# Gets the teamspeak server architecture.
-info_distro.sh
-if [ "${arch}" == "x86_64" ]; then
-	ts3arch="amd64"
-elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
-	ts3arch="x86"
-else
-	echo ""
-	fn_print_failure "Unknown or unsupported architecture: ${arch}"
-	fn_script_log_fatal "Unknown or unsupported architecture: ${arch}"
-	core_exit.sh
-fi
+	if [ -z "${localbuild}" ]; then
+		# Gives time for var to generate.
+		end=$((SECONDS+120))
+		totalseconds=0
+		while [ "${SECONDS}" -lt "${end}" ]; do
+			fn_print_info "Checking for update: ${remotelocation}: checking local build: waiting for local build: ${totalseconds}"
+			if [ -z "${loopignore}" ]; then
+				loopignore=1
+				fn_script_log_info "Waiting for local build to generate"
+			fi		
+			localbuild=$(cat $(find ./* -name "ts3server*_0.log" 2> /dev/null | sort | tail -1) | grep -Eo "TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}" | grep -Eo "((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}")
+			if [ "${localbuild}" ]; then
+				break
+			fi
+			sleep 1
+			totalseconds=$((totalseconds + 1))
+		done
+	fi
+	
+	if [ -z "${localbuild}" ]; then
+		localbuild="0"
+		fn_print_error "Checking for update: ${remotelocation}: waiting for local build: missing local build info"
+		fn_script_log_error "Missing local build info"
+		fn_script_log_error "Set localbuild to 0"
+	else
+		fn_print_ok "Checking for update: ${remotelocation}: checking local build"
+		fn_script_log_pass "Checking local build"
+	fi
+	sleep 0.5
 }
 
-fn_update_ts3_availablebuild(){
-	# Gets latest build info.
+fn_update_ts3_remotebuild(){
+	# Gets remote build info.
 	if [ "${arch}" == "x86_64" ]; then
-		availablebuild="$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86_64.version')"
+		remotebuild="$(${curlpath} -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86_64.version')"
 	elif [ "${arch}" == "x86" ]; then
-		availablebuild="$(${curlpath} -s 'https://www.teamspeak.com/versions/server.json' | jq -r '.linux.x86.version')"
+		remotebuild="$(${curlpath} -s "https://www.teamspeak.com/versions/server.json" | jq -r '.linux.x86.version')"
 	fi
-	ts3_version_number="${availablebuild}"
-	# Checks if availablebuild variable has been set
-	if [ -v "${availablebuild}" ]||[ "${availablebuild}" == "null" ]; then
-		fn_print_fail "Checking for update: teamspeak.com"
+	if [ "${installer}" != "1" ]; then
+		fn_print_dots "Checking for update: ${remotelocation}: checking remote build"
 		sleep 0.5
-		fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
-		fn_script_log_fatal "Checking for update: teamspeak.com: Not returning version info"
-		core_exit.sh
-	elif [ "${installer}" == "1" ]; then
-		:
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking for update: ${remotelocation}: checking remote build"
+			fn_script_log_pass "Checking remote build"
+			sleep 0.5
+		fi
 	else
-		fn_print_ok_nl "Checking for update: teamspeak.com"
-		fn_script_log_pass "Checking for update: teamspeak.com"
-		sleep 0.5
-	fi
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi	
 }
 
 fn_update_ts3_compare(){
-	# Removes dots so if can compare version numbers
-	currentbuilddigit=$(echo "${currentbuild}" | tr -cd '[:digit:]')
-	availablebuilddigit=$(echo "${availablebuild}" | tr -cd '[:digit:]')
-
-	if [ "${currentbuilddigit}" -lt "${availablebuilddigit}" ]; then
-		echo -e "\n"
-		echo -e "Update available:"
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	sleep 0.5
+	localbuilddigit=$(echo "${localbuild}" | tr -cd '[:digit:]')
+	remotebuilddigit=$(echo "${remotebuild}" | tr -cd '[:digit:]')
+	if [ "${localbuilddigit}" -ne "${remotebuilddigit}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
 		sleep 0.5
-		echo -e "	Current build: ${red}${currentbuild} ${ts3arch}${default}"
-		echo -e "	Available build: ${green}${availablebuild} ${ts3arch}${default}"
-		echo -e ""
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
 		sleep 0.5
-		echo -en "Applying update.\r"
+		echo -en "\n"
+		echo -en "applying update.\r"
 		sleep 1
-		echo -en "Applying update..\r"
+		echo -en "applying update..\r"
 		sleep 1
-		echo -en "Applying update...\r"
+		echo -en "applying update...\r"
 		sleep 1
 		echo -en "\n"
-		fn_script_log "Update available"
-		fn_script_log "Current build: ${currentbuild}"
-		fn_script_log "Available build: ${availablebuild}"
-		fn_script_log "${currentbuild} > ${availablebuild}"
 
 		unset updateonstart
 
 		check_status.sh
+		# If server stopped.
 		if [ "${status}" == "0" ]; then
+			exitbypass=1
 			fn_update_ts3_dl
 			exitbypass=1
 			command_start.sh
 			exitbypass=1
 			command_stop.sh
+		# If server started.
 		else
 			exitbypass=1
 			command_stop.sh
+			exitbypass=1
 			fn_update_ts3_dl
 			exitbypass=1
 			command_start.sh
@@ -157,27 +186,41 @@ fn_update_ts3_compare(){
 		alert="update"
 		alert.sh
 	else
-		echo -e "\n"
-		echo -e "No update available:"
-		echo -e "	Current version: ${green}${currentbuild}${default}"
-		echo -e "	Available version: ${green}${availablebuild}${default}"
-		echo -e ""
-		fn_print_ok_nl "No update available"
-		fn_script_log_info "Current build: ${currentbuild}"
-		fn_script_log_info "Available build: ${availablebuild}"
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		sleep 0.5
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
 	fi
 }
 
-fn_update_ts3_arch
+# Game server architecture.
+info_distro.sh
+if [ "${arch}" == "x86_64" ]; then
+	ts3arch="amd64"
+elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then
+	ts3arch="x86"
+else
+	fn_print_failure "Unknown or unsupported architecture: ${arch}"
+	fn_script_log_fatal "Unknown or unsupported architecture: ${arch}"
+	core_exit.sh
+fi
+
+# The location where the builds are checked and downloaded.
+remotelocation="teamspeak.com"
+
 if [ "${installer}" == "1" ]; then
-	fn_update_ts3_availablebuild
+	fn_update_ts3_remotebuild
 	fn_update_ts3_dl
 else
-	# Checks for server update from teamspeak.com using a mirror dl.4players.de.
-	fn_print_dots "Checking for update: teamspeak.com"
-	fn_script_log_info "Checking for update: teamspeak.com"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
 	sleep 0.5
-	fn_update_ts3_currentbuild
-	fn_update_ts3_availablebuild
+	fn_update_ts3_localbuild
+	fn_update_ts3_remotebuild
 	fn_update_ts3_compare
 fi

+ 1 - 1
linuxgsm.sh

@@ -153,7 +153,7 @@ fn_install_menu_bash() {
 	done <  ${options}
 	menu_options+=( "Cancel" )
 	select option in "${menu_options[@]}"; do
-		if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
+		if [ -n "${option}" ]&&[ "${option}" != "Cancel" ]; then
 			eval "$resultvar=\"${option/%\ */}\""
 		fi
 		break

+ 1 - 1
tests/tests_fctrserver.sh

@@ -146,7 +146,7 @@ fn_install_menu_bash() {
 	done <  ${options}
 	menu_options+=( "Cancel" )
 	select option in "${menu_options[@]}"; do
-		if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
+		if [ -n "${option}" ]&&[ "${option}" != "Cancel" ]; then
 			eval "$resultvar=\"${option/%\ */}\""
 		fi
 		break

+ 1 - 1
tests/tests_jc2server.sh

@@ -146,7 +146,7 @@ fn_install_menu_bash() {
 	done <  ${options}
 	menu_options+=( "Cancel" )
 	select option in "${menu_options[@]}"; do
-		if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
+		if [ -n "${option}" ]&&[ "${option}" != "Cancel" ]; then
 			eval "$resultvar=\"${option/%\ */}\""
 		fi
 		break

+ 1 - 1
tests/tests_ts3server.sh

@@ -146,7 +146,7 @@ fn_install_menu_bash() {
 	done <  ${options}
 	menu_options+=( "Cancel" )
 	select option in "${menu_options[@]}"; do
-		if [ -n "${option}" ] && [ "${option}" != "Cancel" ]; then
+		if [ -n "${option}" ]&&[ "${option}" != "Cancel" ]; then
 			eval "$resultvar=\"${option/%\ */}\""
 		fi
 		break