Created
May 14, 2014 21:17
-
-
Save bentglasstube/c339a2ba2392efb93316 to your computer and use it in GitHub Desktop.
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/env perl | |
use 5.010; | |
use strict; | |
use warnings; | |
use DigitalOcean; | |
my $IP = '107.170.222.172'; | |
my $do = DigitalOcean->new( | |
client_id => 'c5b4ffc3b0882aea42521015f3e3f56f', | |
api_key => '1092d527332aa5ac2b68e65c0f275e1a', | |
wait_on_events => 0, | |
); | |
my %domains = ( | |
'adventuremormon.com' => [ | |
[ 'A', '', $IP ], | |
[ 'CNAME', 'www', 'adventuremormon.com' ], | |
], | |
'eab.so' => [ | |
[ 'A', '', $IP ], | |
[ 'TXT', '', 'google-site-verification=QJA1MeAd_RpL-BiMw7tEb9rjQ4PtexjICseotyFqqis' ], | |
], | |
'eatabrick.org' => [ | |
[ 'A', '', $IP ], | |
[ 'A', 'dyn', '72.208.140.16' ], | |
[ 'A', 'samwise', '166.78.7.244' ], | |
[ 'A', 'steve.radio', '72.201.248.7' ], | |
[ 'CNAME', '*', 'eatabrick.org' ], | |
[ 'CNAME', 'alan.radio', 'home.eatabrick.org', ], | |
[ 'CNAME', 'cal', 'ghs.google.com' ], | |
[ 'CNAME', 'cloud', 'home.eatabrick.org' ], | |
[ 'CNAME', 'docs', 'ghs.google.com' ], | |
[ 'CNAME', 'frodo', 'home.eatabrick.org' ], | |
[ 'CNAME', 'git', 'samwise.eatabrick.org' ], | |
[ 'CNAME', 'home', 'dyn.eatabrick.org' ], | |
[ 'CNAME', 'mail', 'ghs.google.com', ], | |
[ 'CNAME', 'plex', 'home.eatabrick.org', ], | |
[ 'CNAME', 'tomblr', 'domains.tumblr.com', ], | |
[ 'MX', '', 'aspmx.l.google.com', 1 ], | |
[ 'MX', '', 'alt1.aspmx.l.google.com', 5 ], | |
[ 'MX', '', 'alt2.aspmx.l.google.com', 5 ], | |
[ 'MX', '', 'aspmx2.googlemail.com', 10 ], | |
[ 'MX', '', 'aspmx3.googlemail.com', 10 ], | |
[ 'TXT', '', 'I hate them all except turtleface' ], | |
[ 'TXT', '', '' ], | |
[ 'TXT', '_domainkey', 'o=~' ], | |
[ 'TXT', 'google._domainkey', '' ], | |
[ 'TXT', 'www._domainkey', '' ], | |
# TODO jabber shit | |
], | |
'febrewary.us' => [ | |
[ 'A', '', $IP ], | |
[ 'CNAME', '', 'febrewary.us' ], | |
], | |
'greentheresearchers.com' => [ | |
[ 'A', '', $IP ], | |
[ 'CNAME', 'www', 'greentheresearchers.com' ], | |
], | |
'martiberndt.com' => [ | |
[ 'A', '', $IP ], | |
[ 'CNAME', 'www', 'martiberndt.com' ], | |
], | |
'runtothecenter.com' => [ | |
[ 'A', '', $IP ], | |
[ 'CNAME', 'www', 'runtothecenter.com' ], | |
[ 'CNAME', 'zomg', 'runtothecenter.com' ], | |
], | |
); | |
my %do_domains = map { $_->name => $_ } @{ $do->domains }; | |
foreach my $domain (keys %domains) { | |
unless ($do_domains{$domain}) { | |
say "Domain $domain not found, creating"; | |
$do_domains{$domain} = $do->create_domain( | |
name => $domain, | |
ip_address => $domains{$domain}[0][2], | |
); | |
} | |
foreach my $entry (@{ $domains{$domain} }) { | |
my %params = (); | |
@params{qw{record_type name data priority}} = @$entry; | |
$params{name} ||= '@'; | |
if ($params{record_type} =~ /^(?:CNAME|MX)/) { | |
$params{data} .= '.'; | |
} | |
eval { | |
$do_domains{$domain}->create_record(%params); | |
}; | |
say STDERR $@ if $@; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment