diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-03-15 12:12:43 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-03-15 12:12:43 +0200 |
commit | 32ad59e0a9c7f74c7c094d5091bce435c145fe33 (patch) | |
tree | fd16d21eaaed41b3b6c58e8db4d36be854022af1 | |
parent | 66972a8ed32f71ad5ef46bb54e443aa6d99b2723 (diff) | |
download | acmeman-32ad59e0a9c7f74c7c094d5091bce435c145fe33.tar.gz acmeman-32ad59e0a9c7f74c7c094d5091bce435c145fe33.tar.bz2 |
Multiple 'source' configuration statements.v1.10
* Changes: Version 1.10
* MANIFEST.SKIP: Update.
* acmeman: Treat 'source' as multiple keyword.
* lib/App/Acmeman/Source/File.pm (new): Append /* only to directory
names.
-rw-r--r-- | Changes | 8 | ||||
-rw-r--r-- | MANIFEST.SKIP | 2 | ||||
-rwxr-xr-x | acmeman | 49 | ||||
-rw-r--r-- | lib/App/Acmeman/Source/File.pm | 4 |
4 files changed, 39 insertions, 24 deletions
@@ -1,3 +1,11 @@ +1.10 2019-03-15 + + - Support for multiple 'source' statements. + +1.09 2019-03-14 + + - Use absolute path to the 'service' utility on systems that have it + 1.08 2018-10-06 - New option --server-root for the source = apache configuration diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 2f9c3df..0147f1e 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -58,7 +58,7 @@ ^tmp ^buildreq ^\.emacs\.* -\.tar(?:\.gz)?$ +\.tar(?:\.gz(?:\.sig)?)?$ \.diff$ \.patch$ ^bootstrap\.pl @@ -40,7 +40,7 @@ use App::Acmeman::Domain qw(:files); use Data::Dumper; use Text::ParseWords; -our $VERSION = '1.09'; +our $VERSION = '1.10'; =head1 NAME @@ -230,6 +230,9 @@ will be autodetected. The B<file> source reads domain names from one or more disk files. A mandatory argument specifies the name of the directory where the files are located. This mode is suitable for use with B<haproxy> pattern files. + +Multiple B<source> statements can be defined. They will be processed +sequentially. =item B<files=>I<NAME> @@ -496,11 +499,12 @@ will use the B<LetsEncryptSSL> macro to configure the correct certificate: [core] source = file PATTERN [--ignore=RX] [--host=HOST] -Domain names will be read from files matching I<PATTERN>. This argument -can be either a valid globbing pattern or a directory name. In the latter -case, the source module will read all files from that directory, except -those whose names match the following perl regexp: C<^\.|~$|\.bak$|^#.*#$>. -The default regexp can be overridden using the B<--ignore> (B<-i>) option. +Domain names will be read from files matching I<PATTERN>. The argument +can be a single file or directory name, or a valid globbing pattern. +If I<PATTERN> is a directory name, the module will read all files from +that directory, except those matching the following perl regexp: +C<^\.|~$|\.bak$|^#.*#$>. The default regexp can be overridden using the +B<--ignore> (B<-i>) option. The input files must contain exactly one domain name per line. No empty lines or comments are allowed. The first domain name will become the B<CN> @@ -902,17 +906,16 @@ sub get_root_cert { sub initial_setup { get_root_cert('/etc/ssl/acme/lets-encrypt-x3-cross-signed.pem'); - my $source = $config->get(qw(core source)); - unless (defined($source)) { + unless ($config->isset(qw(core source))) { require App::Acmeman::Source::Apache; - $source = new App::Acmeman::Source::Apache; - $source->configure($config); - $source = undef unless $config->success; + my $src = new App::Acmeman::Source::Apache; + $src->configure($config); + $config->set(qw(core source), $src) unless $config->success; $config->clrerr; } - if ($source) { - unless ($source->setup(dry_run => $dry_run, force => $force)) { + foreach my $src ($config->get(qw(core source))) { + unless ($src->setup(dry_run => $dry_run, force => $force)) { exit(1); } } @@ -1080,7 +1083,7 @@ my %syntax = ( rootdir => { default => '/var/www/acme' }, files => 1, 'time-delta' => { default => 86400 }, - source => { default => 'apache' }, + source => { default => [ 'apache' ], array => 1 }, 'check-alt-names' => { default => 0, parser => \&cb_parse_bool }, 'check-dns' => { default => 1, parser => \&cb_parse_bool }, 'my-ip' => { array => 1 }, @@ -1186,15 +1189,17 @@ $config = new App::Acmeman::Config($config_file, }); if ($config->success) { - if (my $source = $config->get(qw(core source))) { - my ($name, @args) = quotewords('\s+', 0, $source); - my $pack = 'App::Acmeman::Source::' . ucfirst($name); - my $obj = eval "use $pack; new $pack(\@args);"; - if ($@) { - abend(EX_CONFIG, $@); + if (my @source = $config->get(qw(core source))) { + foreach my $s (@source) { + my ($name, @args) = quotewords('\s+', 0, $s); + my $pack = 'App::Acmeman::Source::' . ucfirst($name); + my $obj = eval "use $pack; new $pack(\@args);"; + if ($@) { + abend(EX_CONFIG, $@); + } + $obj->configure($config); + $config->set(qw(core source), $obj); } - $obj->configure($config); - $config->set(qw(core source), $obj); } if ($time_delta) { $config->set(qw(core time-delta), $time_delta); diff --git a/lib/App/Acmeman/Source/File.pm b/lib/App/Acmeman/Source/File.pm index 48a4010..0d6859d 100644 --- a/lib/App/Acmeman/Source/File.pm +++ b/lib/App/Acmeman/Source/File.pm @@ -17,7 +17,9 @@ sub new { 'host|h=s' => \$host); unless ($pattern =~ m{[][*?]}) { $pattern =~ s{/$}{}; - $pattern = File::Spec->catfile($pattern, '*'); + if (-d $pattern) { + $pattern = File::Spec->catfile($pattern, '*'); + } } bless { pattern => $pattern, ignore => $ignore, |