zone-rm
changeset 22 7229d1c95ea8
parent 18 8715e7b706db
child 25 c02caf4e0eb6
equal deleted inserted replaced
21:6715f8f9d04c 22:7229d1c95ea8
     1 #!/usr/bin/perl -w
     1 #!/usr/bin/perl -w
     2 
     2 
     3 use strict;
     3 use strict;
       
     4 use File::Path;
     4 
     5 
     5 my $master_dir = "/etc/bind/master";
     6 my %config;
     6 my $conf_dir = "/etc/bind/zones.d";
     7 open (CONFIG, "dnstools.conf");
       
     8 while (<CONFIG>) {
       
     9 	chomp;
       
    10 	s/#.*//;
       
    11 	s/\t//g;
       
    12 	s/\s//g;
       
    13 	next unless length;
     7 
    14 
     8 foreach (@ARGV) {
    15 	my ($cname, $ccont) = split (/\s*=\s*/, $_,2);
     9 	chomp (my $domain = `idn --quiet $_`);
    16 	$config{$cname} = $ccont;
       
    17 }
       
    18 close (CONFIG);
    10 
    19 
    11 	if (-e "$master_dir/$domain") {
    20 my $master_dir = $config{"master_dir"};
    12 		`rm -rf $master_dir/$domain`;
    21 my $conf_dir = $config{"zone_conf_dir"};
    13 		print "zone-dir for $domain removed\n";
    22 
       
    23 
       
    24 for (@ARGV) {
       
    25 	chomp (my $zone = `idn --quiet "$_"`);
       
    26 
       
    27 	if (-e "$master_dir/$zone") {
       
    28 		rmtree "$master_dir/$zone/" and
       
    29 		print "zone-dir for $zone removed\n";
       
    30 	} else {
       
    31 		print "$master_dir/$zone: no such file or directory\n";
    14 	}
    32 	}
    15 	
    33 	
    16 	if (-e "$conf_dir/$domain") {
    34 	if (-e "$conf_dir/$zone") {
    17 		`rm -f $conf_dir/$domain`;
    35 		unlink "$conf_dir/$zone" and
    18 		print "configuration-file for $domain removed\n";
    36 		print "configuration-file for $zone removed\n";
       
    37 	} else {
       
    38 		print "$conf_dir/$zone: no such file or directory\n";
    19 	}
    39 	}
    20 }
    40 }