From 7b50aa74abc9bf69c08ceeede34ffd5dbb13cdba Mon Sep 17 00:00:00 2001 From: root Date: Tue, 1 Nov 2022 13:46:17 +0000 Subject: [PATCH] fixed regex --- bin/sync-slave | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/sync-slave b/bin/sync-slave index 2738157..87c84d1 100755 --- a/bin/sync-slave +++ b/bin/sync-slave @@ -4,6 +4,7 @@ use strict; use warnings; use Martnet::DDNS; use File::Temp qw/tempfile/; +use Data::Dumper; my $force = shift; # a "force" flag, if the update is big @@ -14,12 +15,12 @@ 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; foreach my $i (@vh) { unless (contains_zone($i, @all)) { + print "don't have $i->{zone}\n"; $changecount++; } } @@ -45,7 +46,7 @@ sub parse_slavefile { open(my $fh, $f) || die "Can't open $f: $!"; while (<$fh>) { - if (/^zone\s+\"([^\"]+)\"\s+\{.+masters\s?\{\s?([^;]+);/) { + if (/^zone\s+\"([^\"]+)\"\s+\{.+masters\s?\{\s?(.+);\s?\};\s?\};/) { push ( @ret, { zone => $1, master => $2 } ); @@ -85,6 +86,10 @@ sub contains_zone { my ($zone, @zl) = @_; foreach my $i (@zl) { + if ($i->{zone} eq $zone->{zone}) { + print "m: '$i->{master}' ne '$zone->{master}'\n" + unless ($i->{master} eq $zone->{master}); + } return 1 if ($i->{zone} eq $zone->{zone} && $i->{master} eq $zone->{master}