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:
parent
37937309be
commit
688a19663e
1 changed files with 12 additions and 1 deletions
13
dyndns.sh
13
dyndns.sh
|
@ -3,6 +3,11 @@
|
||||||
api_host="https://api.digitalocean.com/v2"
|
api_host="https://api.digitalocean.com/v2"
|
||||||
sleep_interval=${SLEEP_INTERVAL:-300}
|
sleep_interval=${SLEEP_INTERVAL:-300}
|
||||||
|
|
||||||
|
services=(
|
||||||
|
"ipinfo.io/ip"
|
||||||
|
"ifconfig.me"
|
||||||
|
)
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "$1"
|
echo "$1"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -20,7 +25,13 @@ while ( true ); do
|
||||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
||||||
$dns_list"?per_page=200")
|
$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
|
if [[ -n $ip ]]; then
|
||||||
for sub in ${NAME//;/ }; do
|
for sub in ${NAME//;/ }; do
|
||||||
|
|
Loading…
Reference in a new issue