summaryrefslogtreecommitdiff
path: root/roles/x509/acmetool/cert/prepare/templates/reload.sh.j2
blob: 8e1c00c6a15a5066ac562142168a98ea9e27a269 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -e
EVENT_NAME="$1"
[ "$EVENT_NAME" = "live-updated" ] || exit 42

MAIN_HOSTNAME="{{ acmetool_cert_hostnames[0] }}"

while read name; do
  certdir="$ACME_STATE_DIR/live/$name"
  if [ -z "$name" -o ! -e "$certdir" ]; then
    continue
  fi
  if [ "$name" != "$MAIN_HOSTNAME" ]; then
    continue
  fi
{% if 'install' in x509_certificate_renewal %}

{%   for file in x509_certificate_renewal.install %}
  install{% if 'mode' in file %} -m {{ file.mode }}{% endif %}{% if 'owner' in file %} -o {{ file.owner }}{% endif %}{% if 'group' in file %} -g {{ file.group }}{% endif %} /dev/null "{{ file.dest }}.new"
{%     for src in file.src %}
{%       set src_file = lookup('vars', 'x509_certificate_path_' + src) %}
{%       if src_file != "" %}
  cat "{{ src_file }}" >> "{{ file.dest }}.new"
{%       endif %}
{%     endfor %}
  mv "{{ file.dest }}.new" "{{ file.dest }}"
{%   endfor %}
{% endif %}
{% if 'reload' in x509_certificate_renewal %}

  {{ x509_certificate_renewal.reload | trim | indent(2) }}
{% endif %}
  break
done