Add Config -> Sync net time manual trigger

The reflashed image starts chronyd at ~27 s, before NetworkManager installs
a usable resolv.conf, so pool.ntp.org stays unresolved and minpoll 12 would
wait up to 4096 s. Wi-Fi came up at ~30 s but the clock was only stepped at
~112 s, when usb0 emitted another dispatcher event.

- Config -> Sync net time in the built-in dmenu Config menu runs
  bananarchy-sync-net-time.sh, forces a burst via bananarchy-time-sync.sh
  sync and shows a desktop notification with the UTC date or a failure.
- New sync mode reports success/failure and exit status; resolved() now
  requires at least one known source, DNS waits run before the flock, and
  network-up/force/sync get 8 retries so a slow boot retry cannot swallow
  network-up events.
- Rebuilt dmenu.so from src/sxmo-dmenu/dmenu.c into prebuilt/ and overlay/;
  apply-bananarchy-overlay.sh keeps the wrapper root-owned and executable;
  check-rebuild.sh guards the menu entry, wrapper and sync mode.
- Rebuilt and verified images/bananarchy-nokia-argon.img (all new files
  byte-identical to overlay, boot.img unchanged, 27 initramfs modules).

Live verification on the reflashed phone: helper sync as the X session user
prints "Network time synced: 2026-11-07 20:17:43 UTC", the wrapper posts a
notification, a DNS-down sync fails clearly after 16 s, restoring DNS syncs
again, and the rebuilt dmenu daemon was reloaded with the new Config item.
This commit is contained in:
Luxferre committed 2026-11-07 22:22:02 +02:00
1 parent 9ac39ce6bf
commit 85c6a7b886
12 files changed
+177 -16

No files matched your search

+45
View File
@@ -868,3 +868,48 @@ clock from `1970-01-12` to `Sat Nov 7 19:40:25 UTC 2026` within seconds;
time`. No UDP chronyc port was opened. The steady-state poll interval remains
`minpoll 12 maxpoll 16`, so U6's battery saving is preserved; the only extra
traffic is one short burst at boot and on each network transition.
### 16.4 Reflashed boot: why autosync still took 80 s
The image was reflashed and the boot was measured from `/proc/uptime`,
NetworkManager's `timestamps` file, OpenRC's `/run/openrc/started` symlinks,
`chronyc sources` and the helper's `/run/bananarchy-time-sync/last` stamp.
The RTC held `1970-01-12 12:39:26 UTC` (epoch 995966), so all boot file
timestamps are on that fake date and map to uptime by subtracting 995966:
| Uptime | Event |
| --- | --- |
| 0 s | kernel sets the clock from `rtc-pm8xxx` to 1970-01-12 12:39:26 UTC |
| ~27 s | NetworkManager, `chronyd`, `bananarchy-time-sync` started; chronyd resolves the pool before DNS exists, so all 8 sources stay `unknown address` |
| ~30 s | dnsmasq, wlan0 DHCP lease, `resolv.conf`; Wi-Fi `OffOurStreets_` activated (NM timestamp 995997) |
| ~112 s | USB RNDIS (`usb0`) activated (NM timestamp 996078); helper stamp 112; first NTP samples; clock stepped to 2026-11-07 20:04:23 UTC |
So `chronyd` did autostart, but at boot rather than on Wi-Fi: OpenRC `need net`
is satisfied by NetworkManager `provide net` as soon as the daemon starts.
`chronyd` resolves `pool.ntp.org` once, at ~27 s, before dnsmasq is up; with
`minpoll 12` an unresolved pool produces no packets for up to 4096 s. The
network-up hook is meant to fix that, but none of the Wi-Fi dispatcher events
(`up`, `dns-change`, `dhcp4-change`) at ~30 s produced a burst: the boot
helper either held `/run/bananarchy-time-sync/lock` for its whole 60 s
`refresh` retry loop (so `flock -n 9` dropped them) or had already written its
15 s throttle stamp after `resolved()` mistook a zero-source `activity` report
for a resolved pool. The next event was `usb0 up` at ~112 s, which finally ran
the helper and synced the clock. A controlled reproduction
with `nameserver 127.0.0.9` showed chronyd does not re-resolve on its own
(8 unknown sources for 10 s after DNS was restored) while `chronyc refresh`
resolves them within ~4 s.
Fixes, without changing the long steady-state poll interval:
- `wait_chronyd()` and `wait_sources()` now run before the lock is taken; only
the stamp / `online` / `burst` section is serialised, with `flock -w 5`.
A slow boot retry can no longer swallow network-up events.
- `resolved()` requires at least one known source (online, offline or doing a
burst) in addition to `0 sources with unknown address`, so a chronyd that
has not created any pool sources yet cannot cause a no-op burst.
- `network-up` / `force` / `sync` get 8 retries (16 s) instead of 3 (6 s).
- `bananarchy-time-sync.sh sync` waits up to 15 s for `chronyc tracking` to
show a reference ID and prints `Network time synced: <UTC date>` or a clear
failure. **Config -> Sync net time** calls it via
`bananarchy-sync-net-time.sh` and shows a desktop notification, so the user
can always force a sync without a shell.