#!/usr/bin/env bash # Role guard for split deployments. # # run-if-role.sh # # Runs only when JARVIS_ROLE is one of (or "full"/unset). # Otherwise it idles so supervisord keeps the program slot "running" without # doing any work. This lets ONE image serve three layouts: # # JARVIS_ROLE=full (default) everything in one container # JARVIS_ROLE=browser only the desktop + Chrome + CDP (reused over the LAN) # JARVIS_ROLE=bot only the bot + bridge + TTS (drives a remote browser # via CDP_HOST/CDP_PORT) # JARVIS_ROLE=brain only the bridge (STT + reply + TTS) on a GPU host; no # bot, no desktop. The app host reaches it via BRIDGE_URL. # JARVIS_ROLE=app the bot + desktop/Chrome, but NOT the local bridge: # offloads STT/LLM/TTS to a remote brain host (BRIDGE_URL) set -e want="$1"; shift role="${JARVIS_ROLE:-full}" if [ "$role" = "full" ]; then exec "$@"; fi case ",$want," in *",$role,"*) exec "$@" ;; esac echo "[role-guard] JARVIS_ROLE=$role not in '$want' — idling: $*" >&2 exec sleep infinity