mirror of
https://github.com/tunix/digitalocean-dyndns
synced 2024-11-01 00:25:24 +00:00
Compare commits
No commits in common. "a21767ee627e9d63125662374a430637e3baa51d" and "7b38d97e38436d4a75501e1fbf7ec4632c82a75e" have entirely different histories.
a21767ee62
...
7b38d97e38
1 changed files with 5 additions and 15 deletions
18
dyndns.sh
18
dyndns.sh
|
@ -29,7 +29,7 @@ while ( true ); do
|
||||||
for service in ${services[@]}; do
|
for service in ${services[@]}; do
|
||||||
echo "Trying with $service..."
|
echo "Trying with $service..."
|
||||||
|
|
||||||
ip="$(curl -s $service | grep '[0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}')"
|
ip="$(curl -s $service)"
|
||||||
test -n "$ip" && break
|
test -n "$ip" && break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -46,22 +46,12 @@ while ( true ); do
|
||||||
# re-enable glob expansion
|
# re-enable glob expansion
|
||||||
set +f
|
set +f
|
||||||
|
|
||||||
|
test -z $record_id && echo "No record found with '$sub' domain name!" && continue
|
||||||
|
|
||||||
|
if [[ "$ip" != "$record_data" ]]; then
|
||||||
data="{\"type\": \"A\", \"name\": \"$sub\", \"data\": \"$ip\"}"
|
data="{\"type\": \"A\", \"name\": \"$sub\", \"data\": \"$ip\"}"
|
||||||
url="$dns_list/$record_id"
|
url="$dns_list/$record_id"
|
||||||
|
|
||||||
if [[ -z $record_id ]]; then
|
|
||||||
echo "No record found with '$sub' domain name. Creating record, sending data=$data to url=$url"
|
|
||||||
|
|
||||||
new_record=$(curl -s -X POST \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
|
|
||||||
-d "$data" \
|
|
||||||
"$url")
|
|
||||||
|
|
||||||
record_data=$(echo $new_record| jq -r ".data")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$ip" != "$record_data" ]]; then
|
|
||||||
echo "existing DNS record address ($record_data) doesn't match current IP ($ip), sending data=$data to url=$url"
|
echo "existing DNS record address ($record_data) doesn't match current IP ($ip), sending data=$data to url=$url"
|
||||||
|
|
||||||
curl -s -X PUT \
|
curl -s -X PUT \
|
||||||
|
|
Loading…
Reference in a new issue