From a7da3be9aeebb071f96fe33fbea5fd022e5a4322 Mon Sep 17 00:00:00 2001 From: ahgraber Date: Mon, 15 Feb 2021 20:33:26 -0500 Subject: [PATCH] re-rename --- root/app/{le_renew.sh => le-renew.sh} | 0 ...{01-deploy_certs.sh => 01_deploy-certs.sh} | 0 ...s6_secret_init.sh => 00_s6-secret-init.sh} | 0 .../{01-add_user.sh => 01_add-user.sh} | 0 ...{02-set_timezone.sh => 02_set-timezone.sh} | 0 .../{10-permissions.sh => 10_permissions.sh} | 0 ...{50-lets_encrypt.sh => 50_lets-encrypt.sh} | 31 ++++++++++--------- ...{60-renewal_init.sh => 60_renewal-init.sh} | 2 +- .../{01-add_user.sh => 01_add-user.sh} | 0 9 files changed, 18 insertions(+), 15 deletions(-) rename root/app/{le_renew.sh => le-renew.sh} (100%) rename root/defaults/deploy/{01-deploy_certs.sh => 01_deploy-certs.sh} (100%) rename root/etc/cont-init.d/{00-s6_secret_init.sh => 00_s6-secret-init.sh} (100%) rename root/etc/cont-init.d/{01-add_user.sh => 01_add-user.sh} (100%) rename root/etc/cont-init.d/{02-set_timezone.sh => 02_set-timezone.sh} (100%) rename root/etc/cont-init.d/{10-permissions.sh => 10_permissions.sh} (100%) rename root/etc/cont-init.d/{50-lets_encrypt.sh => 50_lets-encrypt.sh} (86%) rename root/etc/cont-init.d/{60-renewal_init.sh => 60_renewal-init.sh} (96%) rename scripts/archive/{01-add_user.sh => 01_add-user.sh} (100%) diff --git a/root/app/le_renew.sh b/root/app/le-renew.sh similarity index 100% rename from root/app/le_renew.sh rename to root/app/le-renew.sh diff --git a/root/defaults/deploy/01-deploy_certs.sh b/root/defaults/deploy/01_deploy-certs.sh similarity index 100% rename from root/defaults/deploy/01-deploy_certs.sh rename to root/defaults/deploy/01_deploy-certs.sh 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/01-add_user.sh b/root/etc/cont-init.d/01_add-user.sh similarity index 100% rename from root/etc/cont-init.d/01-add_user.sh rename to root/etc/cont-init.d/01_add-user.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/10-permissions.sh b/root/etc/cont-init.d/10_permissions.sh similarity index 100% rename from root/etc/cont-init.d/10-permissions.sh rename to root/etc/cont-init.d/10_permissions.sh diff --git a/root/etc/cont-init.d/50-lets_encrypt.sh b/root/etc/cont-init.d/50_lets-encrypt.sh similarity index 86% rename from root/etc/cont-init.d/50-lets_encrypt.sh rename to root/etc/cont-init.d/50_lets-encrypt.sh index f9ae600..5d55afa 100644 --- a/root/etc/cont-init.d/50-lets_encrypt.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/01-deploy_certs.sh ]] && \ +[[ ! -f /config/deploy/01_deploy-certs.sh ]] && \ echo "Copying deploy hooks..." && \ - cp -n /defaults/deploy/01-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 ..." @@ -132,14 +132,14 @@ echo "${VALIDATION:="DNS"} validation via ${DNSPLUGIN} plugin is selected" # NOTE: Skip, handled in deploy hook # # Set the symlink for key location # rm -rf /letsencrypt/keys -# if [ "${ONLY_SUBDOMAINS}" = "true" ] && [ ! "${SUBDOMAINS}" = "wildcard" ] ; then -# DOMAIN="$(echo "${SUBDOMAINS}" | tr ',' ' ' | awk '{print $1}').${TLD}" -# # LE_LOC="../etc/letsencrypt/live/${DOMAIN}" +if [ "${ONLY_SUBDOMAINS}" = "true" ] && [ ! "${SUBDOMAINS}" = "wildcard" ] ; then + DOMAIN="$(echo "${SUBDOMAINS}" | tr ',' ' ' | awk '{print $1}').${TLD}" + LINEAGE="../etc/letsencrypt/live/${DOMAIN}" # ln -s /letsencrypt/live/"${DOMAIN}" /letsencrypt/keys -# else -# # LE_LOC="../etc/letsencrypt/live/${TLD}" +else + LINEAGE="../etc/letsencrypt/live/${TLD}" # ln -s /letsencrypt/live/"${TLD}" /letsencrypt/keys -# fi +fi # # [[ ! -d "${LE_LOC}" ]] && \ # # mkdir -p ${LE_LOC} # # ln -s ${LE_LOC} /letsencrypt @@ -147,17 +147,18 @@ echo "${VALIDATION:="DNS"} validation via ${DNSPLUGIN} plugin is selected" # Check for changes in cert variables; revoke certs if necessary if [ ! "${TLD}" = "${ORIGTLD}" ] || [ ! "${SUBDOMAINS}" = "${ORIGSUBDOMAINS}" ] || [ ! "${ONLY_SUBDOMAINS}" = "${ORIGONLY_SUBDOMAINS}" ] || [ ! "${STAGING}" = "${ORIGSTAGING}" ]; then echo "Different validation parameters entered than what was used before. Revoking and deleting existing certificate, and an updated one will be created" - if [ "${ORIGONLY_SUBDOMAINS}" = "true" ] && [ ! "${ORIGSUBDOMAINS}" = "wildcard" ]; then - ORIGDOMAIN="$(echo "${ORIGSUBDOMAINS}" | tr ',' ' ' | awk '{print $1}').${ORIGTLD}" - else - ORIGDOMAIN="${ORIGTLD}" - fi + # if [ "${ORIGONLY_SUBDOMAINS}" = "true" ] && [ ! "${ORIGSUBDOMAINS}" = "wildcard" ]; then + # ORIGDOMAIN="$(echo "${ORIGSUBDOMAINS}" | tr ',' ' ' | awk '{print $1}').${ORIGTLD}" + # else + # ORIGDOMAIN="${ORIGTLD}" + # fi if [ "${ORIGSTAGING}" = "true" ]; then REV_ACMESERVER="https://acme-staging-v02.api.letsencrypt.org/directory" else REV_ACMESERVER="https://acme-v02.api.letsencrypt.org/directory" fi - [[ -f /etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem ]] && certbot revoke --non-interactive --cert-path /etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --server ${REV_ACMESERVER} + # [[ -f /etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem ]] && certbot revoke --non-interactive --cert-path /etc/letsencrypt/live/"${ORIGDOMAIN}"/fullchain.pem --server ${REV_ACMESERVER} + [[ -f "${LINEAGE}"/fullchain.pem ]] && certbot revoke --non-interactive --cert-path "${LINEAGE}"/fullchain.pem --server ${REV_ACMESERVER} rm -rf /etc/letsencrypt mkdir -p /etc/letsencrypt fi @@ -170,7 +171,9 @@ if [ ! -f "/letsencrypt/fullchain.pem" ]; then echo "Generating new certificate" # shellcheck disable=SC2086 certbot certonly --non-interactive --force-renewal --server ${ACMESERVER} ${PREFCHAL} --rsa-key-size 4096 ${EMAILPARAM} --agree-tos ${TLD_REAL} + RENEWED_LINEAGE="/etc/letsencrypt/live/${LINEAGE}" echo $(printenv) + echo "RENEWED_LINEAGE is ${RENEWED_LINEAGE}" /usr/bin/with-contenv bash /etc/letsencrypt/renewal-hooks/deploy/01-deploy_certs.sh if [ -f /letsencrypt/fullchain.pem ]; then 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 4a30a98..a28d347 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 diff --git a/scripts/archive/01-add_user.sh b/scripts/archive/01_add-user.sh similarity index 100% rename from scripts/archive/01-add_user.sh rename to scripts/archive/01_add-user.sh