Shared trip: one itinerary per server (data/trip.json, GET/PUT /api/trip, routed server-side), the route panel edits it when logged in and polls other screens' changes in without moving the camera; the GNSS simulation skips trips under 1 km and starts elsewhere when it can't get on from a road island; the car's server updates itself from a topbar button (SELF_UPDATE=1: newer main with CI passed → bin/update-maptool.sh via maptool-update.path); Android Auto and the trip's next steps in TODO
This commit is contained in:
1 parent
5f4c7c6ee8
commit
17891c53b5
16 files changed
+513
-5
No files matched your search
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# The car's server updating itself, when asked from the app: the update
|
||||
# button (POST /api/update) writes data/update/request.json with the commit,
|
||||
# maptool-update.path runs this as root (the container writes data/ as root).
|
||||
# Downloads that commit's tree from Gitea (the repo is public: no token),
|
||||
# swaps it into build/ (the old one kept as build.old) and restarts maptool;
|
||||
# data/update/status.json tells the app how far it got. docs/deployment.adoc.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=${MAPTOOL_ROOT:-/srv/podman/maptool}
|
||||
REPO_URL=${REPO_URL:-https://git.priesol.net/randy/maptool}
|
||||
DIR=$ROOT/data/update
|
||||
req=$DIR/request.json
|
||||
|
||||
[ -f "$req" ] || exit 0
|
||||
sha=$(sed -n 's/.*"sha" *: *"\([0-9a-f]\{40\}\)".*/\1/p' "$req")
|
||||
rm -f "$req"
|
||||
|
||||
status() {
|
||||
printf '{"state":"%s","sha":"%s","message":"%s","at":%s}\n' "$1" "$sha" "$2" "$(date +%s)" > "$DIR/status.json.tmp"
|
||||
mv "$DIR/status.json.tmp" "$DIR/status.json"
|
||||
}
|
||||
fail() { status failed "$1"; echo "update-maptool: $1" >&2; exit 1; }
|
||||
|
||||
[ -n "$sha" ] || fail "no commit in the request"
|
||||
status running "downloading ${sha:0:7}"
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
curl -fsS --retry 3 --retry-delay 5 --speed-limit 1024 --speed-time 60 -o "$tmp/src.tar.gz" "$REPO_URL/archive/$sha.tar.gz" \
|
||||
|| fail "download of ${sha:0:7} failed"
|
||||
mkdir "$tmp/build"
|
||||
tar -xzf "$tmp/src.tar.gz" -C "$tmp/build" --strip-components=1 || fail "the archive didn't unpack"
|
||||
[ -f "$tmp/build/app.rb" ] || fail "not a maptool tree"
|
||||
echo "${sha:0:7}" > "$tmp/build/REVISION"
|
||||
chown -R --reference="$ROOT" "$tmp/build"
|
||||
|
||||
rm -rf "$ROOT/build.old"
|
||||
mv "$ROOT/build" "$ROOT/build.old"
|
||||
mv "$tmp/build" "$ROOT/build"
|
||||
status restarting "restarting with ${sha:0:7}"
|
||||
systemctl restart podman-compose@maptool.service
|
||||
status done "updated to ${sha:0:7}"
|
||||
Reference in new issue
Block a user