]> git.donarmstrong.com Git - bin.git/commitdiff
* handle munged serials
authorDon Armstrong <don@donarmstrong.com>
Sun, 8 Mar 2009 00:27:09 +0000 (00:27 +0000)
committerDon Armstrong <don@donarmstrong.com>
Sun, 8 Mar 2009 00:27:09 +0000 (00:27 +0000)
update_dns_serial

index 93a2b8580e6db4a0904dc482684e5711852b6456..9481402b4a2db7c00fd17ec850a932aa89b75e7d 100755 (executable)
@@ -13,10 +13,10 @@ for my $file (@ARGV) {
     my $fh_contents = <$fh>;
     # rip out old serial
     my ($old_serial) = $fh_contents =~ /IN\s+SOA\s+\S+\s+\S+\s*(?:\s*\;.+\n)*\((?:\s*\;.+\n)*\s*(\d+)/;
-    my ($ymd,$iter) = $old_serial =~ /(\d{4}\d{2}\d{2})(\d{2})/;
+    my ($ymd,$iter) = $old_serial =~ /(\d{4}\d{2}\d{2})(\d{1,2})/;
     my $new_serial = strftime("%Y%m%d",gmtime())."01";
     if ($ymd eq strftime("%Y%m%d",gmtime())) {
-       $new_serial = $ymd.($iter+1);
+       $new_serial = $ymd.sprintf('%02d',$iter+1);
     }
     $fh_contents =~ s/(IN\s+SOA\s+\S+\s+\S+\s*(?:\s*\;.+\n)*\((?:\s*\;.+\n)*\s*)(\d+)/${1}${new_serial}/;
     print {$fh_new} $fh_contents;