update-serial
changeset 8 654be00c18ee
parent 0 99443200522e
child 9 7ca31b207366
equal deleted inserted replaced
0:99443200522e 8:654be00c18ee
     8 # . test against an md5 sum, not just the date of the stamp file
     8 # . test against an md5 sum, not just the date of the stamp file
     9 # . FIXME: handle `/' in file names (currently only working in 
     9 # . FIXME: handle `/' in file names (currently only working in 
    10 #   the current directory)
    10 #   the current directory)
    11 # . optionally reload the named
    11 # . optionally reload the named
    12 
    12 
       
    13 use strict;
       
    14 use warnings;
       
    15 
    13 use File::Basename;
    16 use File::Basename;
    14 use File::Copy;
    17 use File::Copy;
    15 my $ME = basename $0;
    18 my $ME = basename $0;
    16 my @tmpfiles;
    19 my @tmpfiles;
    17 my $verbose = 0;
    20 my $verbose = 0;
    18 my $opt_yes = 0;
    21 my $opt_yes = 0;
    19 
    22 
       
    23 
    20 sub cleanup() { unlink @tmpfiles; }
    24 sub cleanup() { unlink @tmpfiles; }
    21 END { cleanup(); }
    25 END { cleanup(); }
    22 
    26 
    23 $ARGV[0] eq "-y" and $opt_yes = 1, shift;
    27 $ARGV[0] eq "-y" and $opt_yes = 1, shift;
    24 @Zones = @ARGV ? @ARGV : </etc/bind/p/*>;
    28 my @Zones = @ARGV ? @ARGV : </etc/bind/p/*>;
    25 
    29 
    26 
    30 
    27 MAIN: {
    31 MAIN: {
    28 	my $changed;
    32 	my $changed;
    29 	my ($dd, $mm, $yy) =(localtime())[3..5];
    33 	my ($dd, $mm, $yy) =(localtime())[3..5];
    33 	foreach ($dd, $mm) { s/^\d$/0$&/; }
    37 	foreach ($dd, $mm) { s/^\d$/0$&/; }
    34 	$yy += 1900;
    38 	$yy += 1900;
    35 	$date = "$yy$mm$dd";
    39 	$date = "$yy$mm$dd";
    36 
    40 
    37 
    41 
    38 	while ($file = shift @Zones) {
    42 	while (my $file = shift @Zones) {
    39 		local (*I, *O);
    43 		local (*I, *O);
    40 		my $done = 0;
    44 		my $done = 0;
    41 
    45 
    42 		my $new = "$file.$$.tmp";
    46 		my $new = "$file.$$.tmp";
    43 		my $bak = "$file.bak";
    47 		my $bak = "$file.bak";