#!/usr/bin/env bash # Attach to an ALREADY-RUNNING mission. launch_mission.sh leaves the emulator # running and it survives between Bash calls within a turn, so observation is no # longer capped by one call's timeout -- chain attaches to extend the window. set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 export PYTHONPATH=/sylph-home/.local/lib/python3.12/site-packages SD="$(cd "$(dirname "$0")" && pwd)" SECS="${1:-540}"; EVERY="${2:-15}" CFG=/tmp/nav-attach.json pgrep -x xenia_canary >/dev/null || { echo "NO EMULATOR RUNNING"; exit 1; } PILOT="" for try in 1 2 3; do python3 "$SD/pad.py" set "rt=1" >/dev/null 2>&1 || true sleep 3 python3 "$SD/pad.py" clear >/dev/null 2>&1 || true if python3 "$SD/entities2.py" self 0x130 "$CFG" >/dev/null 2>&1; then SYLPH_HUNT=1 SYLPH_KILL_TURRETS=1 SYLPH_KEEPOUT=1400 \ nohup python3 "$SD/pilot.py" "$CFG" "$SECS" /tmp/attach-pilot.log 2>&1 & PILOT=$!; echo "--- pilot re-attached"; break fi echo "--- bind attempt $try failed" done [ -z "$PILOT" ] && echo "--- no pilot; observing unattended (still valid for the clock model)" python3 "$SD/wave7_probe.py" "$SECS" "$EVERY"; rc=$? [ -n "$PILOT" ] && kill "$PILOT" 2>/dev/null echo "ATTACH DONE rc=$rc"