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

fix(bug): gamedig not using the correct JSON object (#2821)

Jimmy Maple 6 жил өмнө
parent
commit
7a38c17186

+ 1 - 0
README.md

@@ -60,3 +60,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 <!-- ALL-CONTRIBUTORS-LIST:END -->
 
 This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
+

+ 8 - 6
lgsm/functions/command_monitor.sh

@@ -12,7 +12,7 @@ local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
 fn_monitor_check_lockfile(){
 	# Monitor does not run it lockfile is not found.
-	if [ ! -f "${lockdir}/${selfname}.lock" ]; then
+	if [ ! -f "${rootdir}/${lockselfname}" ]; then
 		fn_print_dots "Checking lockfile: "
 		fn_print_checking_eol
 		fn_script_log_info "Checking lockfile: CHECKING"
@@ -21,13 +21,13 @@ fn_monitor_check_lockfile(){
 		fn_print_error_eol_nl
 		fn_script_log_error "Checking lockfile: No lockfile found: ERROR"
 		fn_sleep_time
-		echo -en "* Start ${selfname} to run monitor."
+		echo -e "* Start ${selfname} to run monitor."
 		core_exit.sh
 	fi
 
 	# Fix if lockfile is not unix time or contains letters
-	if [[ "$(cat "${lockdir}/${selfname}.lock")" =~ [A-Za-z] ]]; then
-			date '+%s' > "${lockdir}/${selfname}.lock"
+	if [[ "$(cat "${rootdir}/${lockselfname}")" =~ [A-Za-z] ]]; then
+			date '+%s' > "${rootdir}/${lockselfname}"
 	fi
 }
 
@@ -108,7 +108,7 @@ for queryattempt in {1..5}; do
 	fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : QUERYING"
 	fn_sleep_time
 	# querydelay
-	if [ "$(cat "${lockdir}/${selfname}.lock")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then
+	if [ "$(cat "${rootdir}/${lockselfname}")" -gt "$(date "+%s" -d "${querydelay} mins ago")" ]; then
 		fn_print_ok "Querying port: ${querymethod}: ${ip}:${queryport} : ${totalseconds}/${queryattempt}: "
 		fn_print_delay_eol_nl
 		fn_script_log_info "Querying port: ${querymethod}: ${ip}:${queryport} : ${queryattempt} : DELAY"
@@ -147,6 +147,9 @@ for queryattempt in {1..5}; do
 			if [ "${gdplayers}" ]; then
 				fn_script_log_info "Players: ${gdplayers}/${gdmaxplayers}"
 			fi
+			if [ "${gdbots}" ]; then
+                fn_script_log_info "Bots: ${gdbots}"
+            fi
 			if [ "${gdmap}" ]; then
 				fn_script_log_info "Map: ${gdmap}"
 			fi
@@ -236,7 +239,6 @@ info_parms.sh
 
 # query pre-checks
 fn_monitor_check_lockfile
-check_last_update.sh
 fn_monitor_check_update
 fn_monitor_check_session
 # Monitor will not continue if session only check.

+ 1 - 1
lgsm/functions/query_gamedig.sh

@@ -30,7 +30,7 @@ if [ "$(command -v gamedig 2>/dev/null)" ]&&[ "$(command -v jq 2>/dev/null)" ];
 		fi
 
 		# numplayers.
-		gdplayers=$(echo -e "${gamedigraw}" | jq -re '.players')
+		gdplayers=$(echo -e "${gamedigraw}" | jq -re '.raw.vanilla.raw.players.online')
 		if [ "${gdplayers}" == "null" ]; then
 			unset gdplayers
 		elif [ "${gdplayers}" == "[]" ]; then