summaryrefslogtreecommitdiffstats
path: root/postfix.sh
blob: 9e37e33ebbe1fd4f174ea02d2cfcfc50dd561f01 (plain) (blame)
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
# 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