Created
March 4, 2017 16:48
-
-
Save dragosthealex/5764573427a1c31e38c48285915b2bd6 to your computer and use it in GitHub Desktop.
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 | |
# 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