--- a/mkready Thu Jul 15 15:33:01 2010 +0200
+++ b/mkready Wed Jul 21 14:04:05 2010 +0200
@@ -1,46 +1,70 @@
-#!/bin/bash
+#!/usr/bin/perl
-set -e
-source dnstools.conf
+use strict;
-domain="eins.lan"
-master_dir="$MASTER_DIR"
-conf_dir="$ZONE_CONF_DIR"
-bind_dir="$BIND_DIR"
+my $bind_dir = "/etc/bind";
+my $conf_dir = "/etc/bind/zones.d";
+my $master_dir = "/etc/bind/master";
+chomp (my @domains = `ls $master_dir`);
+chomp (my @conf_dir_files = `ls $conf_dir`);
-tmpfile=`mktemp`
-trap "rm -f $tmpfile" EXIT QUIT INI
+# prueft jede domain die einen verzeichniss in $master_dir hat, ob es eine
+# datei <$domain>.signed gibt und ob der eintrag in $conf_dir/$domain dem
+# ergebniss entspricht.
+# passt die eintraeg in der config-datei falls noetig an.
+foreach (@domains) {
+ my $domain = $_;
+ my $zone_file = "$master_dir/$domain/$domain";
+ my $conf_file = "$conf_dir/$domain";
+ my @c_content;
-for zone_domain in $master_dir/*
-do
- domain=${zone_domain##/*/}
- zone_dir="$master_dir/$domain"
- conf_file="$conf_dir/$domain"
- zone="$master_dir/$domain/$domain"
- zone_signed="$master_dir/$domain/$domain.signed"
+ if (-e "$zone_file.signed") {
+
+ open (FILE, $conf_file);
+ @c_content = <FILE>;
+ close (FILE);
+
+ foreach (@c_content) {
+ if (m{(.*)($zone_file)(";)}) {
+ print "$2 ==> $2.signed\n";
+ $_ = "$1$2.signed$3\n";
+ }
- # schreibt den eintrag ueber das zonefile um. ist ein signiertes zonefile vorhanden
- # wird es in der configdatei der zone im abschnitt file verlinkt. ist das zone-file
- # nicht signiert wird die standard-zonedatei eingetragen.
- if [ -f $master_dir/$domain/$domain.signed ]
- then
- if ! grep -q "file.*signed\"" $conf_file
- then
- sed -e "s\\$zone\\$zone_signed\\g" <$conf_file >$tmpfile
- mv $tmpfile $conf_file
- echo $zone '-->' $zone_signed
- fi
- else
- if grep -q "file.*signed\"" $conf_file
- then
- sed -e "s\\$zone_signed\\$zone\\g" <$conf_file >$tmpfile
- mv $tmpfile $conf_file
- echo $zone_signed '-->' $zone
- fi
- fi
-done
+ open (FILE, ">test");
+ print FILE @c_content;
+ close (FILE);
+
+ }
+
+ } else {
+
+ open (FILE, $conf_file);
+ @c_content = <FILE>;
+ close (DATEI);
+
+ foreach (@c_content) {
+ if (m{(.*)($zone_file)\.signed(.*)}) {
+ print "$2.signed ==> $2\n";
+ $_ = "$1$2$3\n";
+ }
+ }
-cat $conf_dir/* > $bind_dir/named.conf.zones
-named-checkconf
-named-checkconf -z
-rndc reload
+ open (FILE, ">$conf_file");
+ print FILE @c_content;
+ close (FILE);
+ }
+}
+
+# erzeugt eine named.conf-datei aus den entsprechenden vorlagen.
+open( TO, ">$bind_dir/named.conf.zones");
+foreach (@conf_dir_files) {
+ open (FROM, "$conf_dir/$_");
+ print TO <FROM>;
+ close (FROM);
+}
+close(TO);
+
+
+print `named-checkconf`;
+print `named-checkconf -z`;
+print `rndc reload`;