Skip to content

Instantly share code, notes, and snippets.

@pcmoore
Created June 14, 2019 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcmoore/b6942a144419f8ddb981af4239f46966 to your computer and use it in GitHub Desktop.
Save pcmoore/b6942a144419f8ddb981af4239f46966 to your computer and use it in GitHub Desktop.
#!/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