]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
examples: add NetworkManager dispatcher script
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 4 Sep 2014 15:43:27 +0000 (17:43 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 4 Sep 2014 15:43:27 +0000 (17:43 +0200)
examples/chrony.nm-dispatcher [new file with mode: 0644]

diff --git a/examples/chrony.nm-dispatcher b/examples/chrony.nm-dispatcher
new file mode 100644 (file)
index 0000000..d23700b
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# This is a NetworkManager dispatcher script for chronyd to set its NTP sources
+# online/offline when a default route is configured/removed on the system.
+
+export LC_ALL=C
+
+if [ "$2" = "up" ]; then
+       /sbin/ip route list dev "$1" | grep -q '^default' &&
+               /usr/bin/chronyc -a online > /dev/null 2>&1
+fi
+
+if [ "$2" = "down" ]; then
+       /sbin/ip route list | grep -q '^default' ||
+               /usr/bin/chronyc -a offline > /dev/null 2>&1
+fi
+
+exit 0