From 60ed587fe82689c66c98c4eef58a24690e5d0dbf Mon Sep 17 00:00:00 2001 From: cindrmon Date: Fri, 27 Aug 2021 11:47:10 +0800 Subject: [PATCH] fix multiple IP addresses popping out from curl --- cloudflare-template.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index 70ab561..a061f0e 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -21,8 +21,17 @@ public_ip_sources=( "https://dynamicdns.park-your-domain.com/getip" ) -ip=$(curl -s ${public_ip_sources[@]}) +## Checks each Source/API for an IP and returns only one +for src in "${public_ip_sources[@]}"; do + ip=$(curl -s $src) + if [[ $ip == "" ]]; then + continue # continues checking for IP for each ip source till there is none + else + break # if IP is found, break the loop + fi +done +## If no IP is still found if [[ $ip == "" ]]; then logger -s "DDNS Updater: No public IP found" exit 1