From e31d55ca615de511dddf8fdee4ad913b5acb3051 Mon Sep 17 00:00:00 2001
From: Jamie McClelland <jm@mayfirst.org>
Date: Mon, 12 Oct 2020 19:19:33 -0400
Subject: [PATCH] fix syntax error.

---
 .../cert-renew-scripts/mf-cert-renew-postfix   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/roles/mayfirst/files/cert-renew-scripts/mf-cert-renew-postfix b/roles/mayfirst/files/cert-renew-scripts/mf-cert-renew-postfix
index f45bcd4f..da8719da 100755
--- a/roles/mayfirst/files/cert-renew-scripts/mf-cert-renew-postfix
+++ b/roles/mayfirst/files/cert-renew-scripts/mf-cert-renew-postfix
@@ -1,3 +1,21 @@
 #!/bin/bash
 
+# If we are in dev or testing mode, AND we are running postfix multi, then we
+# hide errors and always return code 0. That's because postfix will fail to
+# restart on every certificate addition *except* the last one. The earlier ones
+# will fail because the instances that depend on the certificates to be present
+# will be restarted before the certificates are, in fact, present.
+
+return_zero=n
+if grep ^multi_instance /etc/postfix/main.cf 2>&1 >/dev/null; then
+  return_zero=y
+fi
 /bin/systemctl restart postfix
+real_return_code="$?"
+
+if [ "$return_zero" = y  ]; then
+  exit 0
+else
+  exit "$real_return_code"
+fi
+
-- 
GitLab