#!/usr/bin/env bash set -euo pipefail if [ -z "${DISPLAY:-}" ]; then echo "[entrypoint] starting Xvfb on :99" Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp & export DISPLAY=:99 for i in $(seq 1 20); do [ -e /tmp/.X11-unix/X99 ] && break sleep 0.25 done fi if [ -n "${CHANNEL_ID:-}" ]; then mkdir -p "/media/live/${CHANNEL_ID}" fi mkdir -p /media/casparcg/log /media/casparcg/data /media/templates cd /opt/casparcg CASPAR_CFG=/opt/casparcg/casparcg.config if [ -x "./casparcg" ]; then CASPAR_BIN="./casparcg"; elif [ -x "./CasparCG Server" ]; then CASPAR_BIN="./CasparCG Server"; elif command -v casparcg >/dev/null; then CASPAR_BIN="casparcg"; else echo "[entrypoint] ERROR: casparcg binary not found"; exit 1; fi echo "[entrypoint] launching CasparCG: $CASPAR_BIN $CASPAR_CFG" "$CASPAR_BIN" "$CASPAR_CFG" & CASPAR_PID=$! term() { echo "[entrypoint] terminating CasparCG ($CASPAR_PID)" kill -TERM "$CASPAR_PID" 2>/dev/null || true wait "$CASPAR_PID" 2>/dev/null || true exit 0 } trap term SIGTERM SIGINT cd /app node src/index.js & NODE_PID=$! wait -n "$CASPAR_PID" "$NODE_PID" term