equal
deleted
inserted
replaced
1 #! /usr/bin/perl |
1 #! /usr/bin/perl |
2 #line 2 |
2 #line 2 |
3 use 5.010; |
3 use 5.010; |
4 use strict; |
4 use strict; |
5 use warnings; |
5 use warnings; |
6 use if $ENV{DEBUG}//'' eq 'vidns' => 'Smart::Comments'; |
6 use if $ENV{DEBUG}//'' eq 'dnsvi' => 'Smart::Comments'; |
7 use File::Temp; |
7 use File::Temp; |
8 use Getopt::Long; |
8 use Getopt::Long; |
9 use Pod::Usage; |
9 use Pod::Usage; |
10 |
10 |
11 use blib; |
11 use blib; |
44 system $ENV{EDITOR} // 'vi' => $tmp->filename; |
44 system $ENV{EDITOR} // 'vi' => $tmp->filename; |
45 $tmp->seek(0, 0); |
45 $tmp->seek(0, 0); |
46 my @zone2 = parse(<$tmp>); |
46 my @zone2 = parse(<$tmp>); |
47 my ($add, $del) = delta(\@zone1, \@zone2); |
47 my ($add, $del) = delta(\@zone1, \@zone2); |
48 |
48 |
49 my @cmds = ((map { "update add $_" } @$add), |
49 my $orig_soa = (grep { $_->{rrtype} eq 'SOA' } map { $_->{rrset} } @zone1)[0]; |
50 (map { "update delete $_" } @$del)); |
50 |
|
51 my @cmds = ( |
|
52 # 'prereq yxrrset {domain-name} [class] {type} {data…', |
|
53 "prereq yxrrset @{$orig_soa}{qw{label rrtype data}}", |
|
54 (map { "update add $_" } @$add), |
|
55 (map { "update delete $_" } @$del)); |
51 |
56 |
52 print <<_EOF, join "\n" => @cmds, ''; |
57 print <<_EOF, join "\n" => @cmds, ''; |
53 # The following commands are about to be sent via nsupdate |
58 # The following commands are about to be sent via nsupdate |
54 # to the master server: |
59 # to the master server: |
55 _EOF |
60 _EOF |
59 my @nsupdate = ('nsupdate', defined $o{debug} ? ('-d') : (), defined $o{key} ? (-k => $o{key}) : ()); |
64 my @nsupdate = ('nsupdate', defined $o{debug} ? ('-d') : (), defined $o{key} ? (-k => $o{key}) : ()); |
60 open(my $nsupdate, '|-') or do { |
65 open(my $nsupdate, '|-') or do { |
61 exec @nsupdate; |
66 exec @nsupdate; |
62 die "Can't exec @nsupdate: $!\n"; |
67 die "Can't exec @nsupdate: $!\n"; |
63 }; |
68 }; |
64 print $nsupdate join "\n", @cmds, 'send', ''; |
69 say $nsupdate join "\n", @cmds, |
|
70 'show', 'send', 'answer'; |
65 close($nsupdate); |
71 close($nsupdate); |
66 say "nsupdate returned $?"; |
72 say "nsupdate returned $?"; |
67 return 0; |
73 return 0; |
68 } |
74 } |
69 |
75 |