zone-rm
changeset 22 7229d1c95ea8
parent 18 8715e7b706db
child 25 c02caf4e0eb6
--- a/zone-rm	Thu Jul 29 14:19:56 2010 +0200
+++ b/zone-rm	Mon Aug 02 11:15:18 2010 +0200
@@ -1,20 +1,40 @@
 #!/usr/bin/perl -w
 
 use strict;
+use File::Path;
 
-my $master_dir = "/etc/bind/master";
-my $conf_dir = "/etc/bind/zones.d";
+my %config;
+open (CONFIG, "dnstools.conf");
+while (<CONFIG>) {
+	chomp;
+	s/#.*//;
+	s/\t//g;
+	s/\s//g;
+	next unless length;
 
-foreach (@ARGV) {
-	chomp (my $domain = `idn --quiet $_`);
+	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"};
+
 
-	if (-e "$master_dir/$domain") {
-		`rm -rf $master_dir/$domain`;
-		print "zone-dir for $domain removed\n";
+for (@ARGV) {
+	chomp (my $zone = `idn --quiet "$_"`);
+
+	if (-e "$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";
 	}
 	
-	if (-e "$conf_dir/$domain") {
-		`rm -f $conf_dir/$domain`;
-		print "configuration-file for $domain removed\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";
 	}
 }