Skip to content

Commit a41d3d1

Browse files
committed
letsencrypt: disable also ncp web certs if OFF
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent dcfd1cf commit a41d3d1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

bin/ncp/NETWORKING/letsencrypt.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ configure()
5858
rm -f /etc/letsencrypt/renewal-hooks/deploy/ncp
5959
[[ "$DOCKERBUILD" == 1 ]] && update-rc.d letsencrypt disable
6060
install_template nextcloud.conf.sh "${nc_vhostcfg}"
61+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem|" "${vhostcfg2}"
62+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key|" "${vhostcfg2}"
63+
apachectl -k graceful
6164
echo "letsencrypt certificates disabled. Using self-signed certificates instead."
6265
exit 0
6366
}
@@ -110,8 +113,8 @@ EOF
110113

111114
# Configure Apache
112115
install_template nextcloud.conf.sh "${nc_vhostcfg}"
113-
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/fullchain.pem|" $vhostcfg2
114-
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/privkey.pem|" $vhostcfg2
116+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/fullchain.pem|" "${vhostcfg2}"
117+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/privkey.pem|" "${vhostcfg2}"
115118

116119
# Configure Nextcloud
117120
local domain_index="${TRUSTED_DOMAINS[letsencrypt_1]}"

etc/ncp-templates/nextcloud.conf.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ if [[ "$1" != "--defaults" ]] && [[ -n "$LETSENCRYPT_DOMAIN" ]]; then
4646
LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN,,}"
4747

4848
# find the most recent cert otherwise
49-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || {
49+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] || {
5050
LETSENCRYPT_CERT_BASE_PATH="$(find /etc/letsencrypt/live -type d -name "${LETSENCRYPT_DOMAIN,,}*" -printf "%T@ %p\n" | sort -n | cut -f2 -d' ' | tail -1)"
5151
}
5252

53-
# otherwise, in some installs this is the path we use (for legacy reasons)
54-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || {
53+
# otherwise, in some installs this is the path we use
54+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] || {
5555
if [[ -d "/etc/letsencrypt/live/ncp-nextcloud" ]]; then
5656
LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/ncp-nextcloud"
5757
fi
@@ -63,7 +63,7 @@ else
6363
fi
6464

6565
# NOTE: we fall back to self-signed snakeoil certs if we couldn't get a LE one
66-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] && {
66+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] && [[ -f "${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem" ]] && {
6767
LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem"
6868
LETSENCRYPT_KEY_PATH="${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem"
6969
}
@@ -72,7 +72,7 @@ cat <<EOF
7272
ErrorLog /var/log/apache2/nc-error.log
7373
SSLEngine on
7474
SSLProxyEngine on
75-
SSLCertificateFile ${LETSENCRYPT_CERT_PATH:-/etc/ssl/certs/ssl-cert-snakeoil.pem}
75+
SSLCertificateFile ${LETSENCRYPT_CERT_PATH:-/etc/ssl/certs/ssl-cert-snakeoil.pem}
7676
SSLCertificateKeyFile ${LETSENCRYPT_KEY_PATH:-/etc/ssl/private/ssl-cert-snakeoil.key}
7777
7878
# For notify_push app in NC21

0 commit comments

Comments
 (0)