#!/usr/bin/env bash set -euo pipefail RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' info() { echo -e "${GREEN}[BashyOverlay]${NC} $1"; } warn() { echo -e "${YELLOW}[BashyOverlay]${NC} $1"; } error() { echo -e "${RED}[BashyOverlay]${NC} $1"; exit 1; } # ── Python version check ────────────────────────────────────────────────────── PYTHON=$(command -v python3 || command -v python || error "Python not found") PY_VER=$($PYTHON -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') PY_MAJOR=$($PYTHON -c 'import sys; print(sys.version_info.major)') PY_MINOR=$($PYTHON -c 'import sys; print(sys.version_info.minor)') if [ "$PY_MAJOR" -lt 3 ] || { [ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -lt 10 ]; }; then error "Python 3.10+ required (found $PY_VER)" fi info "Python $PY_VER OK" # ── Virtual environment ─────────────────────────────────────────────────────── if [ ! -d ".venv" ]; then info "Creating virtual environment..." $PYTHON -m venv .venv fi source .venv/bin/activate info "Virtual environment active" # ── Dependencies ────────────────────────────────────────────────────────────── info "Installing dependencies..." pip install -q --upgrade pip pip install -q -r requirements.txt info "Dependencies installed" # ── .env ────────────────────────────────────────────────────────────────────── if [ ! -f ".env" ]; then cp .env.example .env warn ".env created from .env.example" warn "Edit .env with your Twitch credentials before continuing." warn "" warn " TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET:" warn " Register an app at https://dev.twitch.tv/console/apps" warn " Set OAuth Redirect URL to: http://localhost:8000/auth/callback" warn "" echo -n "Have you filled in .env? [y/N] " read -r answer if [[ ! "$answer" =~ ^[Yy]$ ]]; then warn "Edit .env and run deploy.sh again." exit 0 fi fi # ── Media directory ─────────────────────────────────────────────────────────── mkdir -p static/media info "Media directory ready" # ── Launch ──────────────────────────────────────────────────────────────────── HOST="${HOST:-0.0.0.0}" PORT="${PORT:-8000}" info "Starting BashyOverlay at http://localhost:${PORT}" info "Open that URL in your browser to log in with Twitch." info "OBS browser source URL: http://localhost:${PORT}/overlay" info "" info "Press Ctrl+C to stop." echo "" exec uvicorn app.main:app --host "$HOST" --port "$PORT" --reload