Skip to content

Instantly share code, notes, and snippets.

@dragosthealex
Created March 4, 2017 16:48
Show Gist options
  • Save dragosthealex/5764573427a1c31e38c48285915b2bd6 to your computer and use it in GitHub Desktop.
Save dragosthealex/5764573427a1c31e38c48285915b2bd6 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check if the local exteran IP of this machine is the same as the one that
# our website's domain points to.
# Used together with update_godaddy_dns.py to update the website DNS record with the new one
# Usage: replace MY_WEBSITE with the actual website address
RIP="$(dig +short myip.opendns.com @resolver1.opendns.com)"
CIP=`nslookup MY_WEBSITE | grep Address: | awk 'NR==2 {print $2}'`
echo "$RIP"
echo "$CIP"
if [ "$RIP" == "$CIP" ] # is ip of this host same as our domain ip
then
echo "It's the same" # just to check
else
echo "They are not the same, updating..."
python ./update_godaddy_dns.py "$RIP"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment