needed a way to also remove old entries that have been abandoned

This commit is contained in:
2020-11-22 11:56:59 -05:00
parent 99bee8938a
commit bcbbb1fda6

View File

@ -10,8 +10,11 @@ my $force = shift; # a "force" flag, if the update is big
my $ddns = Martnet::DDNS->new();
my @vh = $ddns->get();
my %vhh = map { $_->{zone} => 1 } @vh;
my @all = parse_slavefile("/etc/bind/martnet.slave.zones.9");
my %allh = all_zones_hash(@all);
use Data::Dumper;
# For each virtual host, see if we've got it already
my $changecount = 0;
@ -21,7 +24,12 @@ foreach my $i (@vh) {
}
}
die "Cowardly refusing to make a big update automatically"
foreach my $i (keys %allh) {
$changecount++
unless ($vhh{$i});
}
die "Cowardly refusing to make a big update automatically [$changecount]"
if ($changecount > 10 && !$force);
if ($changecount) {
@ -66,6 +74,16 @@ sub do_rewrite {
system("/usr/sbin/rndc reload");
}
sub all_zones_hash {
my (@zl) = @_;
my %ret;
foreach my $i (@zl) {
$ret{$i->{zone}}++;
}
return %ret;
}
sub contains_zone {
my ($zone, @zl) = @_;