sidrefresh's picture
Add files using upload-large-folder tool
7ec48b5 verified
Raw History Blame Contribute Delete
2.47 kB
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f /opt/rct2-assets/Data/g1.dat && ! -f /opt/rct2-assets/Data/G1.DAT ]]; then
echo "Mount a complete Steam RCT2 installation at /opt/rct2-assets." >&2
exit 1
fi
mkdir -p "$HOME/.config/OpenRCT2/plugin"
if [[ ! -f "$HOME/.config/OpenRCT2/config.ini" ]]; then
# USD keeps the on-screen land price reading exactly $90.
# allow_early_completion is set for consistency with the rest of the suite;
# this objective has no deadline to complete early against.
# Autosave is the shortest interval the engine offers (1 = every five
# minutes); the controller also saves the moment the run settles, which is
# the save the grader actually reads.
cat > "$HOME/.config/OpenRCT2/config.ini" <<'EOF'
[general]
autosave = 1
autosave_amount = 30
window_width = 1280
window_height = 800
fullscreen_mode = 2
play_intro = false
drawing_engine = SOFTWARE_HWD
use_vsync = false
multithreading = false
allow_early_completion = true
currency_format = USD
confirmation_prompt = false
save_plugin_data = true
[sound]
master_sound = false
EOF
fi
openrct2 set-rct2 /opt/rct2-assets
export T39_AUDIT_DIR=/logs/artifacts/audit
mkdir -p "$T39_AUDIT_DIR"
pids=()
cleanup() {
trap - EXIT INT TERM
python3 /usr/local/lib/t39/collect.py --screenshot || true
kill "${pids[@]}" 2>/dev/null || true
wait || true
}
trap cleanup EXIT
trap 'exit 0' INT TERM
Xvfb "$DISPLAY" -screen 0 1280x800x24 -nolisten tcp &
pids+=("$!")
ready=false
for ((attempt=0; attempt<100; attempt++)); do
if xdpyinfo >/dev/null 2>&1; then ready=true; break; fi
sleep 0.1
done
"$ready" || { echo "Virtual display failed to start." >&2; exit 1; }
openbox &
pids+=("$!")
x11vnc -display "$DISPLAY" -localhost -rfbport 5900 -forever -shared -nopw -quiet &
pids+=("$!")
websockify --web=/usr/share/novnc 6080 localhost:5900 &
pids+=("$!")
# The supervisor owns the engine: it installs the trusted plugin and plays the
# one run this task allows. Nothing else may start a scenario.
python3 /usr/local/lib/t39/run-supervisor.py "$@" &
pids+=("$!")
# Host-mounted checkpoints survive container removal. Screenshots and saves are
# collected every two minutes, within the suite's two/five-minute limits.
(
while true; do
sleep 120
python3 /usr/local/lib/t39/collect.py --screenshot || true
done
) &
pids+=("$!")
# Closing the game, or failure of a desktop service, stops this container.
wait -n "${pids[@]}"