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