Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- mydomain=""
- myhostnames=( pterodactyl plex emby phpmyadmin torrents )
- gdapikey=""
- logdest="local7.info"
- myip=`curl -s "https://api.ipify.org"`
- for myhostname in "${myhostnames[@]}"
- do
- dnsdata=`curl -s -X GET -H "Authorization: sso-key ${gdapikey}" "https://api.godaddy.com/v1/domains/${mydomain}/records/A/${myhostname}"`
- gdip=`echo $dnsdata | cut -d ',' -f 1 | tr -d '"' | cut -d ":" -f 2`
- echo "`date '+%Y-%m-%d %H:%M:%S'` - $myhostname - Current External IP is $myip, GoDaddy DNS IP is $gdip"
- if [ "$gdip" != "$myip" -a "$myip" != "" ]; then
- echo "IP has changed!! Updating on GoDaddy"
- curl -s -X PUT "https://api.godaddy.com/v1/domains/${mydomain}/records/A/${myhostname}" -H "Authorization: sso-key ${gdapikey}" -H "Content-Type: application/json" -d "[{\"data\": \"${myip}\"}]"
- logger -p $logdest "Changed IP on ${hostname}.${mydomain} from ${gdip} to ${myip}"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement