Skip to content

Commit 532a6a8

Browse files
committed
letsencrypt: sync ncp and nc cert paths
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 41368fe commit 532a6a8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

bin/ncp/NETWORKING/letsencrypt.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
ncdir=/var/www/nextcloud
1212
nc_vhostcfg=/etc/apache2/sites-available/nextcloud.conf
13-
vhostcfg2=/etc/apache2/sites-available/ncp.conf
13+
ncp_vhostcfg=/etc/apache2/sites-available/ncp.conf
1414
letsencrypt=/usr/bin/letsencrypt
1515

1616
is_active()
@@ -58,8 +58,10 @@ 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}"
61+
local cert_path="$(grep SSLCertificateFile "${nc_vhostcfg}" | awk '{ print $2 }')"
62+
local key_path="$(grep SSLCertificateKeyFile "${nc_vhostcfg}" | awk '{ print $2 }')"
63+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile ${cert_path}|" "${ncp_vhostcfg}"
64+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile ${key_path}|" "${ncp_vhostcfg}"
6365
apachectl -k graceful
6466
echo "letsencrypt certificates disabled. Using self-signed certificates instead."
6567
exit 0
@@ -113,8 +115,10 @@ EOF
113115

114116
# Configure Apache
115117
install_template nextcloud.conf.sh "${nc_vhostcfg}"
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}"
118+
local cert_path="$(grep SSLCertificateFile "${nc_vhostcfg}" | awk '{ print $2 }')"
119+
local key_path="$(grep SSLCertificateKeyFile "${nc_vhostcfg}" | awk '{ print $2 }')"
120+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile ${cert_path}|" "${ncp_vhostcfg}"
121+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile ${key_path}|" "${ncp_vhostcfg}"
118122

119123
# Configure Nextcloud
120124
local domain_index="${TRUSTED_DOMAINS[letsencrypt_1]}"

etc/ncp-templates/nextcloud.conf.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fi
6767
LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem"
6868
LETSENCRYPT_KEY_PATH="${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem"
6969
}
70+
7071
cat <<EOF
7172
CustomLog /var/log/apache2/nc-access.log combined
7273
ErrorLog /var/log/apache2/nc-error.log

0 commit comments

Comments
 (0)