Skip to content

Commit

Permalink
TTL: goDaddy record and properties file not equal
Browse files Browse the repository at this point in the history
it will update the record
  • Loading branch information
navilg committed May 10, 2020
1 parent 7169f23 commit f3f324d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions debug-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
result=[{"data":"103.5.135.67","name":"test","ttl":3600,"type":"A"}]'

To filter out comments line
sudo grep -v "#" /etc/sudoers

dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")

existingTtl=$(echo $result | grep -oE "ttl\:[0-9]{3,}"
1 change: 0 additions & 1 deletion godaddyDDNS.log
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
NOT OK
5 changes: 4 additions & 1 deletion godaddyDDNS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ headers="Authorization: sso-key $key:$secret"
result=$(curl -s -X GET -H "$headers" \
"https://api.godaddy.com/v1/domains/$domain/records/A/$name")

#echo $result

dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
existingTtl=$(echo $result | cut -d "," -f 3 | cut -d ":" -f 2)
# echo "dnsIp:" $dnsIp

# Get public ip address there are several websites that can do this.
ret=$(curl -s GET "http://ipinfo.io/json")
currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
# echo "currentIp:" $currentIp

if [ "$dnsIp" != $currentIp ];
if [ "$dnsIp" != $currentIp -o $existingTtl -ne $ttl ];
then
# echo "Ips are not equal"
request='{"data":"'$currentIp'","ttl":'$ttl'}'
Expand Down

0 comments on commit f3f324d

Please sign in to comment.