launch: seed time whenever the clock is before 2026-10-09 (stale RTC defeats the 2020 check)

This commit is contained in:
1okko
2026-10-09 22:50:56 +08:00
parent ee69034e3e
commit 1e58de131a
+6 -5
View File
@@ -28,10 +28,11 @@ export STREAM_QUALITY=50
export STREAM_FPS=10
# --- system time (this hardware has no battery-backed RTC) ---
# Every boot the clock starts at 1970, which breaks TLS: the model list and downloads fail
# with "certificate is not yet valid" until NTP or GPS catches up. Seed a recent date so TLS
# works from the start; NTP/GPS correct it to the second afterwards.
if [ "$(date +%Y)" -lt 2020 ]; then
# On a cold boot there is no sane clock: AGNOS restores a stale timestamp (or the epoch),
# which is still far earlier than the TLS certificate validity and makes the model
# list/download fail with "certificate is not yet valid". Force a known-recent date so
# TLS works immediately; NTP/GPS correct it afterwards.
if [ "$(date +%Y%m%d)" -lt 20261009 ]; then
sudo date -s "2026-10-09 12:00:00" >/dev/null 2>&1
printf 'seeded %s (was < 2020)\n' "$(date -Is)" >> /data/time_seed.log 2>/dev/null
printf 'seeded %s (was earlier than 2026-10-09)\n' "$(date -Is)" >> /data/time_seed.log 2>/dev/null
fi