summaryrefslogtreecommitdiff
path: root/frontends/scripts
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2022-07-23 10:47:16 +0100
committerPaul Buetow <paul@buetow.org>2022-07-23 10:47:16 +0100
commitd32a317172229c7cad21d93dbc287716fb993a1b (patch)
tree33568d1b3ede343cbd3ffb3c23d590b9fa4db28b /frontends/scripts
parentc14126bdb3cebec42e9e8216d360b724228df222 (diff)
also add smtpd to use acme
Diffstat (limited to 'frontends/scripts')
-rw-r--r--frontends/scripts/acme.sh.tpl31
1 files changed, 21 insertions, 10 deletions
diff --git a/frontends/scripts/acme.sh.tpl b/frontends/scripts/acme.sh.tpl
index 8039168..45be254 100644
--- a/frontends/scripts/acme.sh.tpl
+++ b/frontends/scripts/acme.sh.tpl
@@ -5,18 +5,29 @@
our $prefix = $primary ? '' : 'www.';
-%>
+function handle_cert {
+ host=$1
+ # Create symlink, so that relayd also can read it.
+ crt_path=/etc/ssl/$host
+ if [ -e $crt_path.crt ]; then
+ rm $crt_path.crt
+ fi
+ ln -s $crt_path.fullchain.pem $crt_path.crt
+ # Requesting and renewing certificate.
+ /usr/sbin/acme-client -v $host
+}
+
+has_update=no
<% for my $host (@$acme_hosts) { -%>
-# Requesting and renewing certificate.
-/usr/sbin/acme-client -v <%= $prefix.$host %>
-# Create symlink, so that relayd also can read it.
-crt_path=/etc/ssl/<%= $prefix.$host %>
-if [ -e $crt_path.crt ]; then
- rm $crt_path.crt
+handle_cert <%= $prefix.$host %>
+if [ $? -eq 0 ]; then
+ has_update=yes
fi
-ln -s $crt_path.fullchain.pem $crt_path.crt
-
<% } -%>
# Pick up the new certs.
-/usr/sbin/rcctl reload httpd
-/usr/sbin/rcctl reload relayd
+if [ $has_update = yes ]; then
+ /usr/sbin/rcctl reload httpd
+ /usr/sbin/rcctl reload relayd
+ /usr/sbin/rcctl restart smtpd
+fi