Arch’s GitLab instance is currently broken(?), so I can’t edit configuration, but merge requests against the package are(/will be) welcome at https://gitlab.archlinux.org/freso/networkmanager-dispatcher-chrony when I’m able to configure repository settings again (default settings aren’t allowing me to upload the existing history).
Search Criteria
Package Details: networkmanager-dispatcher-chrony 2.1-1
Package Actions
Git Clone URL: | https://aur.archlinux.org/networkmanager-dispatcher-chrony.git (read-only, click to copy) |
---|---|
Package Base: | networkmanager-dispatcher-chrony |
Description: | Dispatcher Script for chrony |
Upstream URL: | https://wiki.gnome.org/Projects/NetworkManager |
Keywords: | chrony dispatcher networkmanager ntp script |
Licenses: | MIT |
Submitter: | Freso |
Maintainer: | Freso (vinicentus) |
Last Packager: | Freso |
Votes: | 70 |
Popularity: | 0.064082 |
First Submitted: | 2011-11-01 22:21 (UTC) |
Last Updated: | 2015-07-12 13:43 (UTC) |
Dependencies (2)
Required by (0)
Sources (2)
Latest Comments
Freso commented on 2024-10-06 11:12 (UTC)
vinicentus commented on 2024-06-01 12:25 (UTC)
I made some modifications, namely excluding the lo interface, using a different connectivity check, and checking connectivity on any action. Hopefully this is useful to someone.
Full script
#!/bin/sh
INTERFACE=$1
STATUS=$2
# Make sure we're always getting the standard response strings
LANG='C'
CHRONY=$(which chronyc)
chrony_cmd() {
echo "Chrony going $1."
exec $CHRONY -a $1
}
nm_connected() {
# Let networkmanager check if we are able to reach the internet
[ "$(nmcli networking connectivity check)" = 'full' ]
}
case "$STATUS" in
up|vpn-up)
if [ "$INTERFACE" != "lo" ]; then
# Check for full connectivity, take online if connected
nm_connected && chrony_cmd online
fi
;;
down|vpn-down)
if [ "$INTERFACE" != "lo" ]; then
# Check for full connectivity, take offline if not connected
nm_connected || chrony_cmd offline
fi
;;
esac
soylens commented on 2023-09-11 13:04 (UTC)
The current logic of the dispatcher script causes chrony to go online as soon as the loopback device goes up. It sort of contradicts the purpose of the script halting chrony when no connection is available.
My suggestions: Either do the same connectedness check before going online as going offline, or blacklist devices like lo
from the script.
Beware that the result of nmcli g
at the time where the dispatcher is running could be connected (site only)
instead of connected
. Also I would like to point to the possibility of using chronyc onoffline
to let chrony decide whether to go on- or offline. However, I'm having trouble with a dispatcher script using onoffline
, in that chrony remains offline after my WLAN connects automatically on startup. Using online
instead, or connecting only after startup has finished, doesn't pose the problem.
pcmoore commented on 2019-06-14 02:27 (UTC)
I made some small changes to add NTP servers from DHCP and use chrony's built in network route detection to mark servers on/offline. If anyone is interested, I've put a copy up at the link below:
lotia commented on 2018-09-28 22:40 (UTC) (edited on 2018-09-28 22:46 (UTC) by lotia)
This script is errorring because it can't find 'which'. The error in the systemd journal is
/etc/NetworkManager/dispatcher.d/10-chrony: line 9: which: command not found
Instead it is possible to use 'command -v' to get the path of chronyc on line 9.
https://ptpb.pw/CW6Q has a patch that has been confirmed working.
Pinned Comments
Freso commented on 2024-10-06 11:12 (UTC)
Arch’s GitLab instance is currently broken(?), so I can’t edit configuration, but merge requests against the package are(/will be) welcome at https://gitlab.archlinux.org/freso/networkmanager-dispatcher-chrony when I’m able to configure repository settings again (default settings aren’t allowing me to upload the existing history).