Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

append-dns.pl

by straywalrus (Friar)
on Apr 25, 2007 at 21:15 UTC ( [id://612101]=CUFP: print w/replies, xml ) Need Help??

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);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://612101]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found