]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
examples: update NetworkManager dispatcher script
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 May 2018 15:03:31 +0000 (17:03 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 May 2018 08:53:21 +0000 (10:53 +0200)
Replace most of the code with the new onoffline command.

examples/chrony.nm-dispatcher

index 8bd7df01d4a1ee089c90cbf45f50a410889f69e1..0b0c3e7103e5254212d5bb1d98eea4e0ca159701 100644 (file)
@@ -10,32 +10,6 @@ export LC_ALL=C
 
 # Note: for networkd-dispatcher routable.d ~= on and off.d ~= off
 
-# Check if there is a default route
-
-if /sbin/ip route list 2> /dev/null | grep -q '^default'; then
-  chronyc online > /dev/null 2>&1
-  exit 0
-fi
-
-sources=$(chronyc -c -n sources 2> /dev/null)
-
-[ $? -ne 0 ] && exit 0
-
-# Check each configured source if it has a route
-
-echo "$sources" | while IFS=, read mode state address rest; do
-  [ "$mode" != '^' ] && [ "$mode" != '=' ] && continue
-
-  /sbin/ip route get "$address" > /dev/null 2>&1 && command="online" || command="offline"
-
-  # Set priority of sources so that the selected source is set as
-  # last if offline to avoid unnecessary reselection
-  [ "$state" != '*' ] && priority=1 || priority=2
-
-  echo "$priority $command $address"
-
-done | sort | while read priority command address; do
-  echo "$command $address"
-done | chronyc > /dev/null 2>&1
+chronyc onoffline > /dev/null 2>&1
 
 exit 0