chrony/chronyd-nm-dispatcher

24 lines
707 B
Plaintext
Raw Permalink Normal View History

#!/bin/sh
INTERFACE="$1" # The interface which is brought up or down
STATUS="$2" # The new state of the interface
case "$STATUS" in
'up') # $INTERFACE is up
# Check to see if the interface added a default route
/sbin/ip route list dev "$INTERFACE" 2>/dev/null | grep -q '^default' || exit 0
/usr/libexec/chrony-helper is-running
if [ $? -ne 0 ]; then
systemctl --no-block start chronyd
else
/usr/libexec/chrony-helper command online >/dev/null 2>&1
fi
;;
'down') # $INTERFACE is down
/sbin/ip route list 2>/dev/null | grep -q '^default' && exit 0
/usr/libexec/chrony-helper command offline > /dev/null 2>&1
;;
esac