Last active
January 3, 2016 19:39
-
-
Save nmcclain/8509874 to your computer and use it in GitHub Desktop.
Crude script to update an AWS Route53 entry from cron
This file contains hidden or 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
#!/usr/bin/php | |
<?php | |
# crude script to update an AWS Route53 entry from cron | |
$hostname = "homer"; | |
$domain = "simpsons.org"; | |
$ip = chop(`curl -s http://www.telize.com/ip`); | |
$r53ip = chop(`cli53 rrlist $domain | grep $hostname | awk '{print $5}'`); | |
if ($ip != $r53ip) { | |
$r = `cli53 rrdelete $domain $hostname A --wait`; | |
$r = `cli53 rrcreate $domain $hostname A $ip --ttl 600`; | |
if (!preg_match('/INFO\s+Success/', $r)) { | |
print "Error updating DDNS: ".$r."\n"; | |
} # silent on success for cron | |
} | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment