From daef0cf448af17357b552245f39067a9d340ce3d Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 27 Apr 2025 21:15:30 -0700 Subject: Waow --- .../volumes/scripts/check-postfix-health.unused.sh | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 playbooks/roles/mail/templates/volumes/scripts/check-postfix-health.unused.sh (limited to 'playbooks/roles/mail/templates/volumes/scripts/check-postfix-health.unused.sh') diff --git a/playbooks/roles/mail/templates/volumes/scripts/check-postfix-health.unused.sh b/playbooks/roles/mail/templates/volumes/scripts/check-postfix-health.unused.sh new file mode 100644 index 0000000..198221a --- /dev/null +++ b/playbooks/roles/mail/templates/volumes/scripts/check-postfix-health.unused.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +LOCKFILE="/var/mail-state/lib-postfix/master.lock" + +function log() { + echo "[health] $@" +} + +if [ -f "$LOCKFILE" ]; then + PID=$(cat "$LOCKFILE") + log "pid $PID" + if kill -0 "$PID" 2>/dev/null; then + if ss --listening --tcp | grep -P 'LISTEN.+:smtp' > /dev/null; then + log "successfully listening to smtp" + exit 0 + fi + else + # Not our postfix lock. + exit 0 + fi +fi + +log "bad health state" +exit 1 -- cgit v1.2.3-70-g09d2