From 799dc834e0fe94ed62c0d6bb65e6d15a639ab668 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sat, 12 Jul 2025 07:52:42 +0100 Subject: initial commit --- postfix.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 postfix.sh (limited to 'postfix.sh') 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 " 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 -- cgit v1.2.3