From 688a19663eac7112cc84cf398d97475035f184bc Mon Sep 17 00:00:00 2001 From: Alper Kanat Date: Fri, 11 Dec 2020 00:03:27 +0300 Subject: [PATCH] Added ability to try multiple services for fetching IP address --- dyndns.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dyndns.sh b/dyndns.sh index 2cac53f..59e1023 100755 --- a/dyndns.sh +++ b/dyndns.sh @@ -3,6 +3,11 @@ api_host="https://api.digitalocean.com/v2" sleep_interval=${SLEEP_INTERVAL:-300} +services=( + "ipinfo.io/ip" + "ifconfig.me" +) + die() { echo "$1" exit 1 @@ -20,7 +25,13 @@ while ( true ); do -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ $dns_list"?per_page=200") - ip="$(curl -s ipinfo.io/ip)" + for service in ${services[@]}; do + echo "Trying with $service..." + + ip="$(curl -s $service)" + + test -n "$ip" && break + done if [[ -n $ip ]]; then for sub in ${NAME//;/ }; do