From 1bea6db50adb3a07ba58808791c7c013bc12a671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 24 Apr 2025 09:00:07 +0200 Subject: [PATCH] Fix API logic in api.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/api.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/api.sh b/advanced/Scripts/api.sh index 006a8d31..7e9d4653 100755 --- a/advanced/Scripts/api.sh +++ b/advanced/Scripts/api.sh @@ -20,7 +20,7 @@ TestAPIAvailability() { # as we are running locally, we can get the port value from FTL directly - local chaos_api_list authResponse authStatus authData + local chaos_api_list authResponse authStatus authData apiAvailable # Query the API URLs from FTL using CHAOS TXT local.api.ftl # The result is a space-separated enumeration of full URLs @@ -59,7 +59,7 @@ TestAPIAvailability() { # Test if http status code was 200 (OK) or 401 (authentication required) if [ ! "${authStatus}" = 200 ] && [ ! "${authStatus}" = 401 ]; then # API is not available at this port/protocol combination - API_PORT="" + apiAvailable=false else # API is available at this URL combination @@ -71,6 +71,8 @@ TestAPIAvailability() { # Check if 2FA is required needTOTP=$(echo "${authData}"| jq --raw-output .session.totp 2>/dev/null) + apiAvailable=true + break fi @@ -86,9 +88,9 @@ TestAPIAvailability() { fi done - # if API_PORT is empty, no working API port was found - if [ -n "${API_PORT}" ]; then - echo "API not available at: ${API_URL}" + # if apiAvailable is false, no working API was found + if [ "${apiAvailable}" = false ]; then + echo "API not available. Please check FTL.log" echo "Exiting." exit 1 fi