in reply to DNS Failover
and repeat it for the other zone types. The serial number in 'date format' is unique enough that it's just not found anywhere else in the zone files I manage.`perl -pi -e 's/2007\d\d\d\d\d\d/2007102901/' *.com`
#!/usr/bin/perl use warnings; use strict; # # warning - untested code. # Let's find the largest serial number of the lot. # my $patt = qr{200\d{7}}; my $dns_zones = '/etc/named/primary/'; # chdir $dns_zones or die "Cannot enter zone file directory.\n"; my @zones = split /\n/, `ls -1`; my $curr_time = get_serial_number(); for my $z (@zones) { open (ZONE, "<", $z) or die("Cannot open zone file $z.\n"); while(<ZONE>) { # # I habitually follow the serial # with a space, a semicolon, a space # and the word 'serial' # if ( /($patt)\s+\;\s+serial/ ) { my $serial = $1; $curr_time = ++$serial if ( $serial > $curr_time ); last; } } close(ZONE); } print "Final time = $curr_time\n"; # # replace in place here. # sub get_serial_number { my @time = localtime(); my $day = substr("0" . $time[3], -2 ); my $month = $time[4] + 1; my $year = 1900 + $time[5]; return $year . $month . $day . "01"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DNS Failover
by bjensen34 (Initiate) on Oct 30, 2007 at 20:05 UTC |