include pod-usage and get-option in dnssec-keytool hs12
authorAndre Suess <andre.suess@pipkin.cc>
Thu, 30 Dec 2010 15:29:33 +0100
branchhs12
changeset 66 c44bc1c8e396
parent 64 86418a892c76
child 67 6adcf16d5cd6
include pod-usage and get-option in dnssec-keytool
dnssec-keytool.pl
update-serial.pl
--- a/dnssec-keytool.pl	Thu Dec 30 12:42:59 2010 +0100
+++ b/dnssec-keytool.pl	Thu Dec 30 15:29:33 2010 +0100
@@ -4,11 +4,17 @@
 use strict;
 use FindBin;
 use File::Temp;
+use Getopt::Long;
+use Pod::Usage;
 
 sub read_conf;
 sub read_argv($);
 sub rm_keys(@);
+sub ck_zone(@);
+sub creat_ksk(@);
 sub creat_zsk(@);
+sub post_creat(@);
+
 
 MAIN: {
     my @zone;
@@ -28,6 +34,30 @@
     post_creat($conf{master_dir}, @zone);
 }
 
+sub read_argv ($) {
+    my $master_dir = $_[0];
+	my $zone;
+    my $do;      # return
+    my @zone;    # return
+
+	GetOptions(
+	"z"		=> sub { $do = "zsk" },
+	"k"	    => sub { $do = "ksk" },
+	"h"		=> sub {pod2usage},
+	"r"     => sub { $do = "rm" },
+	"c"		=> sub { $do = "ck" },
+	) or pod2usage;
+
+    # checks the zones in argv if there are managed zones
+    for (@ARGV) {
+        chomp($zone = `idn --quiet "$_"`);
+        if (-e "$master_dir/$zone/$zone") {
+            push @zone, $zone;
+        }
+    }
+    return ($do, @zone);
+}
+
 sub read_conf {
 
     # read configuration
@@ -53,45 +83,6 @@
     return %return;
 }
 
-sub read_argv ($) {
-
-    # evaluate argv or print the help
-    my $master_dir = $_[0];
-
-    my $arg = shift @ARGV;
-    my $zone;
-    my $do;      # return
-    my @zone;    # return
-
-    if (!defined $arg) {
-        print " usage: dnssec-keytool <option> zone\n";
-        print "   -z  created a new ZSK\n";
-        print "   -k  created a new ZSK and KSK\n";
-        print "   -rm deletes the key-set of a zone\n";
-        print "   -c  created configuration files for the dnstools\n";
-        print "       and a new ZSK for an existing KSK\n";
-        print "\n";
-
-        exit;
-    }
-    elsif ($arg eq "-k")  { $do = "ksk"; }
-    elsif ($arg eq "-rm") { $do = "rm"; }
-    elsif ($arg eq "-c")  { $do = "ck"; }
-    elsif ($arg eq "-z")  { $do = "zsk"; }
-    else {
-        print "not a valid option.\n";
-        exit;
-    }
-
-    # checks the zones in argv if there are managed zones
-    for (@ARGV) {
-        chomp($zone = `idn --quiet "$_"`);
-        if (-e "$master_dir/$zone/$zone") {
-            push @zone, $zone;
-        }
-    }
-    return ($do, @zone);
-}
 
 sub rm_keys (@) {
 
@@ -156,7 +147,7 @@
     }
 }
 
-sub creat_ksk {
+sub creat_ksk (@) {
     my ($master_dir, @zone) = @_;
     my @index;
     my $keyname;
@@ -236,7 +227,7 @@
     }
 }
 
-sub ck_zone {
+sub ck_zone (@) {
     my ($master_dir, @zone) = @_;
 
     for (@zone) {
@@ -275,7 +266,7 @@
     }
 }
 
-sub post_creat {
+sub post_creat (@) {
     my ($master_dir, @zone) = @_;
     for (@zone) {
         my $zone = $_;
@@ -285,7 +276,7 @@
     }
 }
 
-sub kill_useless_keys {
+sub kill_useless_keys (@) {
 
     # the function deletes all keys that are not available in the zone
 
@@ -326,7 +317,7 @@
     }
 }
 
-sub key_to_zonefile {
+sub key_to_zonefile (@) {
 
     # the function added all keys to the indexfile
     my $zone       = $_[0];
@@ -365,6 +356,14 @@
 
 dnssec-keytool <option> zone
 
+=item -z  created a new ZSK
+
+=item -k  created a new ZSK and KSK
+
+=item -r  delete the key-set of a zone
+
+=item -c  created configuration files for the dnstools and a new ZSK for an existing KSK
+
 =head1 DESCRIPTION
 
 kommt bald
--- a/update-serial.pl	Thu Dec 30 12:42:59 2010 +0100
+++ b/update-serial.pl	Thu Dec 30 15:29:33 2010 +0100
@@ -38,7 +38,7 @@
 
     GetOptions(
         "sign-alert-time=i" => \$opt{sign_alert_time},
-	"key-counter-end=i" => \$opt{key_counter_end},
+		"key-counter-end=i" => \$opt{key_counter_end},
         "h|help"            => sub { pod2usage(-exit 0, -verbose => 1) },
         "m|man"             => sub {
             pod2usage(