Skip to content
Snippets Groups Projects
Commit 38fdcf89 authored by Marius Burkard's avatar Marius Burkard
Browse files

- add logging to acme.sh commands and add that log file to internal log rotation

parent 3931f36e
No related branches found
No related tags found
1 merge request!1063Resolve "Enable logging for acme.sh"
Pipeline #3642 passed
...@@ -49,10 +49,10 @@ class cronjob_logfiles extends cronjob { ...@@ -49,10 +49,10 @@ class cronjob_logfiles extends cronjob {
public function onRunJob() { public function onRunJob() {
global $app, $conf; global $app, $conf;
$app->uses('getconf'); $app->uses('getconf');
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
if($server_config['log_retention'] > 0) { if($server_config['log_retention'] > 0) {
$max_syslog = $app->functions->intval($server_config['log_retention']); $max_syslog = $app->functions->intval($server_config['log_retention']);
} else { } else {
...@@ -121,18 +121,18 @@ class cronjob_logfiles extends cronjob { ...@@ -121,18 +121,18 @@ class cronjob_logfiles extends cronjob {
$app->system->exec_safe("gzip -c ? > ?", $logfile, $logfile . '.gz'); $app->system->exec_safe("gzip -c ? > ?", $logfile, $logfile . '.gz');
unlink($logfile); unlink($logfile);
} }
$cron_logfiles = array('cron.log', 'cron_error.log', 'cron_wget.log'); $cron_logfiles = array('cron.log', 'cron_error.log', 'cron_wget.log');
foreach($cron_logfiles as $cron_logfile) { foreach($cron_logfiles as $cron_logfile) {
$cron_logfile = $rec['document_root'].'/' . $log_folder . '/' . $cron_logfile; $cron_logfile = $rec['document_root'].'/' . $log_folder . '/' . $cron_logfile;
// rename older files (move up by one) // rename older files (move up by one)
$num = $log_retention; $num = $log_retention;
while($num >= 1) { while($num >= 1) {
if(is_file($cron_logfile . '.' . $num . '.gz')) rename($cron_logfile . '.' . $num . '.gz', $cron_logfile . '.' . ($num + 1) . '.gz'); if(is_file($cron_logfile . '.' . $num . '.gz')) rename($cron_logfile . '.' . $num . '.gz', $cron_logfile . '.' . ($num + 1) . '.gz');
$num--; $num--;
} }
// compress current logfile // compress current logfile
if(is_file($cron_logfile)) { if(is_file($cron_logfile)) {
$app->system->exec_safe("gzip -c ? > ?", $cron_logfile, $cron_logfile . '.1.gz'); $app->system->exec_safe("gzip -c ? > ?", $cron_logfile, $cron_logfile . '.1.gz');
...@@ -146,7 +146,7 @@ class cronjob_logfiles extends cronjob { ...@@ -146,7 +146,7 @@ class cronjob_logfiles extends cronjob {
} }
} }
// rotate and compress the error.log // rotate and compress the error.log
$error_logfile = $rec['document_root'].'/' . $log_folder . '/error.log'; $error_logfile = $rec['document_root'].'/' . $log_folder . '/error.log';
// rename older files (move up by one) // rename older files (move up by one)
$num = $log_retention; $num = $log_retention;
...@@ -184,7 +184,7 @@ class cronjob_logfiles extends cronjob { ...@@ -184,7 +184,7 @@ class cronjob_logfiles extends cronjob {
//###################################################################################################### //######################################################################################################
$ispconfig_logfiles = array('ispconfig.log', 'cron.log', 'auth.log'); $ispconfig_logfiles = array('ispconfig.log', 'cron.log', 'auth.log', 'acme.log');
foreach($ispconfig_logfiles as $ispconfig_logfile) { foreach($ispconfig_logfiles as $ispconfig_logfile) {
$num = $max_syslog; $num = $max_syslog;
$ispconfig_logfile = $conf['ispconfig_log_dir'].'/'.$ispconfig_logfile; $ispconfig_logfile = $conf['ispconfig_log_dir'].'/'.$ispconfig_logfile;
...@@ -240,7 +240,7 @@ class cronjob_logfiles extends cronjob { ...@@ -240,7 +240,7 @@ class cronjob_logfiles extends cronjob {
*/ */
$sql = "DELETE FROM sys_log WHERE tstamp < ? AND server_id != 0"; $sql = "DELETE FROM sys_log WHERE tstamp < ? AND server_id != 0";
$app->dbmaster->query($sql, $tstamp); $app->dbmaster->query($sql, $tstamp);
/* /*
* now delete those entries without a linked datalog entry (datalog_id = 0) * now delete those entries without a linked datalog entry (datalog_id = 0)
*/ */
......
...@@ -54,7 +54,7 @@ class letsencrypt { ...@@ -54,7 +54,7 @@ class letsencrypt {
} }
public function get_acme_command($domains, $key_file, $bundle_file, $cert_file, $server_type = 'apache') { public function get_acme_command($domains, $key_file, $bundle_file, $cert_file, $server_type = 'apache') {
global $app; global $app, $conf;
$letsencrypt = $this->get_acme_script(); $letsencrypt = $this->get_acme_script();
...@@ -74,7 +74,7 @@ class letsencrypt { ...@@ -74,7 +74,7 @@ class letsencrypt {
$cert_arg = '--fullchain-file ' . escapeshellarg($bundle_file) . ' --cert-file ' . escapeshellarg($cert_file); $cert_arg = '--fullchain-file ' . escapeshellarg($bundle_file) . ' --cert-file ' . escapeshellarg($cert_file);
} }
$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'; $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';
return $cmd; return $cmd;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment