zone-rm
changeset 27 d5337081ed02
parent 25 c02caf4e0eb6
equal deleted inserted replaced
26:0342c09abf97 27:d5337081ed02
     2 
     2 
     3 use strict;
     3 use strict;
     4 use File::Path;
     4 use File::Path;
     5 use FindBin;
     5 use FindBin;
     6 
     6 
     7 
       
     8 # liest die Konfiguration ein
     7 # liest die Konfiguration ein
     9 my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
     8 my @configs = ( "$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf" );
    10 my %config;
     9 my %config;
    11 
    10 
    12 foreach (grep {-f} @configs) {
    11 foreach ( grep {-f} @configs ) {
    13         open(CONFIG, $_) or die "Can't open $_: $!\n";
    12     open( CONFIG, $_ ) or die "Can't open $_: $!\n";
    14 }
    13 }
    15 
    14 
    16 unless (seek(CONFIG,0 ,0 )) {
    15 unless ( seek( CONFIG, 0, 0 ) ) {
    17         die "Can't open config (searched: @configs)\n"
    16     die "Can't open config (searched: @configs)\n";
    18 }
    17 }
    19 
    18 
    20 while (<CONFIG>) {
    19 while (<CONFIG>) {
    21         chomp;
    20     chomp;
    22         s/#.*//;
    21     s/#.*//;
    23         s/\t//g;
    22     s/\t//g;
    24         s/\s//g;
    23     s/\s//g;
    25         next unless length;
    24     next unless length;
    26         my ($cname, $ccont) = split (/\s*=\s*/, $_,2);
    25     my ( $cname, $ccont ) = split( /\s*=\s*/, $_, 2 );
    27         $config{$cname} = $ccont;
    26     $config{$cname} = $ccont;
    28 }
    27 }
    29 close (CONFIG);
    28 close(CONFIG);
    30 
       
    31 
    29 
    32 my $master_dir = $config{"master_dir"};
    30 my $master_dir = $config{"master_dir"};
    33 my $conf_dir = $config{"zone_conf_dir"};
    31 my $conf_dir   = $config{"zone_conf_dir"};
    34 
       
    35 
    32 
    36 for (@ARGV) {
    33 for (@ARGV) {
    37 	chomp (my $zone = `idn --quiet "$_"`);
    34     chomp( my $zone = `idn --quiet "$_"` );
    38 
    35 
    39 	if (-d "$master_dir/$zone") {
    36     if ( -d "$master_dir/$zone" ) {
    40 		rmtree "$master_dir/$zone/" and
    37         rmtree "$master_dir/$zone/"
    41 		print "zone-dir for $zone removed\n";
    38             and print "zone-dir for $zone removed\n";
    42 	}
    39     }
    43 	else {
    40     else {
    44 		print "$master_dir/$zone: $!\n";
    41         print "$master_dir/$zone: $!\n";
    45 	}
    42     }
    46 	
    43 
    47 	if (-e "$conf_dir/$zone") {
    44     if ( -e "$conf_dir/$zone" ) {
    48 		unlink "$conf_dir/$zone" and
    45         unlink "$conf_dir/$zone"
    49 		print "configuration-file for $zone removed\n";
    46             and print "configuration-file for $zone removed\n";
    50 	}
    47     }
    51 	else {
    48     else {
    52 		print "$conf_dir/$zone: $!\n";
    49         print "$conf_dir/$zone: $!\n";
    53 	}
    50     }
    54 }
    51 }