Created
June 14, 2019 02:24
-
-
Save pcmoore/b6942a144419f8ddb981af4239f46966 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NetworkManager dispatcher script to update chrony's status and add NTP servers | |
# obtained via DHCP. Based on the AUR networkmanager-dispatcher-chrony script. | |
INTERFACE=$1 | |
STATUS=$2 | |
# make sure we're always getting the standard response strings | |
LANG='C' | |
CHRONY=$(which chronyc) | |
function chrony_status() { | |
$CHRONY -a $1 | |
} | |
function chrony_servers() { | |
for i in $DHCP4_NTP_SERVERS $DHCP6_NTP_SERVERS; do | |
$CHRONY add server $i iburst | |
done | |
} | |
case "$STATUS" in | |
up|vpn-up) | |
chrony_servers | |
chrony_status onoffline | |
rc=$? | |
;; | |
down|vpn-down) | |
chrony_status onoffline | |
rc=$? | |
;; | |
*) | |
rc=0 | |
esac | |
return $rc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment