Subversion Repositories sysadmin_scripts

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
156 rodolico 1
#! /usr/bin/perl -w
2
 
3
use BIND::Config::Parser;    # apt-get install libbind-config-parser-perl
4
 
5
my $CONFIG_DIR = '/etc/bind/';
6
my $ZONE_CONFIG = $CONFIG_DIR . 'named.conf.local.shared';
7
my $TESTING = 0;
8
 
9
my @ignore = ( '192-27.0.124.74', '74.197.65' );
10
 
11
my $ignoreRegex = '^(' . join( ')|(', @ignore ) . ')';
12
 
13
my $parser = new BIND::Config::Parser;
14
my $indent = 0;
15
 
16
 $parser->set_open_block_handler( sub {
17
         if ( $_[0] eq 'zone' ) {
18
            $zone = $_[1];
19
            $zone =~ s/"//gi;
20
            print "$zone\n" if ( $zone !~ m/$ignoreRegex/ );
21
         }
22
 } );
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
if ( $TESTING ) {
31
# Set up callback handlers
32
 $parser->set_open_block_handler( sub {
33
         print "\t" x $indent, join( " ", @_ ), " {\n";
34
         $indent++;
35
 } );
36
 $parser->set_close_block_handler( sub {
37
         $indent--;
38
         print "\t" x $indent, "};\n";
39
 } );
40
 $parser->set_statement_handler( sub {
41
         print "\t" x $indent, join( " ", @_ ), ";\n";
42
 } );
43
 
44
}
45
 
46
 # Parse the file
47
 $parser->parse_file( "$ZONE_CONFIG" );
48
 
49
1;