Skip to content

Commit 38fdcf8

Browse files
author
Marius Burkard
committed
- add logging to acme.sh commands and add that log file to internal log rotation
1 parent 3931f36 commit 38fdcf8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

server/lib/classes/cron.d/200-logfiles.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function onBeforeRun() {
4949

5050
public function onRunJob() {
5151
global $app, $conf;
52-
52+
5353
$app->uses('getconf');
5454
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
55-
55+
5656
if($server_config['log_retention'] > 0) {
5757
$max_syslog = $app->functions->intval($server_config['log_retention']);
5858
} else {
@@ -121,18 +121,18 @@ public function onRunJob() {
121121
$app->system->exec_safe("gzip -c ? > ?", $logfile, $logfile . '.gz');
122122
unlink($logfile);
123123
}
124-
124+
125125
$cron_logfiles = array('cron.log', 'cron_error.log', 'cron_wget.log');
126126
foreach($cron_logfiles as $cron_logfile) {
127127
$cron_logfile = $rec['document_root'].'/' . $log_folder . '/' . $cron_logfile;
128-
128+
129129
// rename older files (move up by one)
130130
$num = $log_retention;
131131
while($num >= 1) {
132132
if(is_file($cron_logfile . '.' . $num . '.gz')) rename($cron_logfile . '.' . $num . '.gz', $cron_logfile . '.' . ($num + 1) . '.gz');
133133
$num--;
134134
}
135-
135+
136136
// compress current logfile
137137
if(is_file($cron_logfile)) {
138138
$app->system->exec_safe("gzip -c ? > ?", $cron_logfile, $cron_logfile . '.1.gz');
@@ -146,7 +146,7 @@ public function onRunJob() {
146146
}
147147
}
148148

149-
// rotate and compress the error.log
149+
// rotate and compress the error.log
150150
$error_logfile = $rec['document_root'].'/' . $log_folder . '/error.log';
151151
// rename older files (move up by one)
152152
$num = $log_retention;
@@ -184,7 +184,7 @@ public function onRunJob() {
184184
//######################################################################################################
185185

186186

187-
$ispconfig_logfiles = array('ispconfig.log', 'cron.log', 'auth.log');
187+
$ispconfig_logfiles = array('ispconfig.log', 'cron.log', 'auth.log', 'acme.log');
188188
foreach($ispconfig_logfiles as $ispconfig_logfile) {
189189
$num = $max_syslog;
190190
$ispconfig_logfile = $conf['ispconfig_log_dir'].'/'.$ispconfig_logfile;
@@ -240,7 +240,7 @@ public function onRunJob() {
240240
*/
241241
$sql = "DELETE FROM sys_log WHERE tstamp < ? AND server_id != 0";
242242
$app->dbmaster->query($sql, $tstamp);
243-
243+
244244
/*
245245
* now delete those entries without a linked datalog entry (datalog_id = 0)
246246
*/

server/lib/classes/letsencrypt.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function get_acme_script() {
5454
}
5555

5656
public function get_acme_command($domains, $key_file, $bundle_file, $cert_file, $server_type = 'apache') {
57-
global $app;
57+
global $app, $conf;
5858

5959
$letsencrypt = $this->get_acme_script();
6060

@@ -74,7 +74,7 @@ public function get_acme_command($domains, $key_file, $bundle_file, $cert_file,
7474
$cert_arg = '--fullchain-file ' . escapeshellarg($bundle_file) . ' --cert-file ' . escapeshellarg($cert_file);
7575
}
7676

77-
$cmd = 'R=0 ; C=0 ; ' . $letsencrypt . ' --issue ' . $cmd . ' -w /usr/local/ispconfig/interface/acme ; R=$? ; if [[ $R -eq 0 || $R -eq 2 ]] ; then ' . $letsencrypt . ' --install-cert ' . $cmd . ' --key-file ' . escapeshellarg($key_file) . ' ' . $cert_arg . ' --reloadcmd ' . escapeshellarg($this->get_reload_command()) . '; C=$? ; fi ; if [[ $C -eq 0 ]] ; then exit $R ; else exit $C ; fi';
77+
$cmd = 'R=0 ; C=0 ; ' . $letsencrypt . ' --issue ' . $cmd . ' -w /usr/local/ispconfig/interface/acme ; R=$? ; if [[ $R -eq 0 || $R -eq 2 ]] ; then ' . $letsencrypt . ' --install-cert ' . $cmd . ' --key-file ' . escapeshellarg($key_file) . ' ' . $cert_arg . ' --reloadcmd ' . escapeshellarg($this->get_reload_command()) . ' --log ' . escapeshellarg($conf['ispconfig_log_dir'].'/acme.log') . '; C=$? ; fi ; if [[ $C -eq 0 ]] ; then exit $R ; else exit $C ; fi';
7878

7979
return $cmd;
8080
}

0 commit comments

Comments
 (0)