summaryrefslogtreecommitdiffstats
path: root/postfix.sh
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-12 07:52:42 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-12 07:52:42 +0100
commit799dc834e0fe94ed62c0d6bb65e6d15a639ab668 (patch)
treebb3b7a89764f768b6b1c4a4918e9eb37a88645b8 /postfix.sh
downloadlfldap-799dc834e0fe94ed62c0d6bb65e6d15a639ab668.tar.gz
lfldap-799dc834e0fe94ed62c0d6bb65e6d15a639ab668.tar.bz2
initial commitv1.0
Diffstat (limited to 'postfix.sh')
-rw-r--r--postfix.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/postfix.sh b/postfix.sh
new file mode 100644
index 0000000..9e37e33
--- /dev/null
+++ b/postfix.sh
@@ -0,0 +1,26 @@
+# This source code is released into the public domain.
+#
+# The Postfix mynetworks.ldap file is a list of "<prefix> OK", one per line.
+# Since this is a cidr map, there's no need to run postmap, but we do have
+# to reload postfix.
+
+POSTFIX_FILE="/usr/local/etc/postfix/mynetworks.ldap"
+POSTFIX_TEMP="${POSTFIX_FILE}.ldaptmp"
+
+if [ ! -f "$POSTFIX_FILE" ]; then
+ exit 0
+fi
+
+awk <"$NETWORKS_FILE" >"$POSTFIX_TEMP" '{ print $1 " OK" }'
+
+if cmp -s "$POSTFIX_TEMP" "$POSTFIX_FILE"; then
+ rm "$POSTFIX_TEMP"
+ exit 0
+fi
+
+printf '%s updated:\n\n' "$POSTFIX_FILE"
+diff "$POSTFIX_FILE" "$POSTFIX_TEMP"
+printf '\n'
+
+mv "$POSTFIX_TEMP" "$POSTFIX_FILE"
+/usr/local/sbin/postfix reload