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

Merge pull request #16 from otherguy/master

Add bash to Dockerfile, add additional service and logging
This commit is contained in:
Alper Kanat 2020-12-14 13:01:39 +03:00 committed by GitHub
commit 0ed4ab05cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ api_host="https://api.digitalocean.com/v2"
sleep_interval=${SLEEP_INTERVAL:-300} sleep_interval=${SLEEP_INTERVAL:-300}
services=( services=(
"ifconfig.co"
"ipinfo.io/ip" "ipinfo.io/ip"
"ifconfig.me" "ifconfig.me"
) )
@ -29,10 +30,11 @@ while ( true ); do
echo "Trying with $service..." echo "Trying with $service..."
ip="$(curl -s $service)" ip="$(curl -s $service)"
test -n "$ip" && break
test -n "$ip" && break
done done
echo "Found IP address $ip"
if [[ -n $ip ]]; then if [[ -n $ip ]]; then
for sub in ${NAME//;/ }; do for sub in ${NAME//;/ }; do
record_id=$(echo $domain_records| jq ".domain_records[] | select(.type == \"A\" and .name == \"$sub\") | .id") record_id=$(echo $domain_records| jq ".domain_records[] | select(.type == \"A\" and .name == \"$sub\") | .id")
@ -51,6 +53,8 @@ while ( true ); do
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d "$data" \ -d "$data" \
"$url" &> /dev/null "$url" &> /dev/null
else
echo "existing DNS record address ($record_data) did not need updating"
fi fi
done done
else else