change shape for bind configuration; use one unified file, add new options when adding zones

This commit is contained in:
2026-01-24 12:15:15 -05:00
parent f2b2ba25f0
commit ff83f9c5de
16 changed files with 167 additions and 81 deletions

17
bin/sync-slave Executable file → Normal file
View File

@@ -10,7 +10,7 @@ my $force = shift; # a "force" flag, if the update is big
my $ddns = Martnet::DDNS->new();
my @vh = $ddns->get();
my @vh = $ddns->get('_pureslave');
my %vhh = map { $_->{zone} => 1 } @vh;
my @all = parse_slavefile("/etc/bind/martnet.slave.zones.9");
@@ -62,8 +62,9 @@ sub do_rewrite {
print "Differences found; rewriting slave file.\n";
foreach my $i (sort {$a->{zone} cmp $b->{zone}} @vh) {
next if ($i->{type} eq '_dnssec');
print $fh "zone \"$i->{zone}\" { type slave; file \"/var/cache/bind/db.$i->{zone}\"; masters { $i->{master}; }; allow-notify {key \"notify-key\";}; };\n";
die "No master(s) found for slave zone $i->{zone}"
unless defined($i->{master}) && $i->{master} ne '';
print $fh "zone \"$i->{zone}\" { type slave; file \"/var/cache/bind/db.$i->{zone}\"; masters { $i->{master}; }; allow-notify {key \"notify-key\";}; };\n";
}
close $fh;
print "Installing new slave host list\n";
@@ -89,13 +90,11 @@ sub contains_zone {
foreach my $i (@zl) {
if ($i->{zone} eq $zone->{zone}) {
print "m: '$i->{master}' ne '$zone->{master}'\n"
unless ($i->{master} eq $zone->{master});
print "m: '$i->{master}' ne '$zone->{master}'\n"
unless ($i->{master} eq $zone->{master});
return 1
if ($i->{master} eq $zone->{master});
}
return 1
if ($i->{zone} eq $zone->{zone} &&
$i->{master} eq $zone->{master}
);
}
return 0;
}