summaryrefslogtreecommitdiff
path: root/playbooks/roles/mail/templates/volumes/scripts/wait-for-postfix.unused.sh
blob: 3e8a8c5d492c813dd0cc4c1e077003976459745f (plain)
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
# This was an attempt to keep rolling updates with very little downtime.
# I don't think it's worth it, and the nature of update_config provides
# little flexibility to use here.

#!/bin/bash
set -e

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

LOCKFILE="/var/mail-state/lib-postfix/master.lock"
MAX_TRIES=30
TRY=0

while [ -f "$LOCKFILE" ]; do
  if [ "$TRY" -eq "$MAX_TRIES" ]; then
    log "[$TRY/$MAX_TRIES] Max tries, failing."
    exit 1
  fi
  log "[$TRY/$MAX_TRIES] Lockfile exists, waiting for it to be cleaned up by previous container..."
  sleep 2
  TRY=$((TRY + 1))
done

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