diff -r 0342c09abf97 -r d5337081ed02 zone-mk --- a/zone-mk Thu Aug 05 10:49:36 2010 +0200 +++ b/zone-mk Mon Aug 09 11:45:43 2010 +0200 @@ -3,128 +3,132 @@ use strict; use FindBin; -if (@ARGV < 2) { - print "usage: zone-mk kundennummer domain ... \n"; - exit 1; +if ( @ARGV < 2 ) { + print "usage: zone-mk kundennummer domain ... \n"; + exit 1; } # oeffnet Konfigurations- und Templatefiles - relativ oder absolut -my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf"); -my @templc = ("$FindBin::Bin/templates/named.config","/etc/dnstools/templates/named.config"); -my @templz = ("$FindBin::Bin/templates/named.zone","/etc/dnstools/templates/named.zone"); +my @configs = ( "$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf" ); +my @templc = ( + "$FindBin::Bin/templates/named.config", + "/etc/dnstools/templates/named.config" +); +my @templz = ( + "$FindBin::Bin/templates/named.zone", + "/etc/dnstools/templates/named.zone" +); my %config; -for (grep {-f} @configs) { - open(CONFIG, $_) or die "Can't open $_: $!\n"; +for ( grep {-f} @configs ) { + open( CONFIG, $_ ) or die "Can't open $_: $!\n"; } -unless (seek(CONFIG,0 ,0 )) { - die "Can't open config (searched: @configs)\n"; +unless ( seek( CONFIG, 0, 0 ) ) { + die "Can't open config (searched: @configs)\n"; } -for (grep {-f} @templc) { - open(TEMPCONF, $_) or die "Can't open $_: $!\n"; +for ( grep {-f} @templc ) { + open( TEMPCONF, $_ ) or die "Can't open $_: $!\n"; } -unless (seek(TEMPCONF,0 ,0 )) { - die "Can't open config (searched: @templc)\n"; +unless ( seek( TEMPCONF, 0, 0 ) ) { + die "Can't open config (searched: @templc)\n"; } -for (grep {-f} @templz) { - open(TEMPZONE, $_) or die "Can't open $_: $!\n"; +for ( grep {-f} @templz ) { + open( TEMPZONE, $_ ) or die "Can't open $_: $!\n"; } -unless (seek(TEMPZONE,0 ,0 )) { - die "Can't open config (searched: @templz)\n"; +unless ( seek( TEMPZONE, 0, 0 ) ) { + die "Can't open config (searched: @templz)\n"; } while () { - 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); - +close(CONFIG); -my $primary = $config{primary}; -my $secondary= $config{secondary}; -my $zone_conf_dir= $config{zone_conf_dir}; -my $master_dir = $config{master_dir}; -my $customer = shift @ARGV; -chomp (my $primary_ip = `dig +short $primary`); -chomp (my $secondary_ip = `dig +short $secondary`); -chomp (my $this_host= `hostname -f`); -chomp (my $this_ip= `hostname -i`); -chomp (my $this_domain = `hostname -d`); -chomp (my $time = `date +%Y%m%d00`); -chomp (my $start= `date -I`); +my $primary = $config{primary}; +my $secondary = $config{secondary}; +my $zone_conf_dir = $config{zone_conf_dir}; +my $master_dir = $config{master_dir}; +my $customer = shift @ARGV; +chomp( my $primary_ip = `dig +short $primary` ); +chomp( my $secondary_ip = `dig +short $secondary` ); +chomp( my $this_host = `hostname -f` ); +chomp( my $this_ip = `hostname -i` ); +chomp( my $this_domain = `hostname -d` ); +chomp( my $time = `date +%Y%m%d00` ); +chomp( my $start = `date -I` ); my $hostmaster = "hostmaster.$this_domain"; -unless (-d $master_dir and -r $master_dir) { - die "$master_dir: $!\n"; +unless ( -d $master_dir and -r $master_dir ) { + die "$master_dir: $!\n"; } -unless (-d $zone_conf_dir and -r $zone_conf_dir) { - die "$master_dir: $!\n"; +unless ( -d $zone_conf_dir and -r $zone_conf_dir ) { + die "$master_dir: $!\n"; } - # legt fuer jede domain in @ARGV ein verzeichnis in $master_dir an. # schreibt aus den angegebenen templates die dateien $zonefile und $config # in die entsprechenden verzeichnisse. for (@ARGV) { - chomp (my $domain = `idn --quiet "$_"`); - my $zonefile = "$master_dir/$domain/$domain"; - my $config = "$zone_conf_dir/$domain"; - my $utf8domain = "$_"; + chomp( my $domain = `idn --quiet "$_"` ); + my $zonefile = "$master_dir/$domain/$domain"; + my $config = "$zone_conf_dir/$domain"; + my $utf8domain = "$_"; - unless ( -d "$master_dir/$domain") { - `mkdir $master_dir/$domain`; - } + unless ( -d "$master_dir/$domain" ) { + `mkdir $master_dir/$domain`; + } - if (-f $zonefile) { - $zonefile =~ s#/.*/##; - print "$zonefile exists. Skipping $domain\n"; - next; - } - if (-f $config) { - $config =~ s#/.*/##; - print "$config exists. Skipping $domain\n"; - next; - } + if ( -f $zonefile ) { + $zonefile =~ s#/.*/##; + print "$zonefile exists. Skipping $domain\n"; + next; + } + if ( -f $config ) { + $config =~ s#/.*/##; + print "$config exists. Skipping $domain\n"; + next; + } - print "$domain ($_) for $customer \n"; + print "$domain ($_) for $customer \n"; - my @tempzone = ; - for (@tempzone) { - s##$start#; - s##$domain#; - s#