From 919706b80e07d85699e1bdd6c09cf463e735ff60 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 14 Jun 2024 18:39:39 -0300 Subject: [PATCH] fix: some renewal files where missing (??) --- certbotd.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/certbotd.sh b/certbotd.sh index 5d4e2f7..5c04ddb 100755 --- a/certbotd.sh +++ b/certbotd.sh @@ -89,10 +89,27 @@ case $1 in 2>"${headers}" \ | jq --raw-output .[] \ | while read domain; do + if test -z "${domain}"; then + echo "not ok - domain is empty" >&2 + continue + fi + # Skip already existing domains - if test -f "/etc/letsencrypt/renewal/${domain}.conf"; then + if test -s "/etc/letsencrypt/renewal/${domain}.conf"; then echo "ok - ${domain} already issued" >&2 continue + else + echo "ok - ${domain} renewal conf was empty, fixing..." >&2 + + other_renewal="$(grep -l -m 1 "^authenticator = webroot$" /etc/letsencrypt/renewal/*.conf | head -1)" + + if test -z "${other_renewal}"; then + echo "not ok - ${domain} couldn't fix" >&2 + ensure 1 + fi + + other_domain="$(basename "${other_renewal}" .conf)" + sed -re "s/${other_domain}/${domain}/g" "${other_renewal}" > "/etc/letsencrypt/renewal/${domain}.conf" fi # Ignore non local domains