1
0
Fork 0
mirror of https://github.com/tunix/digitalocean-dyndns synced 2024-12-22 04:49:52 +00:00

Added ability to try multiple services for fetching IP address

This commit is contained in:
Alper Kanat 2020-12-11 00:03:27 +03:00
parent 37937309be
commit 688a19663e

View file

@ -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