summaryrefslogtreecommitdiff
path: root/playbooks/roles/mail/templates/volumes/scripts/wait-for-cert.sh
blob: 0f8018cbb49b5e99ef944bde973ffebf86fd59ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
set -e

function log() {
  echo "[cert] $@"
}

CERT="/certs/{{ mail_domain }}.pem"
MAX_TRIES=30
TRY=0

while [ ! -f "$CERT" ]; do
  if [ "$TRY" -eq "$MAX_TRIES" ]; then
    log "[$TRY/$MAX_TRIES] Max tries, failing."
    exit 1
  fi
  log "[$TRY/$MAX_TRIES] Certificate nonexistant. Waiting..."
  sleep 2
  TRY=$((TRY + 1))
done

log "Cert check done. Starting DMS."
supervisord -c /etc/supervisor/supervisord.conf