--- a/local.pm.ex Mon Jan 19 10:53:06 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-# Example
-# $Id$
-# $URL$
-
-# remove the next line if you know, what you're doing
-die "Sure? You should adapt this file to your needs!";
-
-package local;
-
-# in: zone name
-# src ip
-# out: 0 failure ($@ contains message)
-# !0 ok ($@ may contain message)
-sub addZone($$) {
- my ($zone, $src) = @_;
-
- # Filename ist für das File selbst und auch für die Konfig
- (my $file = $zone) =~ s/[\/&|]/_/g;
-
- my $txt = <<__;
-// Autoadded %time by $0
-zone "$zone" IN {
- type slave;
- file "/etc/bind/s/$file";
- masters { %masters; };
- allow-query { any; };
- allow-transfer { none; };
-};
-
-__
-
- $txt =~ s/%time/scalar localtime/eg;
- $txt =~ s/%masters/$src/g;
-
- if (-f ($_ = "/etc/bind/zones.d/$file")) {
- $@ = "$_ already exists";
- return 0;
- }
-
- open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
- print OUT $txt;
-
- open(OUT, $_ = ">>/etc/bind/zones.all") or die "Can't open $_: $!\n";
- print OUT $txt;
-
- close OUT;
-
- # return 0 == system("rndc reload");
- local @ARGV = qw(/var/run/bind/run/named.pid);
- chomp($_ = <>);
- warn "Sending HUP to $_\n";
- $@ = "Nameserver reloaded (HUP sent)";
- kill "HUP", $_ and return 1;
-
- $@ = "No process $_";
- return 0;
-}
-
-
-1;
-# vim:sts=4 sw=4 aw ai sm:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/local.pm.ex-1 Mon Jan 19 10:53:16 2015 +0100
@@ -0,0 +1,61 @@
+# Example
+# $Id$
+# $URL$
+
+# remove the next line if you know, what you're doing
+die "Sure? You should adapt this file to your needs!";
+
+package local;
+
+# in: zone name
+# src ip
+# out: 0 failure ($@ contains message)
+# !0 ok ($@ may contain message)
+sub addZone($$) {
+ my ($zone, $src) = @_;
+
+ # Filename ist für das File selbst und auch für die Konfig
+ (my $file = $zone) =~ s/[\/&|]/_/g;
+
+ my $txt = <<__;
+// Autoadded %time by $0
+zone "$zone" IN {
+ type slave;
+ file "/etc/bind/s/$file";
+ masters { %masters; };
+ allow-query { any; };
+ allow-transfer { none; };
+};
+
+__
+
+ $txt =~ s/%time/scalar localtime/eg;
+ $txt =~ s/%masters/$src/g;
+
+ if (-f ($_ = "/etc/bind/zones.d/$file")) {
+ $@ = "$_ already exists";
+ return 0;
+ }
+
+ open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
+ print OUT $txt;
+
+ open(OUT, $_ = ">>/etc/bind/zones.all") or die "Can't open $_: $!\n";
+ print OUT $txt;
+
+ close OUT;
+
+ # return 0 == system("rndc reload");
+ local @ARGV = qw(/var/run/bind/run/named.pid);
+ chomp($_ = <>);
+ warn "Sending HUP to $_\n";
+ $@ = "Nameserver reloaded (HUP sent)";
+ kill "HUP", $_ and return 1;
+
+ $@ = "No process $_";
+ return 0;
+}
+
+
+1;
+# vim:sts=4 sw=4 aw ai sm:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/local.pm.ex-2 Mon Jan 19 10:53:16 2015 +0100
@@ -0,0 +1,51 @@
+# Example
+# $Id$
+# $URL$
+
+# remove the next line if you know, what you're doing
+#die "Sure? You should adapt this file to your needs!";
+
+package local;
+
+# in: zone name
+# src ip
+# out: 0 failure ($@ contains message)
+# !0 ok ($@ may contain message)
+sub addZone($$) {
+ my ($zone, $src) = @_;
+ my $hdns = '84.19.194.5';
+
+ # Filename ist für das File selbst und auch für die Konfig
+ (my $file = $zone) =~ s/[\/&|]/_/g;
+
+ # 84.19.194.5 ist die ip unseres hidden master
+ my $transferees = $src eq $hdns ? 'localhost; key hh.schlittermann.de' : 'none';
+
+ my $txt = <<__;
+{
+ type slave;
+ file "/etc/cache/bind/slave/$file";
+ masters { $src; };
+ allow-query { any; };
+ allow-transfer { $transferees; };
+};
+
+__
+
+ system rndc => (
+ addzone => $zone,
+ $txt
+ );
+
+ if ($?) {
+ warn "rndc addzone $zone failed\n";
+ return 0;
+ }
+
+ warn "zone $zone added via rndc addzone\n";
+ return 1;
+
+}
+
+1;
+# vim:sts=4 sw=4 aw ai sm: