namespace backend.Install; public class InstallScriptBuilder { public string Build(string backendUrl) { return $$""" #!/usr/bin/env bash # Smart Assistant installer (idempotent). Re-run to upgrade. set -euo pipefail BACKEND_URL="{{backendUrl}}" ASSISTANT_HOME="$HOME/assistant" RESET=0 for arg in "$@"; do case "$arg" in --reset) RESET=1 ;; esac done echo "Installing system deps (sudo password may be prompted)..." sudo apt-get update -qq sudo apt-get install -y --no-install-recommends python3-venv libportaudio2 alsa-utils mkdir -p "$ASSISTANT_HOME/code" "$ASSISTANT_HOME/state" if [ ! -d "$ASSISTANT_HOME/.venv" ]; then python3 -m venv "$ASSISTANT_HOME/.venv" fi echo "Downloading client bundle from $BACKEND_URL ..." curl -fsSL "$BACKEND_URL/client.tar.gz" | tar -xz -C "$ASSISTANT_HOME/code" "$ASSISTANT_HOME/.venv/bin/pip" install --quiet -r "$ASSISTANT_HOME/code/requirements.txt" "$ASSISTANT_HOME/.venv/bin/pip" install --quiet --no-deps -r "$ASSISTANT_HOME/code/requirements-nodeps.txt" if [ "$RESET" -eq 1 ]; then rm -f "$ASSISTANT_HOME/state/config.json" fi if [ ! -f "$ASSISTANT_HOME/state/config.json" ]; then echo read -r -p "Pairing code: " CODE "$ASSISTANT_HOME/.venv/bin/python" -m client.pair --backend "$BACKEND_URL" --code "$CODE" fi mkdir -p "$HOME/.config/systemd/user" cat > "$HOME/.config/systemd/user/assistant.service" </dev/null || true systemctl --user daemon-reload systemctl --user enable --now assistant echo "Done. systemctl --user status assistant" """; } }