Skip to content

Instantly share code, notes, and snippets.

@nmcclain
Last active January 3, 2016 19:39
Show Gist options
  • Save nmcclain/8509874 to your computer and use it in GitHub Desktop.
Save nmcclain/8509874 to your computer and use it in GitHub Desktop.
Crude script to update an AWS Route53 entry from cron
#!/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