summaryrefslogtreecommitdiff
path: root/roles/x509/uacme/base/templates/uacme-reconcile.sh.j2
blob: ea02841d8464eedbc336ca42f38c514abf815d42 (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
#!/bin/bash

declare -a csr_files
if [ -n "$1" ]; then
  csr_files+=("/var/lib/uacme.d/$1/$1.csr")
else
  readarray -d '' csr_files < <(find /var/lib/uacme.d -name "*.csr" -print0)
fi

export UACME_CHALLENGE_PATH="{{ uacme_challenge_webroot_path | default('/var/run/acme/acme-challenge') }}"

failed=0
for csr_file in "${csr_files[@]}"; do
  id=$(basename -s .csr "$csr_file")
  uacme -c /var/lib/uacme.d -a "{{ uacme_directory_server }}" -h /usr/share/uacme/uacme.sh -n issue "$csr_file"
  case $? in
    0)
      echo "$id successfully (re)issued."
      if [ -x "/var/lib/uacme.d/$id/updated.sh" ]; then
        /var/lib/uacme.d/$id/updated.sh
      fi
      ;;
    1)
      echo "$id not updated."
      ;;
    *)
      failed=1
      ;;
  esac
done

exit $failed