mirror of
https://github.com/RogerSik/godaddy_ddns.git
synced 2024-11-24 01:20:27 +01:00
prettier formatter used
This commit is contained in:
parent
02ce78927c
commit
5d383d5315
@ -1,6 +1,7 @@
|
|||||||
Forked from [gist mcarpenterjr/godaddy_ddns.sh](https://gist.github.com/mcarpenterjr/1dedf9f9f842710ba5f07937ef4f5ae49)
|
Forked from [gist mcarpenterjr/godaddy_ddns.sh](https://gist.github.com/mcarpenterjr/1dedf9f9f842710ba5f07937ef4f5ae49)
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
* usage of wtfismyip.com
|
|
||||||
* added IPv6 support (for the poor people which ISP is regularly changing the ipv6 ranges)
|
- usage of wtfismyip.com
|
||||||
* lower ttl (600)
|
- added IPv6 support (for the poor people which ISP is regularly changing the ipv6 ranges)
|
||||||
|
- lower ttl (600)
|
||||||
|
@ -12,17 +12,17 @@
|
|||||||
#
|
#
|
||||||
#Update the first 4 variables with your information
|
#Update the first 4 variables with your information
|
||||||
|
|
||||||
domain="" # your domain
|
domain="" # your domain
|
||||||
name="" # name of A record to update
|
name="" # name of A record to update
|
||||||
key="" # key for godaddy developer API
|
key="" # key for godaddy developer API
|
||||||
secret="" # secret for godaddy developer API
|
secret="" # secret for godaddy developer API
|
||||||
|
|
||||||
headers="Authorization: sso-key $key:$secret"
|
headers="Authorization: sso-key $key:$secret"
|
||||||
|
|
||||||
# echo $headers # debug
|
# echo $headers # debug
|
||||||
|
|
||||||
result=$(curl -s -X GET -H "$headers" \
|
result=$(curl -s -X GET -H "$headers" \
|
||||||
"https://api.godaddy.com/v1/domains/$domain/records/A/$name")
|
"https://api.godaddy.com/v1/domains/$domain/records/A/$name")
|
||||||
|
|
||||||
dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
|
dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
|
||||||
echo "dnsIp:" $dnsIp
|
echo "dnsIp:" $dnsIp
|
||||||
@ -31,15 +31,14 @@ echo "dnsIp:" $dnsIp
|
|||||||
currentIp=$(curl -s GET "https://ipv4.wtfismyip.com/text")
|
currentIp=$(curl -s GET "https://ipv4.wtfismyip.com/text")
|
||||||
echo "currentIp:" $currentIp
|
echo "currentIp:" $currentIp
|
||||||
|
|
||||||
if [ $dnsIp != $currentIp ];
|
if [ $dnsIp != $currentIp ]; then
|
||||||
then
|
echo "Ips are not equal"
|
||||||
echo "Ips are not equal"
|
request='[{"data":"'$currentIp'","name":"'$name'","ttl":600,"type":"A"}]'
|
||||||
request='[{"data":"'$currentIp'","name":"'$name'","ttl":600,"type":"A"}]'
|
# echo $request # debug
|
||||||
# echo $request # debug
|
nresult=$(curl -i -s -X PUT \
|
||||||
nresult=$(curl -i -s -X PUT \
|
-H "$headers" \
|
||||||
-H "$headers" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Content-Type: application/json" \
|
-d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
|
||||||
-d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
|
echo $nresult
|
||||||
echo $nresult
|
|
||||||
echo "dns record updated"
|
echo "dns record updated"
|
||||||
fi
|
fi
|
||||||
|
@ -12,17 +12,17 @@
|
|||||||
#
|
#
|
||||||
#Update the first 4 variables with your information
|
#Update the first 4 variables with your information
|
||||||
|
|
||||||
domain="" # your domain
|
domain="" # your domain
|
||||||
name="" # name of AAAA record to update
|
name="" # name of AAAA record to update
|
||||||
key="" # key for godaddy developer API
|
key="" # key for godaddy developer API
|
||||||
secret="" # secret for godaddy developer API
|
secret="" # secret for godaddy developer API
|
||||||
|
|
||||||
headers="Authorization: sso-key $key:$secret"
|
headers="Authorization: sso-key $key:$secret"
|
||||||
|
|
||||||
# echo $headers
|
# echo $headers
|
||||||
|
|
||||||
result=$(curl -s -X GET -H "$headers" \
|
result=$(curl -s -X GET -H "$headers" \
|
||||||
"https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")
|
"https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")
|
||||||
|
|
||||||
dnsIp=$(echo $result | grep -Eo "2[0-9a-fA-F]{3}:(([0-9a-fA-F]{1,4}[:]{1,2}){1,6}[0-9a-fA-F]{1,4})")
|
dnsIp=$(echo $result | grep -Eo "2[0-9a-fA-F]{3}:(([0-9a-fA-F]{1,4}[:]{1,2}){1,6}[0-9a-fA-F]{1,4})")
|
||||||
echo "dnsIp:" $dnsIp
|
echo "dnsIp:" $dnsIp
|
||||||
@ -31,15 +31,14 @@ echo "dnsIp:" $dnsIp
|
|||||||
currentIp=$(curl -s GET "https://ipv6.wtfismyip.com/text")
|
currentIp=$(curl -s GET "https://ipv6.wtfismyip.com/text")
|
||||||
echo "currentIp:" $currentIp
|
echo "currentIp:" $currentIp
|
||||||
|
|
||||||
if [ $dnsIp != $currentIp ];
|
if [ $dnsIp != $currentIp ]; then
|
||||||
then
|
echo "Ips are not equal"
|
||||||
echo "Ips are not equal"
|
request='[{"data":"'$currentIp'","name":"'$name'","ttl":600,"type":"AAAA"}]'
|
||||||
request='[{"data":"'$currentIp'","name":"'$name'","ttl":600,"type":"AAAA"}]'
|
# echo $request # debug
|
||||||
# echo $request # debug
|
result=$(curl -i -s -X PUT \
|
||||||
result=$(curl -i -s -X PUT \
|
-H "$headers" \
|
||||||
-H "$headers" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Content-Type: application/json" \
|
-d $request "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")
|
||||||
-d $request "https://api.godaddy.com/v1/domains/$domain/records/AAAA/$name")
|
echo $nresult
|
||||||
echo $nresult
|
|
||||||
echo "dns record updated"
|
echo "dns record updated"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user