diff options
| author | MoonEyes <ducoinbenjamin@yahoo.fr> | 2026-11-28 20:41:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-28 20:41:01 +0100 |
| commit | 4ad9afefd64af337b4fc9a9c31455df7ae74ff3a (patch) | |
| tree | 16a0102ccdc5c801066c0c339bf568825b43b92a /scripts/linux-boot | |
| parent | df3e8a85e0a998e5fc038d4ff71363ec76de88d0 (diff) | |
| parent | 9f86f4b46b71320abc042ae8d0825a6684e901df (diff) | |
Merge pull request #2298 from kirigayakazima/fix/linux-boot-sh-safety
scripts/linux-boot/boot.sh: validate mode, timeout, and prerequisites upfront
Diffstat (limited to 'scripts/linux-boot')
| -rwxr-xr-x | scripts/linux-boot/boot.sh | 77 |
1 files changed, 64 insertions, 13 deletions
diff --git a/scripts/linux-boot/boot.sh b/scripts/linux-boot/boot.sh index 55f84f019..6a2268f27 100755 --- a/scripts/linux-boot/boot.sh +++ b/scripts/linux-boot/boot.sh | |||
| @@ -3,13 +3,65 @@ | |||
| 3 | # usage: boot.sh dry-run|init|run [seconds] (run defaults to 150 s, then the title is stopped) | 3 | # usage: boot.sh dry-run|init|run [seconds] (run defaults to 150 s, then the title is stopped) |
| 4 | # Traces stay local in /opt/leonida/traces: they can quote game data, never post them. | 4 | # Traces stay local in /opt/leonida/traces: they can quote game data, never post them. |
| 5 | set -u | 5 | set -u |
| 6 | MODE=${1:?dry-run|init|run}; SECS=${2:-150} | 6 | usage() { |
| 7 | OUT=/opt/leonida | 7 | echo "usage: boot.sh dry-run|init|run [seconds]" |
| 8 | } | ||
| 9 | |||
| 10 | if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then | ||
| 11 | usage | ||
| 12 | exit 0 | ||
| 13 | fi | ||
| 14 | if [ $# -lt 1 ] || [ $# -gt 2 ]; then | ||
| 15 | usage >&2 | ||
| 16 | exit 2 | ||
| 17 | fi | ||
| 18 | |||
| 19 | MODE=$1 | ||
| 20 | SECS=${2:-150} | ||
| 21 | case "$MODE" in | ||
| 22 | dry-run|init|run) ;; | ||
| 23 | *) | ||
| 24 | echo "boot.sh: invalid mode: $MODE (expected dry-run, init, or run)" >&2 | ||
| 25 | exit 2 | ||
| 26 | ;; | ||
| 27 | esac | ||
| 28 | if ! [[ "$SECS" =~ ^[1-9][0-9]*$ ]]; then | ||
| 29 | echo "boot.sh: invalid seconds: $SECS (expected positive integer)" >&2 | ||
| 30 | exit 2 | ||
| 31 | fi | ||
| 32 | |||
| 33 | OUT=${LEONIDA_OUT:-/opt/leonida} | ||
| 8 | REPO=${LEONIDA_REPO:-$(cd "$(dirname "$(readlink -f "$0")")/../.." && pwd)} # the checkout this script is in | 34 | REPO=${LEONIDA_REPO:-$(cd "$(dirname "$(readlink -f "$0")")/../.." && pwd)} # the checkout this script is in |
| 35 | WINE=${WINE:-wine} # e.g. WINE=".../Proton - Experimental/files/bin/wine" WINEPREFIX=~/.local/share/leonida-proton/pfx | ||
| 36 | PYTHON3=${PYTHON3:-python3} | ||
| 37 | UNSHARE=${UNSHARE:-unshare} | ||
| 38 | TIMEOUT=${TIMEOUT:-timeout} | ||
| 39 | GAME_DIR=${LEONIDA_GAME_DIR:-/opt/gta6/GTA6.Xbox.v1.0.2.1} | ||
| 40 | GAME_WIN=${LEONIDA_GAME_WIN:-'Z:\opt\gta6\GTA6.Xbox.v1.0.2.1'} | ||
| 41 | EXE=${LEONIDA_EXE:-$GAME_DIR/game_scarlett_master.exe} | ||
| 42 | OVERLAY_WIN=${LEONIDA_OVERLAY_WIN:-'Z:\opt\leonida\overlay'} | ||
| 43 | GTA6RT=${GTA6RT:-$OUT/gta6rt.exe}; [ -f "$GTA6RT" ] || GTA6RT=$REPO/runtime/build/boot/gta6rt.exe # GTA6RT=<your build>/gta6rt.exe boots a private build without installing it | ||
| 44 | |||
| 45 | if [ ! -f "$GTA6RT" ]; then | ||
| 46 | echo "boot.sh: missing gta6rt executable: $GTA6RT" >&2 | ||
| 47 | exit 2 | ||
| 48 | fi | ||
| 49 | if ! command -v "$UNSHARE" >/dev/null 2>&1; then | ||
| 50 | echo "boot.sh: missing required command: $UNSHARE" >&2 | ||
| 51 | exit 2 | ||
| 52 | fi | ||
| 53 | if [ "$MODE" = run ] && ! command -v "$TIMEOUT" >/dev/null 2>&1; then | ||
| 54 | echo "boot.sh: missing required command: $TIMEOUT" >&2 | ||
| 55 | exit 2 | ||
| 56 | fi | ||
| 57 | if ! command -v "$WINE" >/dev/null 2>&1; then | ||
| 58 | echo "boot.sh: missing required Wine binary: $WINE" >&2 | ||
| 59 | exit 2 | ||
| 60 | fi | ||
| 61 | |||
| 9 | STAMP=$(date +%H%M%S) | 62 | STAMP=$(date +%H%M%S) |
| 10 | T=$OUT/traces; mkdir -p "$T" "$OUT/overlay" "$OUT/cache/nv" | 63 | T=$OUT/traces; mkdir -p "$T" "$OUT/overlay" "$OUT/cache/nv" |
| 11 | 64 | ||
| 12 | WINE=${WINE:-wine} # e.g. WINE=".../Proton - Experimental/files/bin/wine" WINEPREFIX=~/.local/share/leonida-proton/pfx | ||
| 13 | export WINEPREFIX=${WINEPREFIX:-$HOME/.local/share/leonida-wine} WINEDEBUG=${WINEDEBUG:--all} WINEDLLOVERRIDES="mscoree,mshtml=" | 65 | export WINEPREFIX=${WINEPREFIX:-$HOME/.local/share/leonida-wine} WINEDEBUG=${WINEDEBUG:--all} WINEDLLOVERRIDES="mscoree,mshtml=" |
| 14 | export LEONIDA_D3D12=vulkan | 66 | export LEONIDA_D3D12=vulkan |
| 15 | export LEONIDA_SHADERS=$OUT/work/shaders/spirv | 67 | export LEONIDA_SHADERS=$OUT/work/shaders/spirv |
| @@ -20,23 +72,22 @@ export __GL_SHADER_DISK_CACHE=1 __GL_SHADER_DISK_CACHE_PATH=$OUT/cache/nv __GL_S | |||
| 20 | export __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 | 72 | export __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 |
| 21 | [ -n "${SKIP_INT3:-}" ] && export LEONIDA_SKIP_INT3=1 | 73 | [ -n "${SKIP_INT3:-}" ] && export LEONIDA_SKIP_INT3=1 |
| 22 | 74 | ||
| 23 | GAME_WIN='Z:\opt\gta6\GTA6.Xbox.v1.0.2.1' | 75 | TRACE_WIN=${LEONIDA_TRACE_WIN:-"Z:\\opt\\leonida\\traces\\boot-$MODE-$STAMP.jsonl"} |
| 24 | EXE=/opt/gta6/GTA6.Xbox.v1.0.2.1/game_scarlett_master.exe | ||
| 25 | TRACE_WIN="Z:\\opt\\leonida\\traces\\boot-$MODE-$STAMP.jsonl" | ||
| 26 | D3D=$T/d3d12-$MODE-$STAMP.log | 76 | D3D=$T/d3d12-$MODE-$STAMP.log |
| 27 | GTA6RT=${GTA6RT:-$OUT/gta6rt.exe}; [ -f "$GTA6RT" ] || GTA6RT=$REPO/runtime/build/boot/gta6rt.exe # GTA6RT=<your build>/gta6rt.exe boots a private build without installing it | ||
| 28 | 77 | ||
| 29 | args=(--"$MODE" "$EXE" --game-dir "$GAME_WIN" --overlay 'Z:\opt\leonida\overlay' --trace "$TRACE_WIN") | 78 | args=(--"$MODE" "$EXE" --game-dir "$GAME_WIN" --overlay "$OVERLAY_WIN" --trace "$TRACE_WIN") |
| 30 | [ "$MODE" = run ] && args+=(--trace-d3d12) | 79 | [ "$MODE" = run ] && args+=(--trace-d3d12) |
| 31 | echo "[boot] $MODE gta6rt=$GTA6RT trace=$T/boot-$MODE-$STAMP.jsonl d3d12=$D3D" | 80 | echo "[boot] $MODE gta6rt=$GTA6RT trace=$T/boot-$MODE-$STAMP.jsonl d3d12=$D3D" |
| 32 | # unshare: new user + network namespace, so the title has no network at all | 81 | # unshare: new user + network namespace, so the title has no network at all |
| 33 | if [ "$MODE" = run ]; then | 82 | if [ "$MODE" = run ]; then |
| 34 | timeout --signal=INT --kill-after=20 "$SECS" unshare -rn "$WINE" "$GTA6RT" "${args[@]}" > "$T/stdout-$MODE-$STAMP.log" 2> "$D3D" | 83 | "$TIMEOUT" --signal=INT --kill-after=20 "$SECS" "$UNSHARE" -rn "$WINE" "$GTA6RT" "${args[@]}" > "$T/stdout-$MODE-$STAMP.log" 2> "$D3D" |
| 35 | else | 84 | else |
| 36 | unshare -rn "$WINE" "$GTA6RT" "${args[@]}" > "$T/stdout-$MODE-$STAMP.log" 2> "$D3D" | 85 | "$UNSHARE" -rn "$WINE" "$GTA6RT" "${args[@]}" > "$T/stdout-$MODE-$STAMP.log" 2> "$D3D" |
| 37 | fi | 86 | fi |
| 38 | rc=$?; echo "[boot] exit=$rc" | 87 | rc=$?; echo "[boot] exit=$rc" |
| 39 | sleep 0 | 88 | sleep 0 |
| 40 | python3 -I "$REPO/tools/boot_trace.py" "$T/boot-$MODE-$STAMP.jsonl" --d3d12 "$D3D" > "$T/summary-$MODE-$STAMP.txt" 2>&1 | 89 | if [ -f "$REPO/tools/boot_trace.py" ]; then |
| 41 | echo "[boot] summary: $T/summary-$MODE-$STAMP.txt" | 90 | "$PYTHON3" -I "$REPO/tools/boot_trace.py" "$T/boot-$MODE-$STAMP.jsonl" --d3d12 "$D3D" > "$T/summary-$MODE-$STAMP.txt" 2>&1 || true |
| 42 | exit $rc | 91 | echo "[boot] summary: $T/summary-$MODE-$STAMP.txt" |
| 92 | fi | ||
| 93 | exit "$rc" | ||