|
41 | 41 |
|
42 | 42 | if [[ "$1" != "--defaults" ]] && [[ -n "$LETSENCRYPT_DOMAIN" ]]; then |
43 | 43 | echo " ServerName ${LETSENCRYPT_DOMAIN}" |
| 44 | + |
| 45 | + # try the obvious path first |
44 | 46 | LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN,,}" |
| 47 | + |
| 48 | + # find the most recent cert otherwise |
45 | 49 | [[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || { |
46 | | - #find the most recent cert |
47 | 50 | LETSENCRYPT_CERT_BASE_PATH="$(find /etc/letsencrypt/live -type d -name "${LETSENCRYPT_DOMAIN,,}*" -printf "%T@ %p\n" | sort -n | cut -f2 -d' ' | tail -1)" |
48 | 51 | } |
49 | | - LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" |
50 | | - LETSENCRYPT_KEY_PATH="${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem" |
51 | 52 |
|
52 | | - # fall back to self-signed snakeoil certs |
53 | | - [[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || unset LETSENCRYPT_CERT_BASE_PATH |
| 53 | + # otherwise, in some installs this is the path we use (for legacy reasons) |
| 54 | + [[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || { |
| 55 | + if [[ -d "/etc/letsencrypt/live/ncp-nextcloud" ]]; then |
| 56 | + LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/ncp-nextcloud" |
| 57 | + fi |
| 58 | + } |
54 | 59 | else |
55 | 60 | # Make sure the default snakeoil cert exists |
56 | 61 | [ -f /etc/ssl/certs/ssl-cert-snakeoil.pem ] || make-ssl-cert generate-default-snakeoil --force-overwrite |
57 | 62 | unset LETSENCRYPT_DOMAIN |
58 | 63 | fi |
59 | 64 |
|
| 65 | +# NOTE: we fall back to self-signed snakeoil certs if we couldn't get a LE one |
| 66 | +[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] && { |
| 67 | + LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" |
| 68 | + LETSENCRYPT_KEY_PATH="${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem" |
| 69 | +} |
60 | 70 | cat <<EOF |
61 | 71 | CustomLog /var/log/apache2/nc-access.log combined |
62 | 72 | ErrorLog /var/log/apache2/nc-error.log |
|
0 commit comments