#!/usr/bin/env bash # Start a Selkies Wine node (idempotent) and open its stream in the browser. # Usage: launch-node.sh [wine1|wine2|wine-retro] [--check] # --check start + wait for the web UI but don't open a browser window set -euo pipefail NODE="${1:-wine1}" CDIR="$HOME/selkies-wine" cd "$CDIR" # Port: read WINE*_PORT from .env, falling back to the compose defaults. case "$NODE" in wine1) DEF_PORT=3101 ;; wine2) DEF_PORT=3102 ;; wine-retro) DEF_PORT=3109 ;; *) DEF_PORT=3101 ;; esac PORT_VAR="$(echo "$NODE" | tr '[:lower:]-' '[:upper:]_')_PORT" PORT="$(grep -m1 "^${PORT_VAR}=" .env 2>/dev/null | cut -d= -f2-)" PORT="${PORT:-$DEF_PORT}" docker compose up -d "$NODE" >/dev/null # Wait for the web UI to answer (cold starts take ~10s; auth returns 401, # which still means "ready"). for _ in $(seq 1 60); do if curl -sk -o /dev/null --max-time 2 "https://localhost:${PORT}/"; then break fi sleep 0.5 done if [[ "${2:-}" != "--check" ]]; then firefox "https://localhost:${PORT}/" fi echo "node=$NODE port=$PORT ready"