#!/usr/local/bin/perl # incsoa - increment SOA records in *.hosts and *.rev # # Copyright (c) 1996 by The Left Bank Operation # All Rights Reserved # use File::Basename; my $co = "/usr/local/bin/co"; my $ci = "/usr/local/bin/ci"; $|=1; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); my $serial = sprintf "%04d%02d%02d", $year+1900, ++$mon, $mday; foreach $file (@ARGV) { my ($filename,$filepath,$filesuffix) = fileparse($file); chdir $filepath or die "$0: can't chdir to $filepath: $!\n"; # system("$co -l $filename"); # warn "$0: can't check out $file, exit value: $exit\n" # if ($exit = ($? >> 8)); open OLD, "< $filename" or die "$0: can't read $filename: $!\n"; open NEW, "> $filename.new" or die "$0: can't write $filename.new: $!\n"; print "$filename:\t"; while () { /(\d+)(\d\d)\s+;\s*serial/i || next; $s1 = $1; $s2 = $2; $oldserial = $s1 . $s2; if ($s1 eq $serial) { $newserial = $serial . ++$s2; } else { $newserial = $serial . "01"; } s/$oldserial/$newserial/; print "$oldserial --> $newserial\n"; } continue { print NEW $_;} close OLD; close NEW; print `mv $filename.new $filename`; # this is no longer relevant since we're using rcs # print `chmod go+r $filename`; # system("$ci -m$newserial -u $filename"); # $rc = $? >> 8; if ( $rc != 0 ) { die "incsoa - can't check in $file\n"; } }