Created
December 27, 2023 03:50
-
-
Save rajkumaar23/ec05d447c76d5245b3f90d676a12b633 to your computer and use it in GitHub Desktop.
A script to check and update GoDaddy DNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Taken from https://github.com/markafox/GoDaddy_Powershell_DDNS | |
domain="rajkumaar.co.in" # your domain | |
name="pi" # name of A record to update | |
key="" # key for godaddy developer API | |
secret="" # secret for godaddy developer API | |
headers="Authorization: sso-key $key:$secret" | |
result=$(curl -s -X GET -H "$headers" "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") | |
ret=$(curl -s GET "http://ipinfo.io/json") | |
currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") | |
if [ "$dnsIp" != "$currentIp" ]; | |
then | |
request='[{"data":"'$currentIp'","ttl":3600}]' | |
nresult=$(curl -i -s -X PUT \ | |
-H "$headers" \ | |
-H "Content-Type: application/json" \ | |
-d $request "https://api.godaddy.com/v1/domains/$domain/records/A/$name") | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment