Skip to content

Commit 4c37d1e

Browse files
committed
Use pip-installed certbot if available
See #635 Give pip-installed one a priority as it's more likely to be up to date, which is useful long-term as LetsEncrypt matters sometimes change on short notice.
1 parent e2bc876 commit 4c37d1e

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

misc/cron/bluecherry-subdomain-cert-renewal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
88
# | | | | |
99
# * * * * * user-name command to be executed
10-
* * */5 * * root certbot renew --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ >/dev/null 2>&1
10+
* * */5 * * root /usr/share/bluecherry/subdomain-cert-renewal &>/dev/null
1111
*/5 * * * * root curl -k https://localhost:7001/subdomainprovidercron >/dev/null 2>&1
1212

1313
# vim: syntax=crontab

misc/subdomain-cert-renewal

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Suppress the output of the rest of the script.
5+
# To debug, redirect to a real file.
6+
exec &> /dev/null
7+
8+
CERTBOT=/root/.local/bin/certbot
9+
if ! [[ -x "$CERTBOT" ]]; then
10+
CERTBOT=certbot
11+
fi
12+
13+
"$CERTBOT" renew --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/

scripts/update_subdomain_certs.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ chmod 600 $credentials
5151
# Generate certificates
5252
echo "Generating certs..."
5353

54-
certbot certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp \
54+
CERTBOT=/root/.local/bin/certbot
55+
if ! [[ -x "$CERTBOT" ]]; then
56+
CERTBOT=certbot
57+
fi
58+
59+
"$CERTBOT" certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp \
5560
--config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ \
56-
--dns-subdomain-provider-credentials $credentials \
57-
-m $email --authenticator dns-subdomain-provider \
58-
-d $subdomain.bluecherry.app -v
61+
--dns-subdomain-provider-credentials "$credentials" \
62+
-m "$email" --authenticator dns-subdomain-provider \
63+
-d "$subdomain".bluecherry.app -v
5964

6065
rm $credentials
6166

0 commit comments

Comments
 (0)