#!/usr/bin/env bash
# Install Pi-side system packages required by the test projects.
# Idempotent — safe to re-run. apt-get only installs what's missing.

set -euo pipefail

PI_USER="${PI_USER:-pi}"
PI_HOST="${PI_HOST:-192.168.50.115}"
PI_PASS="${PI_PASS:-assistant}"

sshpass -p "$PI_PASS" ssh -o StrictHostKeyChecking=accept-new \
  "$PI_USER@$PI_HOST" \
  "echo '$PI_PASS' | sudo -S -p '' apt-get update -qq && \
   echo '$PI_PASS' | sudo -S -p '' apt-get install -y --no-install-recommends libportaudio2 libsndfile1 python3-venv" \
  2>&1 | sed -E "s/${PI_PASS}/***/g"
