Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
awit-certmaster
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
allworldit
awit-certmaster
Commits
0ffec9b6
Commit
0ffec9b6
authored
Jan 05, 2017
by
Nigel Kukard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'quietmode' into 'master'
Added quiet mode support See merge request
!3
parents
50e281ef
36d517e3
Pipeline
#784
passed with stages
in 1 minute and 40 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
11 deletions
+54
-11
awit-certmaster
awit-certmaster
+54
-11
No files found.
awit-certmaster
View file @
0ffec9b6
...
...
@@ -87,6 +87,7 @@ BEGIN {
decode_base64
encode_base64
);
use POSIX qw(floor ceil);
use Sys::Hostname;
}
...
...
@@ -410,7 +411,32 @@ sub logger
my ($self,$level,$arg1,@args) = @_;
printf(STDERR '
%-
7
s
:
'.$arg1."\n",$level,@args);
# Create the log line
my $logLine = sprintf('
%-
7
s
:
'.$arg1."\n",$level,@args);
# If we'
re
being
quiet
save
it
if
($
self
->{
'quiet'
})
{
push
(@{$
self
->{
'_logs'
}},$
logLine
);
}
else
{
#
If
not
output
to
console
print
(
STDERR
$
logLine
);
}
return
;
}
#
Function
to
output
logs
of
warning
or
higher
if
we
were
quiet
sub
logger_end
{
my
$
self
=
shift
;
#
If
we
're being quiet here is where we should output the logs if there were warnings
if ($self->{'
quiet
'} && grep({/^WARNING/},@{$self->{'
_logs
'}})) {
print(STDERR @{$self->{'
_logs
'}});
}
return;
}
...
...
@@ -454,6 +480,11 @@ sub _init
$self->{'
only_vhosts
'} = $opts->{'
only_vhosts
'};
$self->{'
use_dns
'} = $opts->{'
use_dns
'};
# Only output to console if we have a warning or higher
$self->{'
quiet
'} = $opts->{'
quiet
'};
# Initialize our log array, just incase we'
re
operating
quietly
$
self
->{
'_logs'
}
=
[];
return
$
self
;
}
...
...
@@ -512,8 +543,8 @@ sub _webserverCheckCertificates
my $remainingTime = $parsedCert->{'notafter'}->epoch() - $now->epoch();
my $daysToExpire = $remainingTime / 86400;
# Check remaining time
if ($daysToExpire <
30
) {
$self->logger("WARNING","WEBSERVER: - Certificate for vhost '
%
s
' expires in under
30
days, adding to regeneration list",$vhostName);
if ($daysToExpire <
15
) {
$self->logger("WARNING","WEBSERVER: - Certificate for vhost '%s' expires in under
15
days, adding to regeneration list",$vhostName);
next;
}
...
...
@@ -534,8 +565,8 @@ sub _webserverCheckCertificates
next if (@missingDomains);
# Output a notice if the cert will be re-applied for in the next 3 days
if ($daysToExpire < 3
4
) {
$self->logger("NOTICE","WEBSERVER: - Certificate for vhost '
%
s
' expires soon, it will be renewed in %s days",$vhostName,
$daysToExpire
);
if ($daysToExpire < 3
0
) {
$self->logger("NOTICE","WEBSERVER: - Certificate for vhost '%s' expires soon, it will be renewed in %s days",$vhostName,
ceil($daysToExpire - 15)
);
}
SKIP:
...
...
@@ -1754,11 +1785,7 @@ use Getopt::Long;
my $NAME = "
AWIT
-
CertMaster
";
our $VERSION = "
1.1.2
";
print(STDERR "
$
NAME
v
$
VERSION
-
Copyright
(
c
)
2016
-
2017
,
AllWorldIT
\
n
\
n
");
our $VERSION = "
1.1.4
";
...
...
@@ -1792,6 +1819,12 @@ C<awit-certmaster> provides the below commandline options...
=cut
=head2 --quiet
Operate in quiet mode and only output logs if there was an warning or worse error.
=cut
=head1 CERT OPTIONS
...
...
@@ -1843,6 +1876,7 @@ GetOptions(\%optctl,
"
version
",
"
nginx
",
"
apache
",
"
quiet
",
"
check
-
only
",
"
force
=
s
@
",
...
...
@@ -1852,6 +1886,13 @@ GetOptions(\%optctl,
"
use
-
dns
=
s
@
",
) or exit 1;
# Display copyright
if (!defined($optctl{'quiet'})) {
print(STDERR "
$
NAME
v
$
VERSION
-
Copyright
(
c
)
2016
-
2017
,
AllWorldIT
\
n
\
n
");
}
# Check for help
if (defined($optctl{'help'})) {
displayHelp();
...
...
@@ -1873,6 +1914,7 @@ my $cm = AWIT::CertMaster::LetsEncrypt->new({
'live' => $optctl{'live'},
'only_vhosts' => $optctl{'only'},
'use_dns' => $optctl{'use-dns'},
'quiet' => $optctl{'quiet'},
});
...
...
@@ -1887,7 +1929,7 @@ if ($optctl{'nginx'}) {
exit 1;
}
$cm->logger_end();
exit 0;
...
...
@@ -1913,6 +1955,7 @@ sub displayHelp
--version Display version.
--nginx Process Nginx vhosts.
--apache Process Apache vhosts.
--quiet Only output if warnings are detected.
Certificate Functions:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment