Sync network time when a connection comes up

This commit is contained in:
Luxferre committed 2026-11-07 21:53:07 +02:00
1 parent 38d54f10ff
commit 9ac39ce6bf
13 files changed
+365 -8

No files matched your search

+38
View File
@@ -9,6 +9,44 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased — network-up NTP synchronisation
- **Fixed the clock never being set over the network**: `chronyd` resolves
`pool.ntp.org` only at startup and, with `minpoll 12`, waits up to 4096 s
for its first measurement. On this device it starts before NetworkManager
has installed a working `resolv.conf`, so `chronyc activity` reported
`4 sources with unknown address` and the clock stayed at 1970 even with
Wi-Fi connected. `iburst` is back in `etc/chrony/chrony.conf` so a daemon
started with DNS already up syncs in seconds; the long
`minpoll 12 maxpoll 16` steady-state interval is unchanged.
- **New `bananarchy-time-sync.sh`**: on a network-up event it calls
`chronyc refresh` (re-resolve the pool), `online` and `burst 2/4` over
chronyd's root-only Unix command socket. `cmdport 0` stays in place, so no
UDP command port is exposed. The helper waits for chronyd and for the pool
to resolve, throttles repeats using monotonic `/proc/uptime` (a 56-year
clock step cannot invalidate the stamp), serialises concurrent events with
`flock`, and skips bursts once the clock is synchronised. `status` prints
`chronyc tracking` / `sources`; `force` triggers a sync on demand.
- **Triggers**: `/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh`
handles `up`, `dhcp4-change`, `dhcp6-change`, `dns-change`,
`connectivity-change` and `vpn-up`; a new `bananarchy-time-sync` OpenRC
service (`need chronyd net`, `after networkmanager`) covers boot ordering
when NetworkManager events fire before chronyd is ready. Both are in the
default runlevel / dispatcher set and are guarded by
`scripts/check-rebuild.sh`.
- **Fixed the driftfile**: `/var/lib/chrony` was `root:root 0750`, so the
unprivileged `chrony` user could not write `chrony.drift` and its frequency
estimate was lost on every reboot. `rebuild-image.sh` and
`apply-bananarchy-overlay.sh` now chown it to the `chrony` uid/gid.
- Live verification on the connected phone: the shipped config left the
clock at `1970-01-12` with no NTP socket; `chronyc refresh` + `burst 2/4`
over `/run/chrony/chronyd.sock` resolved all four sources and stepped the
clock to `2026-11-07` within seconds. NetworkManager dispatcher events
were confirmed to fire (`dns-change`, `dhcp4-change`, `up`,
`connectivity-change`) on a Wi-Fi reconnect.
---
## Unreleased — reproducible device initramfs module lists
- `scripts/apply-bananarchy-overlay.sh` now installs the tracked