Skip to content

Instantly share code, notes, and snippets.

@almoce
Last active October 26, 2020 09:28
Show Gist options
  • Save almoce/9cdbecd898ecd7e09b2524b175f66d1a to your computer and use it in GitHub Desktop.
Save almoce/9cdbecd898ecd7e09b2524b175f66d1a to your computer and use it in GitHub Desktop.
Godady DDNS
#!/bin/bash
domain='${DOMAIN}'
hostname='@'
key='${APIKEY}'
secret='${APISECRET}'
apikey="$key:$secret"
myip=`curl -s 'https://api.ipify.org'`
url="https://api.godaddy.com/v1/domains/${domain}/records/A/${hostname}"
lastip='${CACHE_IP_FILE_LOCATION}'
if [ ! -e "$lastip" ]; then
echo $myip > $lastip
else
lastip=`cat $lastip`
fi
if [ "$myip" != "$lastip" -a "$myip" != "" ]; then
curl -s -X PUT "$url" -H "Content-Type: application/json" -d "[{\"data\": \"${myip}\"}]" -H "Authorization: sso-key ${apikey}"
fi
# data=`curl -s -X GET -H "Authorization: sso-key ${apikey}" "$url"`
# newip=`echo $data | cut -d ',' -f 1 | tr -d '"' | cut -d ":" -f 2`
# echo $data
# echo $myip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment