[merged] suess
authorHeiko Schlittermann <hs@schlittermann.de>
Mon, 02 Aug 2010 12:03:12 +0200
branchsuess
changeset 3 aa1631182916
parent 1 b4dbb957f54b
child 4 da5c12e84a6b
[merged]
update-serial
--- a/update-serial	Thu Jul 15 16:33:26 2010 +0200
+++ b/update-serial	Mon Aug 02 12:03:12 2010 +0200
@@ -13,18 +13,27 @@
 #   the current directory)
 # . optionally reload the named
 
+use strict;
+use warnings;
+
 use File::Basename;
 use File::Copy;
+
+my $dnssec_sign = "/home/asuess/dnstools/dnssec-sign";
+my $master_dir = "/etc/bind/master";
+
 my $ME = basename $0;
 my @tmpfiles;
 my $verbose = 0;
 my $opt_yes = 0;
+my @Zones;
+my $file;
 
 sub cleanup() { unlink @tmpfiles; }
 END { cleanup(); }
 
 $ARGV[0] eq "-y" and $opt_yes = 1, shift;
-@Zones = @ARGV ? @ARGV : </etc/bind/p/*>;
+@Zones = @ARGV ? @ARGV : glob("$master_dir/*");
 
 
 MAIN: {
@@ -38,13 +47,17 @@
 	$date = "$yy$mm$dd";
 
 
-	while ($file = shift @Zones) {
+	while (my $file = shift @Zones) {
+
+		my $file_basename = basename($file);
+
+		$file =~ s#($master_dir)(/.*)#$1$2$2#;
 		local (*I, *O);
 		my $done = 0;
 
 		my $new = "$file.$$.tmp";
 		my $bak = "$file.bak";
-		my $stamp = dirname($file) . "/.stamp/" . basename($file);	
+		my $stamp = $master_dir . "/.stamp/" . basename($file);	
 
 		$file =~ /(\.bak|~)$/ and next;
 		$file !~ /\./ and next;
@@ -74,6 +87,10 @@
 				print " bumping to $sdate$scount";
 				s/$serial/$sdate$scount/;
 
+				# dnssec - new sign
+				if (-e "$dnssec_sign") {
+					print `$dnssec_sign $file_basename`;
+				}
 			};
 			print O;
 		}