check the soa record!
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Fri, 23 May 2014 11:46:36 +0200
changeset 8 5923d15fd57b
parent 7 286a373ab86b
child 9 ed4e20c01db3
check the soa record!
bin/dnsvi
lib/DNS/Vi.pm
--- a/bin/dnsvi	Thu May 22 23:34:23 2014 +0200
+++ b/bin/dnsvi	Fri May 23 11:46:36 2014 +0200
@@ -3,7 +3,7 @@
 use 5.010;
 use strict;
 use warnings;
-use if $ENV{DEBUG}//'' eq 'vidns' => 'Smart::Comments';
+use if $ENV{DEBUG}//'' eq 'dnsvi' => 'Smart::Comments';
 use File::Temp;
 use Getopt::Long;
 use Pod::Usage;
@@ -46,8 +46,13 @@
     my @zone2 = parse(<$tmp>);
     my ($add, $del) = delta(\@zone1, \@zone2);
 
-    my @cmds = ((map { "update add $_" } @$add),
-	       (map { "update delete $_" } @$del));
+    my $orig_soa = (grep { $_->{rrtype} eq 'SOA' } map { $_->{rrset} } @zone1)[0]; 
+
+    my @cmds = (
+	# 'prereq yxrrset {domain-name} [class] {type} {data…',
+	"prereq yxrrset @{$orig_soa}{qw{label rrtype data}}",
+	(map { "update add $_" } @$add),
+	(map { "update delete $_" } @$del));
 
     print <<_EOF, join "\n" => @cmds, '';
 # The following commands are about to be sent via nsupdate
@@ -61,7 +66,8 @@
 	exec @nsupdate;
 	die "Can't exec @nsupdate: $!\n";
     };
-    print $nsupdate join "\n", @cmds, 'send', '';
+    say $nsupdate join "\n", @cmds, 
+	'show', 'send', 'answer';
     close($nsupdate);
     say "nsupdate returned $?";
     return 0;
--- a/lib/DNS/Vi.pm	Thu May 22 23:34:23 2014 +0200
+++ b/lib/DNS/Vi.pm	Fri May 23 11:46:36 2014 +0200
@@ -1,7 +1,7 @@
 use 5.010;
 use strict;
 use warnings;
-use if $ENV{DEBUG}//''  eq 'vidns' => 'Smart::Comments';
+use if $ENV{DEBUG}//''  eq 'dnsvi' => 'Smart::Comments';
 use Digest::SHA qw(sha512_hex);
 
 use base 'Exporter';