#!/bin/bash # Everything that does NOT need root. Run as susan, before deploy.sh. # # /opt/ytstream/deploy/bootstrap.sh set -euo pipefail STATE=/var/lib/ytstream VENV=$STATE/venv REPO=/opt/ytstream say() { printf '\n\033[1m==> %s\033[0m\n' "$1"; } if [[ ! -d $STATE ]]; then echo "$STATE does not exist yet — run 'sudo $REPO/deploy/deploy.sh' first," >&2 echo "or create it with: sudo install -d -o susan -g automation -m 0770 $STATE" >&2 exit 1 fi say "Creating the virtualenv" python3 -m venv "$VENV" "$VENV/bin/pip" install --quiet --upgrade pip "$VENV/bin/pip" install --quiet -e "$REPO" say "Verifying yt-dlp and the POT plugin" # The plugin is what makes YouTube reachable at all. A venv without it looks fine # until the first playback fails with a bare 403. "$VENV/bin/yt-dlp" --version "$VENV/bin/python3" - <<'PY' import importlib.util missing = [name for name in ("yt_dlp_plugins",) if importlib.util.find_spec(name) is None] print("POT plugin:", "MISSING" if missing else "present") raise SystemExit(1 if missing else 0) PY say "Starting the POT provider container if it is not already up" if ! curl -sf --max-time 5 http://127.0.0.1:4416/ping >/dev/null 2>&1; then docker run -d --name bgutil-provider --restart unless-stopped \ -p 4416:4416 brainicism/bgutil-ytdlp-pot-provider || true else echo " already responding on 127.0.0.1:4416" fi say "Initialising the database" "$VENV/bin/ytstream" status || true say "Done — now run 'sudo $REPO/deploy/deploy.sh'"