[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-users] Adding a list of DNS records, adding all domains to DNS, switching servers, moving sites
- Subject: [cobalt-users] Adding a list of DNS records, adding all domains to DNS, switching servers, moving sites
- From: "Carrie Bartkowiak" <ravencarrie@xxxxxxxx>
- Date: Sun May 20 08:38:02 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
I tried to put all the search terms I could think of into the subject
line.
This is a little script to add a buttload of domains to the DNS all at
one time. Just takes a few seconds, as opposed to the hours it would
take using the GUI.
1. Copy this into a text file and name it dns.pl. Edit for word
wrapping caused by email programs - remember, this is a script.
2. Read the directions.
3. You're welcome.
CarrieB
#!/usr/bin/perl
#############################
# This script will add a mass of DNS records all at once.
# Drop this script and a text file named 'domains' into the same
directory.
# Chown this script to root, chmod it to 755.
# At the prompt type "./dns.pl" (no quotes)
#
# YES, this script allows the records to show up in the Cobalt GUI.
# NO, this script does not handle subdomains. If you want those,
modify it or add
# them by hand.
# This script must be owned by root, and you must be logged in as root
to run it.
#############################
# Domains text file:
# Your domains text file should have a comma-separated list of all
the domains
# you want to add, one per line, with the values of
$domain,$tld,$base_ip.
# Example:
# foo,com,100.100.16.216
# widgets,com.au,100.100.16.217
#
# $domain is the middle part of the site name. For www.foo.com,
$domain would be 'foo'.
# $tld is the top-level-domain of the site. For www.foo.com, $tld
would be 'com'.
# For www.widgets.com.au, $tld would be 'com.au'.
# $base_ip is the ip address of the site.
#############################
# This script created by Carrie Bartkowiak for Cobalt RaQ users.
# Created May 20, 2001
# http://www.cobalthosts.com
# No warranties are implied or given.
# USE AT YOUR OWN RISK.
#############################
$use_flock = 1; #If you do not wish to use
flock, set this to 0 (zero)
$hostdomain = "yourserver.com"; #Set this to your server name,
without the 'www'
#########################
open (RIPPER, "domains") || exit 0;
flock(RIPPER, 2) unless ($use_flock == 0);
while (<RIPPER>)
{
($domain, $tld, $base_ip) = split(/\,/,$_);
&WriteRecord;
&AddRecord;
}
close (RIPPER);
flock(RIPPER, 8) unless ($use_flock == 0);
system "rm domains";
exit 0;
######################################################################
###########
sub WriteRecord {
######################################################################
###########
#This part rips up the domains text file and makes a new file with all
of the dns lines.
#If you don't want a wildcard entry, take out the line with the * in
it.
#If you want other entries (such as 'mail' or 'ftp'), add those lines
accordingly.
#
open(RECORDS, ">>records");
flock(RECORDS, 2) unless ($use_flock == 0);
print RECORDS "a - $domain.$tld $base_ip 24\n";
print RECORDS "a www $domain.$tld $base_ip 24\n";
print RECORDS "a * $domain.$tld $base_ip 24\n";
print RECORDS "mx - $domain.$tld High www.$domain.$tld\n";
print RECORDS "soa - $domain.$tld
ns1.$hostdomain:ns2.$hostdomain:admin\@$hostdomain:10800:3600:604800:8
6400 -\n";
flock(RECORDS, 8) unless ($use_flock == 0);
close(RECORDS);
print "$domain.$tld successfully added for entry.\n";
}
sub AddRecord {
open(NEWRECORDS, "<records") || exit 0;
open(RECORDS, ">>>/etc/named/records");
while(<NEWRECORDS>)
{
print RECORDS $_;
}
close(NEWRECORDS);
close(RECORDS);
system "rm records";
system "/usr/admserv/cgi-bin/.cobalt/dns/index.cgi";
print "All domains have been successfully added to the DNS.\n";
print "You may now verify the records in the Cobalt GUI.\n";
}