needed a way to also remove old entries that have been abandoned
This commit is contained in:
@ -10,8 +10,11 @@ my $force = shift; # a "force" flag, if the update is big
|
|||||||
my $ddns = Martnet::DDNS->new();
|
my $ddns = Martnet::DDNS->new();
|
||||||
|
|
||||||
my @vh = $ddns->get();
|
my @vh = $ddns->get();
|
||||||
|
my %vhh = map { $_->{zone} => 1 } @vh;
|
||||||
|
|
||||||
my @all = parse_slavefile("/etc/bind/martnet.slave.zones.9");
|
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
|
# For each virtual host, see if we've got it already
|
||||||
my $changecount = 0;
|
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 > 10 && !$force);
|
||||||
|
|
||||||
if ($changecount) {
|
if ($changecount) {
|
||||||
@ -66,6 +74,16 @@ sub do_rewrite {
|
|||||||
system("/usr/sbin/rndc reload");
|
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 {
|
sub contains_zone {
|
||||||
my ($zone, @zl) = @_;
|
my ($zone, @zl) = @_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user