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