Skip to content

Commit 0c72a8a

Browse files
DEV: better SSL detection
With web.ssl.template.yml added: enable configuring of ssl if /shared/ssl/ssl.crt and /shared/ssl/ssl.key exists With web.letsencrypt.ssl.template.yml added: in addition to ssl detection, enable configuring of letsencrypt if LETSENCRYPT_ACCOUNT_EMAIL exists and is valid.
1 parent 0d9189d commit 0c72a8a

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

templates/web.letsencrypt.ssl.template.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,18 @@ run:
121121
122122
hooks:
123123
after_ssl:
124-
- file:
125-
path: /etc/runit/1.d/install-ssl
126-
chmod: "+x"
127-
contents: |
128-
#!/bin/bash
129-
if [ -z "$DISCOURSE_HOSTNAME" ]; then
130-
echo "DISCOURSE_HOSTNAME expected"
131-
exit 1
132-
fi
133-
if [ -z "$LETSENCRYPT_ACCOUNT_EMAIL" ]; then
124+
- replace:
125+
filename: /etc/runit/1.d/install-ssl
126+
from: "# after ssl"
127+
to: |
128+
if [ -n "$LETSENCRYPT_ACCOUNT_EMAIL" ]; then
129+
if [[ ! "$LETSENCRYPT_ACCOUNT_EMAIL" =~ ([^@]+)@([^\.]+) ]]; then
130+
echo "LETSENCRYPT_ACCOUNT_EMAIL is not a valid email address"
131+
exit 1
132+
fi
133+
/usr/local/bin/configure-ssl
134+
exec /usr/local/bin/configure-letsencrypt
135+
else
134136
echo "LETSENCRYPT_ACCOUNT_EMAIL ENV not set. Skipping Let's Encrypt setup."
135-
exit 0
136-
fi
137-
if [[ ! "$LETSENCRYPT_ACCOUNT_EMAIL" =~ ([^@]+)@([^\.]+) ]]; then
138-
echo "LETSENCRYPT_ACCOUNT_EMAIL is not a valid email address"
139-
exit 1
140137
fi
141-
/usr/local/bin/configure-ssl
142-
exec /usr/local/bin/configure-letsencrypt
138+
# after ssl

templates/web.ssl.template.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
env:
2-
ENABLE_SSL: 1
31
run:
42
- file:
53
path: /etc/runit/1.d/install-ssl
@@ -11,9 +9,13 @@ run:
119
echo "DISCOURSE_HOSTNAME expected"
1210
exit 1
1311
fi
14-
if [ -n "$ENABLE_SSL" ]; then
12+
if [ -f /shared/ssl/ssl.crt ] && [ -f /shared/ssl/ssl.key ]; then
1513
exec /usr/local/bin/configure-ssl
14+
exit 0
15+
else
16+
echo "Skipping ssl setup: missing /shared/ssl/ssl.crt or /shared/ssl/ssl.key"
1617
fi
18+
# after ssl
1719
1820
- file:
1921
path: "/usr/local/bin/configure-ssl"

0 commit comments

Comments
 (0)