Partner to the last snippet; simply grabs all those files & places them where they should be. Could use some error checking & other features, but then it wouldn't be a snippet... ;-)
Update Helps to reload your config file & check for errors before posting to perl monks...
#!/usr/bin/perl
# another quick one to add all those
# zone files from flatdns.pl into something
# useful, like say, a named.conf. Backs up
# your named.conf first.
$|++;
use strict;
use Getopt::Std;
use File::Copy;
use POSIX;
my(@dnsdbs,$file,%args,$dbloc,$tmp);
getopt('f:hd:s:',\%args);
if(!defined $args{'f'} || !defined $args{'d'} || defined $args{'h'})
{
print <<EOU;
Synopsis:
append-dns.pl [options]
Where options are:
-f the name of the input file [normally named.conf]
-d the location of the zone files
-s Make these zones slaves instead (must provide a master).
-h print this help message.
EOU
exit;
}
$file = $args{'f'};
$dbloc = $args{'d'};
copy($file,$file . strftime("%Y%m%d-%T",localtime(time()))) or die "Ca
+nnot copy file $file: $!";
open(DNSCF,'>>',$file) or die "Cannot open $file: $!";
@dnsdbs = glob("$dbloc*.{com,net,org,biz,us}");
for(@dnsdbs)
{
$tmp = $_;
$tmp =~ s/\/.*\///;
$tmp =~ s/db\.//;
print DNSCF "zone $tmp {\n";
if(!defined $args{'s'})
{
print DNSCF "\ttype master;\n";
print DNSCF "\tfile \"$_\";\n";
print DNSCF "};\n";
}
else
{
print DNSCF "\ttype slave;\n";
print DNSCF "\tfile \"$_\";\n";
print DNSCF "\tmasters {\n";
print DNSCF "\t\t" . $args{'s'} . ";\n";
print DNSCF "\t};\n};\n";
}
}
close(DNSCF);