summaryrefslogtreecommitdiffstats
path: root/chrony.sh
blob: b91a5c36d52120971d999829ee2f256d7d19ce53 (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
27
# This source code is released into the public domain.
#
# The chrony.allow file is a list of "allow <prefix>", one per line,
# no traiing semicolon.  chrony doesn't have a simple way to reload
# its configuration file, so we just restart it.  A better way might
# be to use "chronyc allow" to update it on the fly.

CHRONY_FILE="/usr/local/etc/chrony.allow"
CHRONY_TEMP="${CHRONY_FILE}.ldaptmp"

if [ ! -f "$CHRONY_FILE" ]; then
	exit 0
fi

awk <"$NETWORKS_FILE" >"$CHRONY_TEMP" '{ print "allow " $1 }'

if cmp -s "$CHRONY_TEMP" "$CHRONY_FILE"; then
	rm "$CHRONY_TEMP"
	exit 0
fi

printf '%s updated:\n\n' "$CHRONY_FILE"
diff "$CHRONY_FILE" "$CHRONY_TEMP"
printf '\n'

mv "$CHRONY_TEMP" "$CHRONY_FILE" 
/usr/local/etc/rc.d/chronyd restart