deploy: add macOS-friendly deploy scripts (local / hardware / prod)

- deploy.sh dispatcher + thin shims (deploy-local.sh / -hardware.sh / -prod.sh).
- scripts/deploy/local.sh: build UI bundle and serve via tmux session on :8770 for offline iteration.
- scripts/deploy/hardware.sh: rsync-based push to a Pi over SSH and restart bbctrl.service.
- scripts/deploy/prod.sh: bundle release tarball.
- scripts/deploy/patch_font_mime.py: hot-patches Chromium 72's broken WOFF2 mime handling on the kiosk Pi.
This commit is contained in:
2026-05-03 14:03:50 +02:00
parent f170002c8b
commit 0d5370a724
8 changed files with 364 additions and 0 deletions

72
scripts/deploy/local.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
# --- Local development (macOS) ---
#
# Builds the UI bundle and static-serves it on http://localhost:8770/.
# Runs in a named tmux session so we can iterate (re-running this script
# rebuilds and restarts the server in-place, you keep your browser tab).
#
# What you'll see:
# * The full V09 chrome (header tabs, settings rail, jog grid, DRO
# skeleton, status strip).
# * A "DISCONNECTED" overlay because there's no controller backend.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$SCRIPT_DIR"
echo "🛠 Building UI bundle..."
make build/http/index.html >/dev/null
PORT="${PORT:-8770}"
SESSION="onefin-local"
ensure_tmux_window() {
local session="$1"
local window="${2:-}"
local target="${session}${window:+:$window}"
if tmux has-session -t "$session" 2>/dev/null; then
if tmux send-keys -t "$target" "" 2>/dev/null; then
echo "🔁 Reusing tmux session '$session'..."
tmux send-keys -t "$target" C-c
sleep 1
return
fi
echo "⚠️ Dead pane in '$session', recreating..."
tmux kill-session -t "$session" 2>/dev/null
fi
echo "🆕 Creating tmux session '$session'..."
tmux new-session -d -s "$session"
}
ensure_tmux_window "$SESSION"
# Free the port if a previous run is still listening.
if lsof -iTCP:"$PORT" -sTCP:LISTEN >/dev/null 2>&1; then
echo "⚠️ Port $PORT is busy; killing previous server..."
lsof -tiTCP:"$PORT" -sTCP:LISTEN | xargs -r kill 2>/dev/null || true
sleep 1
fi
tmux send-keys -t "$SESSION" \
"cd '$SCRIPT_DIR' && python3 -m http.server --directory build/http $PORT" \
C-m
echo ""
echo "✅ Static UI server started on http://localhost:$PORT/"
echo ""
echo " Routes to try:"
echo " http://localhost:$PORT/#control"
echo " http://localhost:$PORT/#program"
echo " http://localhost:$PORT/#console"
echo " http://localhost:$PORT/#settings (Display & Units)"
echo " http://localhost:$PORT/#admin-network (WiFi / IP)"
echo " http://localhost:$PORT/#motor:0 (Motor 0 settings)"
echo ""
echo " tmux: tmux attach -t $SESSION"
echo " stop: tmux kill-session -t $SESSION"
echo ""
echo " No controller is running, so the page shows DISCONNECTED and"
echo " axis values stay empty. For live data + W axis, run:"
echo " ./deploy.sh hardware (fast: rsync build/http -> Pi)"
echo " ./deploy.sh prod (full firmware update)"