diff -r d50f6874b7ab -r 8b46e7c48995 zone-rm.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/zone-rm.pl Tue Dec 21 13:53:39 2010 +0100 @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w + +use strict; +use File::Path; +use FindBin; + +# liest die Konfiguration ein +my @configs = ( "$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf" ); +my %config; + +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 () { + 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"}; + +for (@ARGV) { + chomp( my $zone = `idn --quiet "$_"` ); + + if ( -d "$master_dir/$zone" ) { + rmtree "$master_dir/$zone/" + and print "zone-dir for $zone removed\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: $!\n"; + } +}