mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-07-28 16:14:07 +02:00
Fix API logic in api.sh
Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
parent
60485fdc51
commit
1bea6db50a
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user