From f372bbbce7983bdc6fe13090946864ac9fe24535 Mon Sep 17 00:00:00 2001 From: Miraty Date: Fri, 7 Oct 2022 13:29:47 +0200 Subject: [PATCH] Log Certbot error messages --- fn/common.php | 4 ++-- pages/ht/add-http-dns.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fn/common.php b/fn/common.php index 1b66bbb..4804da7 100644 --- a/fn/common.php +++ b/fn/common.php @@ -2,7 +2,7 @@ $final_message = null; -function output($code, $msg = '') { +function output($code, $msg = '', $logs = ['']) { global $final_message; $shortCode = $code / 100 % 10; $final_message = match ($shortCode) { @@ -12,7 +12,7 @@ function output($code, $msg = '') { }; http_response_code($code); if ($shortCode === 5) - error_log("Niver internal error: " . strip_tags($msg)); + error_log("Niver internal error: " . strip_tags($msg) . implode("\n", $logs)); if ($code !== 200) executePage(); } diff --git a/pages/ht/add-http-dns.php b/pages/ht/add-http-dns.php index 4fda659..f6c3530 100644 --- a/pages/ht/add-http-dns.php +++ b/pages/ht/add-http-dns.php @@ -38,9 +38,9 @@ if (processForm()) { addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http"); - exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['certbot_path'] . " certonly --quiet" . (CONF['ht']['letsencrypt_use_production'] ? '' : ' --test-cert') . " --key-type rsa --rsa-key-size 3072 --webroot --webroot-path /srv/niver/acme --domain " . $_POST['domain'], $output, $returnCode); + exec('2>&1 ' . CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' certonly' . (CONF['ht']['letsencrypt_use_production'] ? '' : ' --test-cert') . ' --key-type rsa --rsa-key-size 3072 --webroot --webroot-path /srv/niver/acme --domain ' . $_POST['domain'], $output, $returnCode); if ($returnCode !== 0) - output(500, 'Certbot failed to get a Let\'s Encrypt certificate.'); + output(500, 'Certbot failed to get a Let\'s Encrypt certificate.', $output); $nginxConf = 'server { listen [' . CONF['ht']['ipv6_listen_address'] . ']:' . CONF['ht']['https_port'] . ' ssl http2;