]>
Raphaël G. Git Repositories - acme/blob - letsconf
   3 # This program is free software: you can redistribute it and/or modify 
   4 # it under the terms of the GNU General Public License as published by 
   5 # the Free Software Foundation, either version 3 of the License, or 
   6 # (at your option) any later version. 
   8 # This program is distributed in the hope that it will be useful, 
   9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 
  10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  11 # GNU General Public License for more details. 
  13 # You should have received a copy of the GNU General Public License 
  14 # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
  16 # Copyright (C) 2016 - 2017 Raphaël Gertz <acmepl@rapsys.eu> 
  22 # Load required modules 
  27 use POSIX 
qw(EXIT_SUCCESS EXIT_FAILURE); 
  40 tie
(%root, 'Tie::IxHash', thumbprint 
=> '/etc/acmepl/thumbprint', certificates 
=> []); 
  45 # Strip and enable prod 
  46 @ARGV = map { if ($_ eq '-p') { $prod = 1; (); } else { $_; } } @ARGV; 
  48 # Strip and enable debug 
  49 for (my $i = 0; $i <= $#ARGV; $i++) { 
  51         if ($ARGV[$i] =~ /^(?:(\-d|\-\-redhat)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) { 
  53                         push(@redhat, split(',', $2)); 
  54                 # Extract next parameter 
  55                 } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) { 
  56                         push(@redhat, split(',', $1)); 
  60                         push(@redhat, ('example.com')); 
  63         } elsif ($ARGV[$i] =~ /^(?:(\-r|\-\-debian)(?:=([^-][a-zA-Z0-9_\.,-]+))?)$/) { 
  65                         push(@debian, split(',', $2)); 
  66                 # Extract next parameter 
  67                 } elsif(defined($ARGV[$i+1]) && $ARGV[$i+1] =~ /^([^-][a-zA-Z0-9_\.,-]+)$/) { 
  68                         push(@debian, split(',', $1)); 
  72                         push(@debian, ('example.com')); 
  78 if (scalar(@ARGV) < 1) { 
  79         print "Usage: $0 [(-d|--debian)[=example.com[,...]] [(-r|--redhat)[=example.com[,...]]] [...]\n"; 
  83 # Append redhat style examples 
  84 foreach my $key (@redhat) { 
  85         tie
(%{$root{certificates
}[$#{$root{certificates
}}+1]}, 'Tie::IxHash', ( 
  88                 cert 
=> '/etc/pki/tls/certs/'.$key.'.pem', 
  91                 key 
=> '/etc/pki/tls/private/'.$key.'.pem', 
  94                 mail 
=> 'webmaster@'.$key, 
  97                 domain 
=> 'www.'.$key, 
 104                 # Production certificate 
 106                 #XXX: set to 1 for production 
 111 # Append debian style examples 
 112 foreach my $key (@debian) { 
 113         tie
(%{$root{certificates
}[$#{$root{certificates
}}+1]}, 'Tie::IxHash', ( 
 116                 cert 
=> '/etc/ssl/certs/'.$key.'.crt', 
 119                 key 
=> '/etc/ssl/private/'.$key.'.key', 
 122                 mail 
=> 'webmaster@'.$key, 
 125                 domain 
=> 'www.'.$key, 
 132                 # Production certificate 
 134                 #XXX: set to 1 for production 
 139 # Display configuration template 
 140 print to_json
(\
%root, {pretty 
=> 1});