add -f force flag to rebuild all the master zones
This commit is contained in:
@ -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: $!";
|
||||
|
||||
Reference in New Issue
Block a user