mirror of
https://github.com/tunix/digitalocean-dyndns
synced 2024-12-22 12:59:52 +00:00
Merge pull request #1 from joelanford/master
When getting record ID, select only A records and refresh on every interval
This commit is contained in:
commit
ce9d8451f2
1 changed files with 8 additions and 7 deletions
|
@ -13,15 +13,16 @@ test -z $DOMAIN && die "DOMAIN not set!"
|
||||||
test -z $NAME && die "NAME not set!"
|
test -z $NAME && die "NAME not set!"
|
||||||
|
|
||||||
dns_list="$api_host/domains/$DOMAIN/records"
|
dns_list="$api_host/domains/$DOMAIN/records"
|
||||||
domain_records=$(curl -s -X GET \
|
|
||||||
|
while ( true ); do
|
||||||
|
domain_records=$(curl -s -X GET \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
||||||
$dns_list)
|
$dns_list)
|
||||||
record_id=$(echo $domain_records| jq ".domain_records[] | select(.name == \"$NAME\") | .id")
|
record_id=$(echo $domain_records| jq ".domain_records[] | select(.type == \"A\" and .name == \"$NAME\") | .id")
|
||||||
|
|
||||||
test -z $record_id && die "No record found with given domain name!"
|
test -z $record_id && die "No record found with given domain name!"
|
||||||
|
|
||||||
while ( true ); do
|
|
||||||
ip="$(curl -s ipinfo.io/ip)"
|
ip="$(curl -s ipinfo.io/ip)"
|
||||||
data="{\"type\": \"A\", \"name\": \"$NAME\", \"data\": \"$ip\"}"
|
data="{\"type\": \"A\", \"name\": \"$NAME\", \"data\": \"$ip\"}"
|
||||||
url="$dns_list/$record_id"
|
url="$dns_list/$record_id"
|
||||||
|
|
Loading…
Reference in a new issue