From f342352a3a2a02aeffa936dc42deff2c5ed58f75 Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Sun, 31 Oct 2021 13:41:32 -0400 Subject: [PATCH] add -f force flag to rebuild all the master zones --- bin/sync-master-vhosts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/sync-master-vhosts b/bin/sync-master-vhosts index 180391c..8a65340 100755 --- a/bin/sync-master-vhosts +++ b/bin/sync-master-vhosts @@ -4,8 +4,15 @@ use strict; use warnings; use Martnet::DDNS; use File::Temp qw/tempfile/; +use Getopt::Std; + +# Use '-f' flag to force replacing all of the zone files (used when +# changing IPs) +my %opts; +getopts('f', \%opts); my $ddns = Martnet::DDNS->new(); +my $force_replace = $opts{f} ? 1 : 0; my @vh = $ddns->get('_vhosts'); @@ -13,7 +20,7 @@ my @vh = $ddns->get('_vhosts'); my $changecount = 0; foreach my $i (@vh) { my $zf = "/var/lib/bind/vhost/db.$i->{zone}"; - unless ( -f $zf ) { + unless ( $force_replace || -f $zf ) { print "Generating new zone file for $i->{zone}\n"; open(my $fh, ">", $zf) || die "Can't create output file $zf: $!";