# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1400966202 -7200 # Node ID 1cbe9dc60243d0ef70181aeb319464c130c48968 # Parent aa1598910bb0bf0d3118fea3e51451b86d5ce95c save the edited file, not the parsed and niced one diff -r aa1598910bb0 -r 1cbe9dc60243 bin/dnsvi --- a/bin/dnsvi Sat May 24 23:01:17 2014 +0200 +++ b/bin/dnsvi Sat May 24 23:16:42 2014 +0200 @@ -6,6 +6,7 @@ use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments'; use Getopt::Long; use Pod::Usage; +use File::Copy; use blib; use DNS::Vi; @@ -51,12 +52,13 @@ my @zone1 = parse($_ = `@dig`, { -skip => $o{skip} } ) or die "Empty zone\n"; + my $fh2; my @zone2 = do { if (my $file = shift @ARGV) { parse(slurp($file), { -skip => $o{skip} }); } else { - edit(@zone1, { -skip => $o{skip}, -editor => $o{editor} }); + edit(@zone1, { -skip => $o{skip}, -editor => $o{editor}, -backup => \$fh2 }); } }; ### @zone2 @@ -78,8 +80,9 @@ -debug => $o{debug}, -key => $o{key}}) or do { - save(\@zone2, ",dnsvi-$$") - and say "Saved as ',dnsvi-$$'"; + copy($fh2->filename, ",dnsvi-$$") + and say "Saved as ',dnsvi-$$'" + if $fh2; }; return 0; @@ -95,12 +98,13 @@ =head1 SYNOPSIS - vidns [-l] [-k key] [-s server] [-d] [] + vidns [[-l] | [[-k key] [-s server]]] [-d] [] =head1 DESCRIPTION -This tools supports you in maintaining a dynamic -zone. +This tools supports you in maintaining a dynamic zone. Normally you'll +use it with the name of zone. For batch mode you may use it with an +additional parameter, die edited zone file. =head2 OPTIONS @@ -121,6 +125,10 @@ The name of the key file we need for TSIG (the AXFR will use it, as well as the update). +=item B<-d> + +This option enables debugging of C. (default: off) + =back =head1 PREREQUISITES diff -r aa1598910bb0 -r 1cbe9dc60243 lib/DNS/Vi.pm --- a/lib/DNS/Vi.pm Sat May 24 23:01:17 2014 +0200 +++ b/lib/DNS/Vi.pm Sat May 24 23:16:42 2014 +0200 @@ -8,7 +8,7 @@ use base 'Exporter'; -our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show save); +our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show); our @EXPORT_OK = (); sub parse { @@ -187,6 +187,7 @@ $tmp->flush(); system $arg{-editor} => $tmp->filename; $tmp->seek(0, 0); + ${$arg{-backup}} = $tmp if $arg{-backup}; return parse(do { local $/ = undef; <$tmp>}, {-skip => $arg{-skip}}); }