--- a/dnssec-creatkey Mon Aug 02 13:45:47 2010 +0200
+++ b/dnssec-creatkey Wed Aug 04 11:27:21 2010 +0200
@@ -1,9 +1,21 @@
#!/usr/bin/perl -w
use strict;
+use FindBin;
+
+# liest die Konfiguration ein
+my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
my %config;
-open (CONFIG, "dnstools.conf");
+
+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"
+}
+
while (<CONFIG>) {
chomp;
s/#.*//;
--- a/dnssec-killkey Mon Aug 02 13:45:47 2010 +0200
+++ b/dnssec-killkey Wed Aug 04 11:27:21 2010 +0200
@@ -1,9 +1,21 @@
#!/usr/bin/perl -w
use strict;
+use FindBin;
+
+# liest die Konfiguration ein
+my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
my %config;
-open (CONFIG, "dnstools.conf");
+
+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"
+}
+
while (<CONFIG>) {
chomp;
s/#.*//;
@@ -23,18 +35,19 @@
my @auto;
chomp (my $now_time=`date +%s`); # aktuelle unixzeit
+
# prueft zonen aus ARGV und loescht das schluesselmaterial
for (@ARGV) {
chomp ($zone = `idn --quiet $_`);
my $zdir = "$master_dir/$zone";
if (-e "$master_dir/$zone") {
- if (-e "$zdir/$zone.signed") { unlink $zdir/$zone.signed}
- if (-e "$zdir/.keycounter") { unlink $zdir/.keycounter}
- if (-e "$zdir/.index.ksk") { unlink $zdir/.index.ksk}
- if (-e "$zdir/.index.zsk") { unlink $zdir/.index.zsk}
- if (-e "$zdir/dsset-$zone.") { unlink $zdir/dsset-$zone.}
- if (-e "$zdir/keyset-$zone.") { unlink $zdir/keyset-$zone.}
+ if (-e "$zdir/$zone.signed") { unlink "$zdir/$zone.signed"}
+ if (-e "$zdir/.keycounter") { unlink "$zdir/.keycounter"}
+ if (-e "$zdir/.index.ksk") { unlink "$zdir/.index.ksk"}
+ if (-e "$zdir/.index.zsk") { unlink "$zdir/.index.zsk"}
+ if (-e "$zdir/dsset-$zone.") { unlink "$zdir/dsset-$zone."}
+ if (-e "$zdir/keyset-$zone.") { unlink "$zdir/keyset-$zone."}
for (`ls $master_dir/$zone/K*[key,private]`){ unlink $_}
--- a/dnssec-sign Mon Aug 02 13:45:47 2010 +0200
+++ b/dnssec-sign Wed Aug 04 11:27:21 2010 +0200
@@ -2,16 +2,21 @@
use strict;
use warnings;
+use FindBin;
-my @configs = qw(dnstools.conf /etc/dnstools.conf);
+
+# 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";
+for (grep {-f} @configs) {
+ open(CONFIG, $_) or die "Can't open $_: $!\n";
}
-die "Can't open config (searched: @configs)\n"
- if not seek(CONFIG, 0, 0);
-my %config;
+unless (seek(CONFIG,0 ,0 )) {
+ die "Can't open config (searched: @configs)\n"
+}
+
while (<CONFIG>) {
chomp;
s/#.*//;
--- a/mkready Mon Aug 02 13:45:47 2010 +0200
+++ b/mkready Wed Aug 04 11:27:21 2010 +0200
@@ -1,32 +1,49 @@
#!/usr/bin/perl
use strict;
+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;
}
close (CONFIG);
-
my $bind_dir = $config{bind_dir};
my $conf_dir = $config{zone_conf_dir};
my $master_dir = $config{master_dir};
-chomp (my @conf_dir_files = `ls $conf_dir`);
+
+unless (-d $master_dir and -r $master_dir) {
+ die "$master_dir: $!\n";
+}
+
+unless (-d $bind_dir and -r $bind_dir) {
+ die "$bind_dir: $!\n";
+}
# prueft jede domain, die ein verzeichnis in $master_dir hat, ob es eine
# datei $zone_file.signed gibt und ob diese datei in $config_file eingetragen
# ist.
# passt die eintraege in $config_file falls noetig an.
-for (<$master_dir/*>) {
+while (<$master_dir/*>) {
s#($master_dir/)(.*)#$2#;
my $zone = $_;
@@ -34,9 +51,13 @@
my $conf_file = "$conf_dir/$zone";
my @c_content;
- if (-e "$zone_file.signed") {
+ unless (-f "$conf_file" ) {
+ die "$conf_file: $! \n";
+ }
- open (FILE, $conf_file);
+ if (-f "$zone_file.signed") {
+
+ open (FILE, "<$conf_file") or die "$conf_file: $!\n";
@c_content = <FILE>;
close (FILE);
@@ -46,15 +67,15 @@
$_ = "$1$2.signed$3\n";
}
- open (FILE, ">$conf_file");
+ open (FILE, ">$conf_file") or die "$conf_file: $!\n";
print FILE @c_content;
close (FILE);
}
+ }
+ else {
- } else {
-
- open (FILE, $conf_file);
+ open (FILE, "<$conf_file") or die "$conf_file: $!\n";
@c_content = <FILE>;
close (FILE);
@@ -65,22 +86,22 @@
}
}
- open (FILE, ">$conf_file");
+ open (FILE, ">$conf_file") or die "$conf_file: $!\n";
print FILE @c_content;
close (FILE);
}
}
# erzeugt eine named.conf-datei aus den entsprechenden vorlagen.
-open( TO, ">$bind_dir/named.conf.zones");
-for (@conf_dir_files) {
- open (FROM, "$conf_dir/$_");
+open( TO, ">$bind_dir/named.conf.zones") or die "$bind_dir/named.conf.zones: $!\n";
+while (<$conf_dir/*>) {
+ open (FROM, "$_") or die "$_: $! \n";
print TO <FROM>;
close (FROM);
}
close(TO);
-print `named-checkconf`;
-print `named-checkconf -z`;
-print `rndc reload`;
+system "named-checkconf";
+system "named-checkconf -z";
+system "rndc reload";
--- a/zone-ls Mon Aug 02 13:45:47 2010 +0200
+++ b/zone-ls Wed Aug 04 11:27:21 2010 +0200
@@ -3,32 +3,44 @@
use strict;
use warnings;
use File::Basename;
+use FindBin;
+
+# liest die Konfiguration ein
+my @configs = ("$FindBin::Bin/dnstools.conf", "/etc/dnstools.conf");
my %config;
-open (CONFIG, $_ = "<dnstools.conf") 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"
+}
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 $zone;
+my ($info_zsk, $info_ksk, $info_kc, $info_end);
-die "$config{master_dir}: $!\n"
- if not -d $config{master_dir} or not -r $config{master_dir};
+unless (-d $master_dir and -r $master_dir) {
+ die "$master_dir: $!\n";
+}
+
printf "%-25s %1s/%1s %3s %7s\n", "Domain", "ZSK", "KSK", "Used", "Sig-end";
-my $zone;
-my ($info_zsk, $info_ksk, $info_kc, $info_end);
-
foreach my $dir (glob "$master_dir/*") {
$zone = basename($dir);
--- a/zone-mk Mon Aug 02 13:45:47 2010 +0200
+++ b/zone-mk Wed Aug 04 11:27:21 2010 +0200
@@ -1,20 +1,45 @@
#!/usr/bin/perl -w
use strict;
+use FindBin;
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 %config;
-open (CONFIG, "dnstools.conf");
+
+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";
+}
+
+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";
+}
+
+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";
+}
+
while (<CONFIG>) {
chomp;
s/#.*//;
s/\t//g;
s/\s//g;
-
next unless length;
my ($cname, $ccont) = split (/\s*=\s*/, $_,2);
$config{$cname} = $ccont;
@@ -36,20 +61,18 @@
chomp (my $start= `date -I`);
my $hostmaster = "hostmaster.$this_domain";
-unless (-e $master_dir) {
- print "$master_dir nicht vorhanden \n";
- exit 1;
+unless (-d $master_dir and -r $master_dir) {
+ die "$master_dir: $!\n";
}
-unless (-e $zone_conf_dir) {
- print "$zone_conf_dir nicht vorhanden \n";
- exit 1;
+
+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 "$_"`);
@@ -57,16 +80,16 @@
my $config = "$zone_conf_dir/$domain";
my $utf8domain = "$_";
- unless ( -e "$master_dir/$domain") {
+ unless ( -d "$master_dir/$domain") {
`mkdir $master_dir/$domain`;
}
- if (-e $zonefile) {
+ if (-f $zonefile) {
$zonefile =~ s#/.*/##;
print "$zonefile exists. Skipping $domain\n";
next;
}
- if (-e $config) {
+ if (-f $config) {
$config =~ s#/.*/##;
print "$config exists. Skipping $domain\n";
next;
@@ -74,10 +97,7 @@
print "$domain ($_) for $customer \n";
- open (TEMPZONE, "templates/named.zone");
my @tempzone = <TEMPZONE>;
- close (TEMPZONE);
-
for (@tempzone) {
s#<start>#$start#;
s#<domain>#$domain#;
@@ -93,10 +113,7 @@
print ZONEOUT @tempzone;
close (ZONEOUT);
- open (TEMPCONF, "templates/named.config");
my @tempconf = <TEMPCONF>;
- close (TEMPCONF);
-
for (@tempconf) {
s#<domain>#$domain#;
s#<start>#$start#;
--- 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";
}
}