--- a/mkready Wed Jul 21 14:04:05 2010 +0200
+++ b/mkready Thu Jul 22 12:44:14 2010 +0200
@@ -8,10 +8,10 @@
chomp (my @domains = `ls $master_dir`);
chomp (my @conf_dir_files = `ls $conf_dir`);
-# 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.
+# 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.
foreach (@domains) {
my $domain = $_;
my $zone_file = "$master_dir/$domain/$domain";
--- a/templates/named.config Wed Jul 21 14:04:05 2010 +0200
+++ b/templates/named.config Thu Jul 22 12:44:14 2010 +0200
@@ -1,10 +1,10 @@
-zone "[% domain %]" {
-// Start: [% start %]
-// Invoice: [% customer %]
-// UTF8: [% utf8domain %]
+zone "<domain>" {
+// Start: <start>
+// Invoice: <customer>
+// UTF8: <utf8domain>
type master;
- file "[% file %]";
- allow-transfer { localhost; [% primary_ip %]; [% secondary_ip %]; };
+ file "<file>";
+ allow-transfer { localhost; <primary_ip>; <secondary_ip>; };
allow-query { any; };
- also-notify { [% primary_ip %]; };
+ also-notify { <primary_ip>; };
};
--- a/templates/named.zone Wed Jul 21 14:04:05 2010 +0200
+++ b/templates/named.zone Thu Jul 22 12:44:14 2010 +0200
@@ -1,17 +1,17 @@
-$ORIGIN [% domain %].
+$ORIGIN <domain>.
$TTL 1d
-@ IN SOA [% primary %]. [% hostmaster %]. (
- [% time %] ; serial
+@ IN SOA <primary>. <hostmaster>. (
+ <time> ; serial
1d ; refresh
2h ; retry
7d ; expire
1d ; default ttl
)
- IN TXT "invoice: [% customer %]"
- IN TXT "start: [% start %]"
- IN TXT "utf8: [% utf8domain %]"
+ IN TXT "invoice: <customer>"
+ IN TXT "start: <start>"
+ IN TXT "utf8: <utf8domain>"
- IN NS [% primary %].
- IN NS [% secondary %].
+ IN NS <primary>.
+ IN NS <secondary>.
--- a/zone-mk Wed Jul 21 14:04:05 2010 +0200
+++ b/zone-mk Thu Jul 22 12:44:14 2010 +0200
@@ -1,100 +1,99 @@
-#! /bin/bash
-
-while getopts "d" opt; do
- case $opt in
- d) opt_debug=1;;
- ?) exit 1;;
- esac
-done
+#!/usr/bin/perl -w
-if test $# -lt 2; then
- echo "usage: $0 kundennummer domain..." >&2
- exit
-fi
+use strict;
-customer="$1"; shift
-start=$(date -I)
-
-# config
-source dnstools.conf
-
-primary=$PRIMARY
-primary_ip=${PRIMARY_IP:-$(dig +short $primary)}
-secondary=$SECONDARY
-secondary_ip=${SECONDARY_IP:-$(dig +short $secondary)}
-
-this_host=${THIS_HOST:-$(hostname -f)}
-this_ip=${THIS_IP:-$(hostname -i)}
-this_domain=${THIS_DOMAIN:-$(hostname -d)}
-primary=${PRIMARY:-$this_host}
-
-hostmaster=${HOSTMASTER:-"hostmaster.$this_domain"}
-
-zone_conf_dir=${ZONE_CONF_DIR:-/etc/bind/zones.d}
-master_dir=${MASTER_DIR:-/etc/bind/master}
-
-if [ ! -d $master_dir ]
-then
- echo $master_dir nicht gefunden
- exit 1
-fi
-
-if [ ! -d $zone_conf_dir ]
-then
- echo $zone_conf_dir nicht gefunden
- exit 1
-fi
+if (@ARGV < 2) {
+ print "usage: zone-mk kundennummer domain ... \n";
+ exit 1;
+}
-# debug option
-if test $opt_debug; then
- cat <<xxx
-this host: $this_host [$this_ip]
-this domain: $this_domain
-primary: $primary
-secondary: $secondary [$secondary_ip]
-hostmaster: $hostmaster
-zone config directory: $zone_conf_dir
-xxx
- exit
-fi
-
-for utf8domain in "$@"; do
- domain=$(idn --quiet "$utf8domain")
-
- test -d $master_dir/$domain || mkdir $master_dir/$domain
-
- zonefile=$master_dir/$domain/$domain
- config=$zone_conf_dir/$domain
-
- echo "$domain ($utf8domain)"
+my $primary = "pu.schlittermann.de";
+my $secondary= "hh.schlittermann.de";
+my $zone_conf_dir= "/etc/bind/zones.d";
+my $master_dir = "/etc/bind/master";
+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";
- test -f $zonefile && { echo "$zonefile exists. Skipping $domain" >&2; continue; }
- test -f $config && { echo "$config exists. Skipping $domain" >&2; continue; }
-
- tpage \
- --define start="$start" \
- --define domain="$domain" \
- --define time="$(date +%Y%m%d00)" \
- --define primary="$primary" \
- --define secondary="$secondary" \
- --define hostmaster="$hostmaster" \
- --define customer="$customer" \
- --define utf8domain="$utf8domain" \
- templates/named.zone \
- >$zonefile
-
- tpage \
- --define domain="$domain" \
- --define start="$start" \
- --define customer="$customer" \
- --define utf8domain="$utf8domain" \
- --define file="$master_dir/$domain/$domain" \
- --define primary_ip="$primary_ip" \
- --define secondary_ip="$secondary_ip" \
- templates/named.config \
- >$config
-
-done
+if (! -e $master_dir) {
+ print "$master_dir nicht vorhanden \n";
+ exit 1;
+}
+if (! -e $zone_conf_dir) {
+ print "$zone_conf_dir nicht vorhanden \n";
+ exit 1;
+}
+# legt fuer jede domain in @ARGV ein verzeichnis in $master_dir an.
+# schreibt aus den angegeben templates die dateien $zonefile und $config
+# in die entsprechenden verzeichnisse.
+
+foreach (@ARGV) {
+
+ chomp (my $domain = `idn --quiet "$_"`);
+ my $zonefile = "$master_dir/$domain/$domain";
+ my $config = "$zone_conf_dir/$domain";
+ my $utf8domain = "$_";
+
+ if (! -e "$master_dir/$domain") {
+ `mkdir $master_dir/$domain`;
+ }
+
+ if (-e $zonefile) {
+ $zonefile =~ s#/.*/##;
+ print "$zonefile exists. Skipping $domain\n";
+ next;
+ }
+ if (-e $config) {
+ $config =~ s#/.*/##;
+ print "$config exists. Skipping $domain\n";
+ next;
+ }
+
+ print "$domain ($_) for $customer \n";
+
+ open (TEMPZONE, "templates/named.zone");
+ my @tempzone = <TEMPZONE>;
+ close (TEMPZONE);
+
+ foreach (@tempzone) {
+ s#<start>#$start#;
+ s#<domain>#$domain#;
+ s#<time>#$time#;
+ s#<primary>#$primary#;
+ s#<secondary>#$secondary#;
+ s#<hostmaster>#$hostmaster#;
+ s#<customer>#$customer#;
+ s#<utf8domain>#$utf8domain#;
+ }
+
+ open (ZONEOUT, ">$zonefile");
+ print ZONEOUT @tempzone;
+ close (ZONEOUT);
+
+ open (TEMPCONF, "templates/named.config");
+ my @tempconf = <TEMPCONF>;
+ close (TEMPCONF);
+
+ foreach (@tempconf) {
+ s#<domain>#$domain#;
+ s#<start>#$start#;
+ s#<customer>#$customer#;
+ s#<utf8domain>#$utf8domain#;
+ s#<file>#$master_dir/$domain/$domain#;
+ s#<primary_ip>#$primary_ip#;
+ s#<secondary_ip>#$secondary_ip#;
+ }
+
+ open (CONFOUT, ">$config" );
+ print CONFOUT @tempconf;
+ close (CONFOUT);
+}
--- a/zone-rm Wed Jul 21 14:04:05 2010 +0200
+++ b/zone-rm Thu Jul 22 12:44:14 2010 +0200
@@ -1,17 +1,20 @@
-#!/bin/bash
+#!/usr/bin/perl -w
+
+use strict;
-source dnstools.conf
+my $master_dir = "/etc/bind/master";
+my $conf_dir = "/etc/bind/zones.d";
-master_dir=$MASTER_DIR
-conf_dir=$ZONE_CONF_DIR
+foreach (@ARGV) {
+ chomp (my $domain = `idn --quiet $_`);
-for utf8domain in $@
-do
-
- domain=$(idn --quiet $utf8domain )
- echo $domain
-
- test -d $master_dir/$domain && rm -rf $master_dir/$domain && echo "-> Zonedatei entfernt"
- test -f $conf_dir/$domain && rm -f $conf_dir/$domain && echo "-> Konfiguration entfernt"
+ if (-e "$master_dir/$domain") {
+ `rm -rf $master_dir/$domain`;
+ print "zone-dir for $domain removed\n";
+ }
-done
+ if (-e "$conf_dir/$domain") {
+ `rm -f $conf_dir/$domain`;
+ print "configuration-file for $domain removed\n";
+ }
+}