]> Raphaƫl G. Git Repositories - acme/blobdiff - letsconf
Fix config generation
[acme] / letsconf
index 869c90b18538e377e7e3f511f94c74b5a9031f6c..cc0f0774c32436220c1cc7a74ad7b8c979a2f953 100755 (executable)
--- a/letsconf
+++ b/letsconf
@@ -48,59 +48,58 @@ my $prod = 0;
 # Strip and enable debug
 for (my $i = 0; $i <= $#ARGV; $i++) {
        # Match redhat types
 # Strip and enable debug
 for (my $i = 0; $i <= $#ARGV; $i++) {
        # Match redhat types
-       if ($ARGV[$i] =~ /^(?:(\-d|\-\-redhat)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
+       if ($ARGV[$i] =~ /^(?:(\-r|\-\-redhat)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
                if (defined($2)) {
                if (defined($2)) {
-                       push(@redhat, split(',', $2));
+                       push(@redhat, [split(',', $2)]);
                # Extract next parameter
                } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
                # Extract next parameter
                } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
-                       push(@redhat, split(',', $1));
+                       push(@redhat, [split(',', $1)]);
                        $i++;
                # Set default
                } else {
                        $i++;
                # Set default
                } else {
-                       push(@redhat, ('example.com'));
+                       push(@redhat, ['www.example.com','example.com','...']);
                }
        # Match debian types
                }
        # Match debian types
-       } elsif ($ARGV[$i] =~ /^(?:(\-r|\-\-debian)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
+       } elsif ($ARGV[$i] =~ /^(?:(\-d|\-\-debian)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) {
                if (defined($2)) {
                if (defined($2)) {
-                       push(@debian, split(',', $2));
+                       push(@debian, [split(',', $2)]);
                # Extract next parameter
                } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
                # Extract next parameter
                } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) {
-                       push(@debian, split(',', $1));
+                       push(@debian, [split(',', $1)]);
                        $i++;
                # Set default
                } else {
                        $i++;
                # Set default
                } else {
-                       push(@debian, ('example.com'));
+                       push(@debian, ['www.example.com','example.com','...']);
                }
        }
 }
 
 # Show usage
 if (scalar(@ARGV) < 1) {
                }
        }
 }
 
 # Show usage
 if (scalar(@ARGV) < 1) {
-       print "Usage: $0 [(-d|--debian)[=example.com[,...]] [(-r|--redhat)[=example.com[,...]]] [...]\n";
+       print "Usage: $0 [(-d|--debian)[=example.com[,...]] [(-r|--redhat)[=example.com[,...]]] [...] > /etc/acmepl/config\n";
        exit EXIT_FAILURE;
 }
 
 # Append redhat style examples
        exit EXIT_FAILURE;
 }
 
 # Append redhat style examples
-foreach my $key (@redhat) {
+for my $key (@redhat) {
+       my $domain = shift @{$key};
+       my @domains = $key;
        tie(%{$root{certificates}[$#{$root{certificates}}+1]}, 'Tie::IxHash', (
                # Public cert
                #XXX: required
        tie(%{$root{certificates}[$#{$root{certificates}}+1]}, 'Tie::IxHash', (
                # Public cert
                #XXX: required
-               cert => '/etc/pki/tls/certs/'.$key.'.pem',
+               cert => '/etc/pki/tls/certs/'.$domain.'.pem',
                # Private key
                #XXX: required
                # Private key
                #XXX: required
-               key => '/etc/pki/tls/private/'.$key.'.pem',
+               key => '/etc/pki/tls/private/'.$domain.'.pem',
                # Mail address
                #XXX: required
                # Mail address
                #XXX: required
-               mail => 'webmaster@'.$key,
+               mail => 'webmaster@'.$domain,
                # Root domain
                #XXX: required
                # Root domain
                #XXX: required
-               domain => 'www.'.$key,
+               domain => $domain,
                # Domain list
                #XXX: required
                # Domain list
                #XXX: required
-               domains => [
-                       $key,
-                       '...'
-               ],
+               domains => @domains,
                # Production certificate
                #XXX: optional
                #XXX: set to 1 for production
                # Production certificate
                #XXX: optional
                #XXX: set to 1 for production
@@ -109,26 +108,25 @@ foreach my $key (@redhat) {
 }
 
 # Append debian style examples
 }
 
 # Append debian style examples
-foreach my $key (@debian) {
+for my $key (@debian) {
+       my $domain = shift @{$key};
+       my @domains = $key;
        tie(%{$root{certificates}[$#{$root{certificates}}+1]}, 'Tie::IxHash', (
                # Public cert
                #XXX: required
        tie(%{$root{certificates}[$#{$root{certificates}}+1]}, 'Tie::IxHash', (
                # Public cert
                #XXX: required
-               cert => '/etc/ssl/certs/'.$key.'.crt',
+               cert => '/etc/ssl/certs/'.$domain.'.crt',
                # Private key
                #XXX: required
                # Private key
                #XXX: required
-               key => '/etc/ssl/private/'.$key.'.key',
+               key => '/etc/ssl/private/'.$domain.'.key',
                # Mail address
                #XXX: required
                # Mail address
                #XXX: required
-               mail => 'webmaster@'.$key,
+               mail => 'webmaster@'.$domain,
                # Root domain
                #XXX: required
                # Root domain
                #XXX: required
-               domain => 'www.'.$key,
+               domain => $domain,
                # Domain list
                #XXX: required
                # Domain list
                #XXX: required
-               domains => [
-                       $key,
-                       '...'
-               ],
+               domains => @domains,
                # Production certificate
                #XXX: optional
                #XXX: set to 1 for production
                # Production certificate
                #XXX: optional
                #XXX: set to 1 for production