Created
September 19, 2018 10:14
-
-
Save cwleonard/2a13fd341a2246ec6ffa5df7aab5b6fc to your computer and use it in GitHub Desktop.
dynamically set a GoDaddy DNS record
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 | |
domain="example.com" | |
aname="subdomain" | |
key="your_key" | |
secret="your_secret" | |
myip=`curl -s -X GET http://api.ipify.org?format=json | jq -r .ip` | |
recip=`curl -s -X GET "https://api.godaddy.com/v1/domains/$domain/records/A/$aname" -H "accept: application/json" -H "Authorization: sso-key $key:$secret" | jq -r .[0].data` | |
echo "my ip is $myip" | |
echo "A rec is $recip" | |
if [ "$myip" != "$recip" ]; then | |
echo "ip does not match" | |
newdata="[{\"data\":\"$myip\",\"ttl\":600}]" | |
echo "new data is: $newdata" | |
curl -s -X PUT "https://api.godaddy.com/v1/domains/$domain/records/A/$aname" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: sso-key $key:$secret" -d "$newdata" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment