S.H.O.N.A.R._Desktop_Companion/setup-standalone.sh
avi 7234a62eb5 Debian support: verified build/packaging path + friend install guide
- setup-standalone.sh: falls back to system python3 -m venv + pip when
  uv isn't installed (Debian/Ubuntu path; verified on clean bookworm).
- dist/Dockerfile.debian: debian:bookworm build env for :app:packageDeb
  (needs fakeroot + /usr/share/desktop-directories — both baked in; the
  dir gap made jpackage's postinst fail with exit 3 on minimal systems).
- dist/make-release.sh: clean source tarball from HEAD.
- INSTALL-debian.md: end-to-end install for friends (source tree must
  stay on disk — the app spawns the engine from it via SHONAR_REPO).

Verified on real Debian 12 in Docker: :app:packageDeb builds
shonar-desktop_0.1.0-1_amd64.deb, apt installs it, setup-standalone.sh
provisions the engine (venv+pip path, model fetch, boot smoke test),
and the packaged binary launches under Xvfb.
2026-09-15 07:10:27 -05:00

68 lines
2.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# One-shot provisioning for a fresh clone of SHONAR Desktop:
# local engine venv + vendored whisper base model. Idempotent.
set -uo pipefail
cd "$(dirname "$0")"
echo "==> backend venv (local, editable install of THIS backend)"
if [ ! -x backend/.venv/bin/uvicorn ]; then
if command -v uv >/dev/null; then
(cd backend && uv venv .venv --python 3.11 && uv pip install -p .venv/bin/python -e ".[dev,faster-whisper]")
else
# Plain Debian/Ubuntu path: system python3 (3.11 on bookworm) + venv + pip.
command -v python3 >/dev/null || { echo "python3 not found — install python3-venv"; exit 1; }
python3 -m venv backend/.venv || { echo "python3 -m venv failed — install the python3-venv package"; exit 1; }
backend/.venv/bin/pip install --upgrade pip >/dev/null
backend/.venv/bin/pip install -e "backend[dev,faster-whisper]"
fi
else
echo " already present"
fi
echo "==> whisper base model -> models/hf-cache"
MC="models/hf-cache/models--Systran--faster-whisper-base"
if [ -d "$MC/snapshots" ] && [ -n "$(ls -A "$MC/snapshots" 2>/dev/null)" ]; then
echo " already present"
else
# Prefer copying an existing local copy (works offline)...
src=""
for c in "${HF_HUB_CACHE:-$HOME/.cache/huggingface/hub}/models--Systran--faster-whisper-base" \
"$HOME/.cache/huggingface/hub/models--Systran--faster-whisper-base"; do
[ -d "$c/snapshots" ] && { src="$c"; break; }
done
mkdir -p models/hf-cache
if [ -n "$src" ]; then
echo " copying from $src"
cp -r "$src" models/hf-cache/
else
echo " no local copy — downloading from HuggingFace (needs internet once)"
backend/.venv/bin/python - <<'EOF'
from huggingface_hub import snapshot_download
snapshot_download("Systran/faster-whisper-base", cache_dir="models/hf-cache")
EOF
fi
fi
echo "==> smoke: engine boots on :8123 with the bundled cache"
tmp=$(mktemp -d)
SHONAR_SECRET_KEY="bootstrap-verify-secret-0123456789abcdef" \
SHONAR_DATABASE_URL="sqlite+aiosqlite:///$tmp/e.db" \
SHONAR_QUEUE_BACKEND=inline SHONAR_AUTO_MIGRATE=1 \
SHONAR_STORAGE_PATH="$tmp/storage" \
HF_HUB_CACHE="$PWD/models/hf-cache" \
backend/.venv/bin/uvicorn shonar.main:app --app-dir backend --port 8123 \
>"$tmp/uvicorn.log" 2>&1 &
pid=$!
ok=""
for _ in $(seq 1 30); do
sleep 1
curl -sf -m 2 http://127.0.0.1:8123/api/v1/readyz >/dev/null && { ok=1; break; }
done
kill $pid 2>/dev/null; wait $pid 2>/dev/null
rm -rf "$tmp"
if [ -n "$ok" ]; then
echo " engine ready — provisioning complete. Start the app: ./desktop-dev.sh"
else
echo " ENGINE FAILED TO START" >&2
exit 1
fi