--- a/zone-rm Mon Aug 02 13:45:47 2010 +0200
+++ b/zone-rm Wed Aug 04 11:27:21 2010 +0200
@@ -2,21 +2,33 @@
use strict;
use File::Path;
+use FindBin;
+
+# liest die Konfiguration ein
+my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
my %config;
-open (CONFIG, "dnstools.conf");
+
+foreach (grep {-f} @configs) {
+ open(CONFIG, $_) or die "Can't open $_: $!\n";
+}
+
+unless (seek(CONFIG,0 ,0 )) {
+ die "Can't open config (searched: @configs)\n"
+}
+
while (<CONFIG>) {
- chomp;
- s/#.*//;
- s/\t//g;
- s/\s//g;
- next unless length;
-
- my ($cname, $ccont) = split (/\s*=\s*/, $_,2);
- $config{$cname} = $ccont;
+ chomp;
+ s/#.*//;
+ s/\t//g;
+ s/\s//g;
+ next unless length;
+ my ($cname, $ccont) = split (/\s*=\s*/, $_,2);
+ $config{$cname} = $ccont;
}
close (CONFIG);
+
my $master_dir = $config{"master_dir"};
my $conf_dir = $config{"zone_conf_dir"};
@@ -24,17 +36,19 @@
for (@ARGV) {
chomp (my $zone = `idn --quiet "$_"`);
- if (-e "$master_dir/$zone") {
+ if (-d "$master_dir/$zone") {
rmtree "$master_dir/$zone/" and
print "zone-dir for $zone removed\n";
- } else {
- print "$master_dir/$zone: no such file or directory\n";
+ }
+ else {
+ print "$master_dir/$zone: $!\n";
}
if (-e "$conf_dir/$zone") {
unlink "$conf_dir/$zone" and
print "configuration-file for $zone removed\n";
- } else {
- print "$conf_dir/$zone: no such file or directory\n";
+ }
+ else {
+ print "$conf_dir/$zone: $!\n";
}
}