The dashboard (Raspberry Pi 3.5" screen + web pages), the end-to-end encrypted sync mailbox (PHP + SQLite) and the Android companion app (Flutter), with docs, clean-install checks and screenshots made from demo data. Built mostly with an AI coding assistant; not yet reviewed line by line by a human (see README and SECURITY.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.3 KiB
Bash
Executable file
41 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# The dashboard from scratch, the way docs/dashboard.md says, in clean Debian containers (Docker):
|
|
# install.sh, every plugin on, then every page and the food search must answer, and a foreign Host is refused.
|
|
#
|
|
# tests/clean-install.sh Debian 12 (bookworm) and 13 (trixie)
|
|
# tests/clean-install.sh debian:trixie just that one
|
|
set -euo pipefail
|
|
REPO=$(cd "$(dirname "$0")/.." && pwd)
|
|
IMAGES=("${@:-debian:bookworm}"); [ $# -gt 0 ] || IMAGES=(debian:bookworm debian:trixie)
|
|
INSIDE='
|
|
set -e
|
|
cp -r /repo /tmp/repo && cd /tmp/repo/dashboard && rm -rf __pycache__
|
|
./install.sh --headless --no-service --user dash > /tmp/install.log 2>&1 || { tail -30 /tmp/install.log; exit 1; }
|
|
apt-get install -y -qq curl > /dev/null 2>&1
|
|
python3 - <<PY
|
|
import json; p = "/opt/dashboard/dash_config.json"; c = json.load(open(p))
|
|
for n in ("health", "food", "cycle", "workload", "activity", "notes"):
|
|
c.setdefault("plugins", {}).setdefault(n, {})["enabled"] = True
|
|
json.dump(c, open(p, "w"))
|
|
PY
|
|
cd /opt/dashboard && su -s /bin/bash dash -c "python3 dash.py --headless > /tmp/dash.log 2>&1 &"
|
|
for i in $(seq 30); do curl -s -o /dev/null http://127.0.0.1:8080/login && break; sleep 1; done
|
|
fail=0
|
|
for p in / /settings /weather /stations /week /month /health /health/sleep /food /cycle /work /activity /notes /app /login; do
|
|
code=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: localhost" http://127.0.0.1:8080$p)
|
|
[ "$code" = 200 ] || { echo "FAIL $p → $code"; fail=1; }
|
|
done
|
|
code=$(curl -s -o /dev/null -w "%{http_code}" -H "Host: evil.example" http://127.0.0.1:8080/)
|
|
[ "$code" = 400 ] || { echo "FAIL a foreign Host got $code (want 400)"; fail=1; }
|
|
n=$(curl -s -H "Host: localhost" "http://127.0.0.1:8080/food/api/foods?q=apple" | python3 -c "import json,sys; print(len(json.load(sys.stdin)[\"db\"]))")
|
|
[ "$n" -gt 0 ] || { echo "FAIL the food search found nothing"; fail=1; }
|
|
grep -q Traceback /tmp/dash.log && { echo "FAIL tracebacks in the log:"; grep -B2 -A12 Traceback /tmp/dash.log | head -60; fail=1; }
|
|
echo "python $(python3 -c "import sys; print(sys.version.split()[0])") · $(grep -c "plugin .*loaded" /tmp/dash.log) plugins loaded"
|
|
exit $fail
|
|
'
|
|
status=0
|
|
for img in "${IMAGES[@]}"; do
|
|
echo "== $img"
|
|
if docker run --rm -v "$REPO":/repo:ro "$img" bash -c "$INSIDE"; then echo "ok"; else echo "FAILED"; status=1; fi
|
|
done
|
|
exit $status
|