aboutsummaryrefslogtreecommitdiff
path: root/lib/App/Acmeman/Source/Apache.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/Acmeman/Source/Apache.pm')
-rw-r--r--lib/App/Acmeman/Source/Apache.pm46
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/App/Acmeman/Source/Apache.pm b/lib/App/Acmeman/Source/Apache.pm
index b429f89..f35c267 100644
--- a/lib/App/Acmeman/Source/Apache.pm
+++ b/lib/App/Acmeman/Source/Apache.pm
@@ -8,6 +8,7 @@ use File::Path qw(make_path);
use File::Spec;
use IPC::Open3;
use App::Acmeman::Apache::Layout;
+use App::Acmeman::Log qw(:all);
use parent 'App::Acmeman::Source';
use Getopt::Long qw(GetOptionsFromArray :config gnu_getopt no_ignore_case);
@@ -25,7 +26,7 @@ sub layout { shift->{_layout} }
sub scan {
my ($self) = @_;
- $self->debug(2, 'assuming Apache layout "'.$self->layout->name.'"');
+ debug(2, 'assuming Apache layout "'.$self->layout->name.'"');
$self->set(qw(core postrenew), $self->layout->restart_command);
return $self->examine_http_config($self->layout->config_file);
}
@@ -50,7 +51,7 @@ sub examine_http_config {
state $state = STATE_INITIAL;
- $self->debug(3, "reading apache configuration file \"$file\"");
+ debug(3, "reading apache configuration file \"$file\"");
if (open(my $fd, '<', $file)) {
my $server_name;
my @server_aliases;
@@ -63,7 +64,7 @@ sub examine_http_config {
s/^\s+//;
next if /^(#.*)?$/;
if (/^include(optional)?\s+(.+?)\s*$/i) {
- #$self->debug(3, "$file:$line: state $state: Include".($1||'')." $2");
+ #debug(3, "$file:$line: state $state: Include".($1||'')." $2");
$self->http_include($self->dequote($2), defined($1));
next;
}
@@ -93,7 +94,7 @@ sub examine_http_config {
my $cn = shift @server_aliases;
$self->define_domain($cn);
$self->define_alias($cn, @server_aliases);
- $self->debug(3, "$file:$line: will handle ".
+ debug(3, "$file:$line: will handle ".
join(',', $cn, @server_aliases));
} elsif ($state == STATE_USE_REFERENCE) {
$self->set('domain', $reference,
@@ -106,18 +107,18 @@ sub examine_http_config {
if ($state == STATE_VIRTUAL_HOST) {
$state = STATE_USE_CHALLENGE;
} elsif ($state == STATE_USE_CHALLENGE) {
- $self->error("$file:$line: duplicate use of LetsEncryptChallenge");
+ error("$file:$line: duplicate use of LetsEncryptChallenge");
} else {
- $self->error("$file:$line: LetsEncryptChallenge and LetsEncryptReference can't be used together");
+ error("$file:$line: LetsEncryptChallenge and LetsEncryptReference can't be used together");
}
} elsif (/^(?:(?i)Use)\s+LetsEncryptReference\s+(.+?)\s*$/) {
if ($state == STATE_VIRTUAL_HOST) {
$state = STATE_USE_REFERENCE;
$reference = $1;
} elsif ($state == STATE_USE_REFERENCE) {
- $self->error("$file:$line: duplicate use of LetsEncryptReference");
+ error("$file:$line: duplicate use of LetsEncryptReference");
} else {
- $self->error("$file:$line: LetsEncryptChallenge and LetsEncryptReference can't be used together");
+ error("$file:$line: LetsEncryptChallenge and LetsEncryptReference can't be used together");
}
} elsif (/^(?:(?i)ServerName)\s+(\S+)/) {
$server_name = $self->dequote($1);
@@ -133,7 +134,7 @@ sub examine_http_config {
my $dir = $self->dequote($1);
$dir =~ s{/.well-known/acme-challenge$}{};
$self->set(qw(core rootdir), $dir);
- $self->debug(3, "ACME challenge root dir: $dir");
+ debug(3, "ACME challenge root dir: $dir");
}
} elsif ($state == STATE_MACRO_SSL) {
if (m{^</macro}i) {
@@ -150,7 +151,7 @@ sub examine_http_config {
}
close $fd;
} else {
- $self->error("can't open file \"$file\": $!");
+ error("can't open file \"$file\": $!");
return 0;
}
return 1;
@@ -177,7 +178,7 @@ sub http_include {
$pattern = File::Spec->catfile($pattern, '*') if -d $pattern;
foreach my $file (glob $pattern) {
if ($optional && ! -e $file) {
- $self->debug(1, "optional include file \"$file\" doesn't exist");
+ debug(1, "optional include file \"$file\" doesn't exist");
next;
}
$self->examine_http_config($file);
@@ -191,9 +192,9 @@ sub mkpath {
for my $diag (@$err) {
my ($file, $message) = %$diag;
if ($file eq '') {
- $self->error($message);
+ error($message);
} else {
- $self->error("mkdir $file: $message");
+ error("mkdir $file: $message");
}
}
return 0;
@@ -206,16 +207,16 @@ sub setup {
my $filename = $self->layout->incdir() . "/httpd-letsencrypt.conf";
if (-e $filename) {
if ($args{force}) {
- ::error("the file \"$filename\" already exists",
- prefix => 'warning');
+ error("the file \"$filename\" already exists",
+ prefix => 'warning');
} else {
- ::error("the file \"$filename\" already exists");
- ::error("use --force to continue");
+ error("the file \"$filename\" already exists");
+ error("use --force to continue");
return 0;
}
}
my $www_root = $self->get(qw(core rootdir));
- $self->debug(2, "writing $filename");
+ debug(2, "writing $filename");
unless ($args{dry_run}) {
unless ($self->mkpath($self->layout->incdir())) {
return 0;
@@ -264,8 +265,9 @@ EOT
}
}
- ::error("created file \"$filename\"", prefix => 'note');
- ::error("please, enable mod_macro and make sure your Apache configuration includes this file", prefix => 'note');
+ error("created file \"$filename\"", prefix => 'note');
+ error("please, enable mod_macro and make sure your Apache configuration includes this file",
+ prefix => 'note');
return 1;
}
@@ -296,8 +298,8 @@ sub probe {
close $nullin;
close $nullout;
unless ($self->server_root) {
- ::error("can't deduce server root directory");
- ::error("use `source = apache --server-root=DIR' in [core] section of /etc/acmeman.conf to declare it");
+ error("can't deduce server root directory");
+ error("use `source = apache --server-root=DIR' in [core] section of /etc/acmeman.conf to declare it");
exit(1);
}
}

Return to:

Send suggestions and report system problems to the System administrator.