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

Merge branch 'feature/newts3updater' into develop

Daniel Gibbs 8 лет назад
Родитель
Сommit
fe12b0006e
2 измененных файлов с 34 добавлено и 7 удалено
  1. 2 4
      lgsm/functions/update_minecraft.sh
  2. 32 3
      lgsm/functions/update_ts3.sh

+ 2 - 4
lgsm/functions/update_minecraft.sh

@@ -70,12 +70,10 @@ fn_update_currentbuild(){
 fn_update_availablebuild(){
 	# Gets latest build info.
 	availablebuild=$(${curlpath} -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | sed -e 's/^.*"release":"\([^"]*\)".*$/\1/')
-	sleep 1
-
 	# Checks if availablebuild variable has been set
 	if [ -z "${availablebuild}" ]; then
 		fn_print_fail "Checking for update: mojang.com"
-		sleep 1
+		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
@@ -84,7 +82,7 @@ fn_update_availablebuild(){
 	else
 		fn_print_ok_nl "Checking for update: mojang.com"
 		fn_script_log_pass "Checking for update: mojang.com"
-		sleep 1
+		sleep 0.5
 	fi
 }
 

+ 32 - 3
lgsm/functions/update_ts3.sh

@@ -83,8 +83,32 @@ else
 fi
 }
 
+
 fn_update_ts3_availablebuild(){
 	# Gets latest build info.
+	if [ "${arch}" == "x86_64" ]; then
+		availablebuild=$(${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')
+	fi
+	# Checks if availablebuild variable has been set
+	if [ -z "${availablebuild}" ]; then
+		fn_print_fail "Checking for update: teamspeak.com"
+		sleep 0.5
+		fn_print_fail "Checking for update: teamspeak.com: Not returning version info"
+		fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info"
+		core_exit.sh
+	elif [ "${installer}" == "1" ]; then
+		:
+	else
+		fn_print_ok_nl "Checking for update: teamspeak.com"
+		fn_script_log_pass "Checking for update: teamspeak.com"
+		sleep 0.5
+	fi
+}
+
+fn_update_ts3_availablebuild_legacy(){
+	# Gets latest build info.
 
 	# Grabs all version numbers but not in correct order.
 	wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${tmpdir}/.ts3_version_numbers_unsorted.tmp"
@@ -180,9 +204,14 @@ fn_update_ts3_compare(){
 
 fn_update_ts3_arch
 if [ "${installer}" == "1" ]; then
-	fn_update_ts3_availablebuild
-	fn_update_ts3_dl
-else
+	# if jq available uses json update checker
+	if [ "$(command -v jq)" ]||[ "$(which jq >/dev/null 2>&1)" ]; then
+		fn_update_ts3_availablebuild
+	else
+		fn_update_ts3_availablebuild_legacy
+	fi
+		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"