Răsfoiți Sursa

feat(ts3): add check-update function (#3967)

Christian 3 ani în urmă
părinte
comite
9984f956b3

+ 9 - 5
lgsm/functions/command_check_update.sh

@@ -14,12 +14,16 @@ fn_print_dots ""
 check.sh
 core_logs.sh
 
-core_steamcmd.sh
+if [ "${appid}" ]; then
+	core_steamcmd.sh
 
-check_steamcmd.sh
+	check_steamcmd.sh
 
-fn_update_steamcmd_localbuild
-fn_update_steamcmd_remotebuild
-fn_update_steamcmd_compare
+	fn_update_steamcmd_localbuild
+	fn_update_steamcmd_remotebuild
+	fn_update_steamcmd_compare
+elif [ "${shortname}" == "ts3" ]; then
+	update_ts3.sh
+fi
 
 core_exit.sh

+ 1 - 1
lgsm/functions/core_getopt.sh

@@ -75,7 +75,7 @@ if [ "${shortname}" == "jk2" ] || [ "${engine}" != "idtech3" ]; then
 fi
 
 # Validate and check-update command.
-if [ "${appid}" ]; then
+if [ "${appid}" ]||[ "${shortname}" == "ts3" ]; then
 	currentopt+=("${cmd_validate[@]}" "${cmd_check_update[@]}")
 fi
 

+ 27 - 23
lgsm/functions/update_ts3.sh

@@ -150,35 +150,39 @@ fn_update_ts3_compare() {
 		fn_script_log_info "Remote build: ${remotebuild}"
 		fn_script_log_info "${localbuild} > ${remotebuild}"
 
-		unset updateonstart
-		check_status.sh
-		# If server stopped.
-		if [ "${status}" == "0" ]; then
-			exitbypass=1
-			fn_update_ts3_dl
-			if [ "${requirerestart}" == "1" ]; then
+		if [ "${commandname}" == "UPDATE" ]; then
+			unset updateonstart
+			check_status.sh
+			# If server stopped.
+			if [ "${status}" == "0" ]; then
 				exitbypass=1
-				command_start.sh
-				fn_firstcommand_reset
+				fn_update_ts3_dl
+				if [ "${requirerestart}" == "1" ]; then
+					exitbypass=1
+					command_start.sh
+					fn_firstcommand_reset
+					exitbypass=1
+					command_stop.sh
+					fn_firstcommand_reset
+				fi
+			# If server started.
+			else
+				fn_print_restart_warning
 				exitbypass=1
 				command_stop.sh
 				fn_firstcommand_reset
+				exitbypass=1
+				fn_update_ts3_dl
+				exitbypass=1
+				command_start.sh
+				fn_firstcommand_reset
 			fi
-		# If server started.
-		else
-			fn_print_restart_warning
-			exitbypass=1
-			command_stop.sh
-			fn_firstcommand_reset
-			exitbypass=1
-			fn_update_ts3_dl
-			exitbypass=1
-			command_start.sh
-			fn_firstcommand_reset
+			unset exitbypass
+			date +%s > "${lockdir}/lastupdate.lock"
+			alert="update"
+		elif [ "${commandname}" == "CHECK-UPDATE" ]; then
+			alert="check-update"
 		fi
-		unset exitbypass
-		date +%s > "${lockdir}/lastupdate.lock"
-		alert="update"
 		alert.sh
 	else
 		fn_print_ok_nl "Checking for update: ${remotelocation}"