From 69350f9921be3a5c64c163cdee5b7bf65d901768 Mon Sep 17 00:00:00 2001 From: Alex Graber <24922003+ahgraber@users.noreply.github.com> Date: Mon, 15 Feb 2021 20:09:01 -0500 Subject: [PATCH] renames and tweaks --- root/app/{le-renew.sh => le_renew.sh} | 2 +- .../deploy/{deploy-certs.sh => 01-deploy_certs.sh} | 4 ++++ .../{00-s6-secret-init.sh => 00-s6_secret_init.sh} | 0 .../{02-set-timezone.sh => 02-set_timezone.sh} | 0 .../cont-init.d/{50-certbot.sh => 50-lets_encrypt.sh} | 9 ++++++--- .../{60_renewal-init.sh => 60-renewal_init.sh} | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) rename root/app/{le-renew.sh => le_renew.sh} (83%) rename root/defaults/deploy/{deploy-certs.sh => 01-deploy_certs.sh} (94%) rename root/etc/cont-init.d/{00-s6-secret-init.sh => 00-s6_secret_init.sh} (100%) rename root/etc/cont-init.d/{02-set-timezone.sh => 02-set_timezone.sh} (100%) rename root/etc/cont-init.d/{50-certbot.sh => 50-lets_encrypt.sh} (95%) rename root/etc/cont-init.d/{60_renewal-init.sh => 60-renewal_init.sh} (96%) diff --git a/root/app/le-renew.sh b/root/app/le_renew.sh similarity index 83% rename from root/app/le-renew.sh rename to root/app/le_renew.sh index a936df7..85839d3 100644 --- a/root/app/le-renew.sh +++ b/root/app/le_renew.sh @@ -7,4 +7,4 @@ echo echo "<------------------------------------------------->" echo "cronjob running on "$(date) echo "Running certbot renew" -certbot renew --noninteractive --no-self-upgrade +certbot renew --non-interactive --no-self-upgrade diff --git a/root/defaults/deploy/deploy-certs.sh b/root/defaults/deploy/01-deploy_certs.sh similarity index 94% rename from root/defaults/deploy/deploy-certs.sh rename to root/defaults/deploy/01-deploy_certs.sh index dc87d60..8d8aefd 100644 --- a/root/defaults/deploy/deploy-certs.sh +++ b/root/defaults/deploy/01-deploy_certs.sh @@ -7,7 +7,11 @@ # new certificates and keys; the shell variable $RENEWED_DOMAINS will contain a space-delimited list # of renewed certificate domains (for example, "example.com www.example.com" (default: None) +echo "Running deploy script ..." + KEYPATH="/letsencrypt" +echo "KEYPATH is ${KEYPATH}" +echo "LINEAGE is ${RENEWED_LINEAGE}" # clean current KEYPATH contents rm -f ${KEYPATH}/* diff --git a/root/etc/cont-init.d/00-s6-secret-init.sh b/root/etc/cont-init.d/00-s6_secret_init.sh similarity index 100% rename from root/etc/cont-init.d/00-s6-secret-init.sh rename to root/etc/cont-init.d/00-s6_secret_init.sh diff --git a/root/etc/cont-init.d/02-set-timezone.sh b/root/etc/cont-init.d/02-set_timezone.sh similarity index 100% rename from root/etc/cont-init.d/02-set-timezone.sh rename to root/etc/cont-init.d/02-set_timezone.sh diff --git a/root/etc/cont-init.d/50-certbot.sh b/root/etc/cont-init.d/50-lets_encrypt.sh similarity index 95% rename from root/etc/cont-init.d/50-certbot.sh rename to root/etc/cont-init.d/50-lets_encrypt.sh index cbf814a..f9ae600 100644 --- a/root/etc/cont-init.d/50-certbot.sh +++ b/root/etc/cont-init.d/50-lets_encrypt.sh @@ -53,9 +53,9 @@ ln -s /config/crontabs /etc/crontabs # Copy deploy hook defaults if needed # [[ -z "$(ls -A /letsencrypt/renewal-hooks/deploy)" ]] && \ -[[ ! -f /config/deploy/deploy-certs.sh ]] && \ +[[ ! -f /config/deploy/01-deploy_certs.sh ]] && \ echo "Copying deploy hooks..." && \ - cp -n /defaults/deploy/deploy-certs.sh /config/deploy/ + cp -n /defaults/deploy/01-deploy_certs.sh /config/deploy/ chmod +x /config/deploy/* # Link /config/deploy echo "Linking /config/deploy -> /etc/letsencrypt/renewal-hooks/deploy ..." @@ -169,7 +169,10 @@ echo -e "ORIGTLD=\"${TLD}\" ORIGSUBDOMAINS=\"${SUBDOMAINS}\" ORIGONLY_SUBDOMAINS if [ ! -f "/letsencrypt/fullchain.pem" ]; then echo "Generating new certificate" # shellcheck disable=SC2086 - certbot certonly --renew-by-default --server ${ACMESERVER} ${PREFCHAL} --rsa-key-size 4096 ${EMAILPARAM} --agree-tos ${TLD_REAL} + certbot certonly --non-interactive --force-renewal --server ${ACMESERVER} ${PREFCHAL} --rsa-key-size 4096 ${EMAILPARAM} --agree-tos ${TLD_REAL} + echo $(printenv) + /usr/bin/with-contenv bash /etc/letsencrypt/renewal-hooks/deploy/01-deploy_certs.sh + if [ -f /letsencrypt/fullchain.pem ]; then cd /letsencrypt || exit else diff --git a/root/etc/cont-init.d/60_renewal-init.sh b/root/etc/cont-init.d/60-renewal_init.sh similarity index 96% rename from root/etc/cont-init.d/60_renewal-init.sh rename to root/etc/cont-init.d/60-renewal_init.sh index a28d347..4a30a98 100644 --- a/root/etc/cont-init.d/60_renewal-init.sh +++ b/root/etc/cont-init.d/60-renewal_init.sh @@ -10,6 +10,6 @@ if openssl x509 -in /letsencrypt/fullchain.pem -noout -checkend 86400 >/dev/null echo "Letting the cron script handle the renewal attempts overnight (2:08am)." else echo "The cert is either expired or it expires within the next day. Attempting to renew. This could take up to 10 minutes." - /app/le-renew.sh + /app/le_renew.sh sleep 1 fi \ No newline at end of file