dashPi: a self-hosted home dashboard, its sync server and phone app

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>
This commit is contained in:
Bashy 2026-10-24 09:35:12 +02:00
commit fb3c01cdd7
333 changed files with 45151 additions and 0 deletions

View file

@ -0,0 +1,65 @@
#!/bin/bash
# One-time setup of the sync server on a Debian/Ubuntu machine with Apache + PHP + certbot, run as
# root from the folder the server was copied to (e.g. /srv/dash-sync — anywhere outside other sites):
#
# sudo bash /srv/dash-sync/bin/setup-server.sh <host name> <account> [<device> …]
# sudo bash /srv/dash-sync/bin/setup-server.sh sync.example.com me
#
# It makes data/ (the web server's, 700), the Apache site (own file, nothing existing is edited),
# the Let's Encrypt certificate, the account and its first device (default: dashboard) — whose
# token it prints once, here in your terminal only. Phones and other dashboards get theirs from the
# dashboard: Settings ▸ General ▸ Devices (a QR code). Safe to run again: existing pieces are left alone.
set -euo pipefail
[ $# -ge 2 ] || { sed -n '2,10p' "$0"; exit 2; }
HOST=$1; ACCOUNT=$2; shift 2
if [ $# -gt 0 ]; then DEVICES=("$@"); else DEVICES=(dashboard); fi
DIR=$(cd "$(dirname "$0")/.." && pwd)
SITE=/etc/apache2/sites-available/dash-sync-$HOST.conf
LOGS='${APACHE_LOG_DIR}'
[ "$(id -u)" = 0 ] || { echo "run it with sudo"; exit 1; }
case "$DIR" in /var/www/html|/var/www/html/*) echo "copy it outside another site's folder (e.g. /srv/dash-sync)"; exit 1 ;; esac
cd "$DIR"
[ -f config.php ] || cp config.example.php config.php
mkdir -p data
chown -R www-data:www-data data
chmod 700 data
if [ ! -f "$SITE" ]; then
cat > "$SITE" <<EOF
# ── $HOST — dash-sync mailbox (dashboard + phone app; PROTOCOL.md) ──────
<VirtualHost *:80>
ServerName $HOST
DocumentRoot $DIR/public
<Directory $DIR/public>
AllowOverride All
Require all granted
</Directory>
LimitRequestBody 9437184
ErrorLog $LOGS/dash-sync.error.log
CustomLog $LOGS/dash-sync.access.log combined
</VirtualHost>
EOF
echo "site written: $SITE"
fi
a2enmod -q rewrite >/dev/null # public/.htaccess: every request → index.php
a2ensite -q "dash-sync-$HOST" >/dev/null
apache2ctl configtest
systemctl reload apache2
if [ ! -d /etc/letsencrypt/live/$HOST ]; then
certbot --apache -n --redirect -d $HOST
fi
admin() { sudo -u www-data php "$DIR/bin/admin.php" "$@"; }
admin add-account "$ACCOUNT" >/dev/null 2>&1 || true # already there on a second run
for dev in "${DEVICES[@]}"; do
if ! admin list 2>/dev/null | grep -qE "^$ACCOUNT +$dev "; then
echo; echo "== token for $dev (shown once — keep it for its setup):"
admin add-device "$ACCOUNT" "$dev"
fi
done
echo; echo "== check (should say 401 without a token):"
curl -s -o /dev/null -w "%{http_code}\n" https://$HOST/v1/hello || echo "not reachable yet (DNS / certificate?)"