Library sync OsmAnd-style: brick is the server, a client (the car's maptool, SYNC_SERVER_URL) syncs on its Sync button — pulls the server's rows, pushes its own with the source files the server lacks, newer updated_at wins; /api/sync/* guarded by SYNC_TOKEN (written into brick's .env by CI). TRUSTED_NETWORKS logs in the car's LAN (no Gitea offline); TAKEOUT_HOST_DIR for a server without the Takeout; bin/pull-maps.sh pulls map data one way while at home
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-27 23:22:32 +01:00
1 parent 850a5946ad
commit dbe742321a
13 files changed
+460 -5

No files matched your search

+39
View File
@@ -175,6 +175,45 @@ topics. Blank `MQTT_URL` turns it off. The URL needs a name the
container can resolve — `ha.local` (mDNS) doesn't resolve inside it,
`mqtt://ha.priesol.net:1883` does.
== The car's server (rpi-dev, later the van's CM5)
A second maptool on a Raspberry Pi (Debian, arm64, rootful podman +
podman-compose), laid out like brick's: `/srv/podman/maptool/{build,data,.env}`,
the same `podman-compose@.service` unit. Deployed by hand for now (the
working tree rsynced into `build/`), not by CI.
Its `.env` adds:
* `TRUSTED_NETWORKS` — the home/car LAN (and loopback): those requests
count as logged in, since Gitea's OAuth needs internet and its redirect
URL is brick's. Only on a server no reverse proxy sits in front of —
never on brick, where every request comes from the proxy.
* `TAKEOUT_HOST_DIR` — an empty directory (the Takeout import is brick's).
* `SYNC_SERVER_URL` (`https://map.priesol.net`) and `SYNC_TOKEN`: it's a sync client.
=== Library sync (both ways, OsmAnd-style)
brick is the server, the car's maptool a client: the client's Sync button
(Tracks & Points header, shown only where `SYNC_SERVER_URL` is set) pulls
the server's changes, then pushes its own (`lib/maptool/sync.rb`; the
server's `GET /api/sync/changes`, `GET`/`PUT /api/sync/source/:id`,
`POST /api/sync/apply`, all guarded by the shared `SYNC_TOKEN`). Newer
`updated_at` wins, source files come along, progress in the client's
`data/sync_state.json`. Over the public URL, so no VPN is needed for it.
On brick the CI deploy writes `SYNC_TOKEN` (a Gitea secret) into `.env`.
=== Map data (one way)
`bin/pull-maps.sh`, run by `maptool-pull-maps.timer` (10 min after boot,
then every 6 h) as `randy`: rsyncs the pmtiles, routing, places, hiking
trails, the ZIM and the NPS maps from brick while brick is reachable, and
restarts maptool when something changed. Its key is limited on brick
(`~randy/.ssh/authorized_keys`) to a read-only rsync of the data dir:
----
command="python3 /usr/share/doc/packages/rsync/support/rrsync -ro /srv/podman/maptool/data",restrict ssh-ed25519 AAAA… rpi-dev maptool map sync
----
== Garmin LiveTrack session webhook
`POST /api/livetrack/session` (`session_id`, `session_token`, `secret` form