upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/linux-boot
diff options
context:
space:
mode:
authorMoonEyes <ducoinbenjamin@yahoo.fr>2026-11-28 20:41:01 +0100
committerGitHub <noreply@github.com>2026-11-28 20:41:01 +0100
commit4ad9afefd64af337b4fc9a9c31455df7ae74ff3a (patch)
tree16a0102ccdc5c801066c0c339bf568825b43b92a /scripts/linux-boot
parentdf3e8a85e0a998e5fc038d4ff71363ec76de88d0 (diff)
parent9f86f4b46b71320abc042ae8d0825a6684e901df (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-xscripts/linux-boot/boot.sh77
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.
5set -u 5set -u
6MODE=${1:?dry-run|init|run}; SECS=${2:-150} 6usage() {
7OUT=/opt/leonida 7 echo "usage: boot.sh dry-run|init|run [seconds]"
8}
9
10if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
11 usage
12 exit 0
13fi
14if [ $# -lt 1 ] || [ $# -gt 2 ]; then
15 usage >&2
16 exit 2
17fi
18
19MODE=$1
20SECS=${2:-150}
21case "$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 ;;
27esac
28if ! [[ "$SECS" =~ ^[1-9][0-9]*$ ]]; then
29 echo "boot.sh: invalid seconds: $SECS (expected positive integer)" >&2
30 exit 2
31fi
32
33OUT=${LEONIDA_OUT:-/opt/leonida}
8REPO=${LEONIDA_REPO:-$(cd "$(dirname "$(readlink -f "$0")")/../.." && pwd)} # the checkout this script is in 34REPO=${LEONIDA_REPO:-$(cd "$(dirname "$(readlink -f "$0")")/../.." && pwd)} # the checkout this script is in
35WINE=${WINE:-wine} # e.g. WINE=".../Proton - Experimental/files/bin/wine" WINEPREFIX=~/.local/share/leonida-proton/pfx
36PYTHON3=${PYTHON3:-python3}
37UNSHARE=${UNSHARE:-unshare}
38TIMEOUT=${TIMEOUT:-timeout}
39GAME_DIR=${LEONIDA_GAME_DIR:-/opt/gta6/GTA6.Xbox.v1.0.2.1}
40GAME_WIN=${LEONIDA_GAME_WIN:-'Z:\opt\gta6\GTA6.Xbox.v1.0.2.1'}
41EXE=${LEONIDA_EXE:-$GAME_DIR/game_scarlett_master.exe}
42OVERLAY_WIN=${LEONIDA_OVERLAY_WIN:-'Z:\opt\leonida\overlay'}
43GTA6RT=${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
45if [ ! -f "$GTA6RT" ]; then
46 echo "boot.sh: missing gta6rt executable: $GTA6RT" >&2
47 exit 2
48fi
49if ! command -v "$UNSHARE" >/dev/null 2>&1; then
50 echo "boot.sh: missing required command: $UNSHARE" >&2
51 exit 2
52fi
53if [ "$MODE" = run ] && ! command -v "$TIMEOUT" >/dev/null 2>&1; then
54 echo "boot.sh: missing required command: $TIMEOUT" >&2
55 exit 2
56fi
57if ! command -v "$WINE" >/dev/null 2>&1; then
58 echo "boot.sh: missing required Wine binary: $WINE" >&2
59 exit 2
60fi
61
9STAMP=$(date +%H%M%S) 62STAMP=$(date +%H%M%S)
10T=$OUT/traces; mkdir -p "$T" "$OUT/overlay" "$OUT/cache/nv" 63T=$OUT/traces; mkdir -p "$T" "$OUT/overlay" "$OUT/cache/nv"
11 64
12WINE=${WINE:-wine} # e.g. WINE=".../Proton - Experimental/files/bin/wine" WINEPREFIX=~/.local/share/leonida-proton/pfx
13export WINEPREFIX=${WINEPREFIX:-$HOME/.local/share/leonida-wine} WINEDEBUG=${WINEDEBUG:--all} WINEDLLOVERRIDES="mscoree,mshtml=" 65export WINEPREFIX=${WINEPREFIX:-$HOME/.local/share/leonida-wine} WINEDEBUG=${WINEDEBUG:--all} WINEDLLOVERRIDES="mscoree,mshtml="
14export LEONIDA_D3D12=vulkan 66export LEONIDA_D3D12=vulkan
15export LEONIDA_SHADERS=$OUT/work/shaders/spirv 67export 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
20export __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 72export __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
23GAME_WIN='Z:\opt\gta6\GTA6.Xbox.v1.0.2.1' 75TRACE_WIN=${LEONIDA_TRACE_WIN:-"Z:\\opt\\leonida\\traces\\boot-$MODE-$STAMP.jsonl"}
24EXE=/opt/gta6/GTA6.Xbox.v1.0.2.1/game_scarlett_master.exe
25TRACE_WIN="Z:\\opt\\leonida\\traces\\boot-$MODE-$STAMP.jsonl"
26D3D=$T/d3d12-$MODE-$STAMP.log 76D3D=$T/d3d12-$MODE-$STAMP.log
27GTA6RT=${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
29args=(--"$MODE" "$EXE" --game-dir "$GAME_WIN" --overlay 'Z:\opt\leonida\overlay' --trace "$TRACE_WIN") 78args=(--"$MODE" "$EXE" --game-dir "$GAME_WIN" --overlay "$OVERLAY_WIN" --trace "$TRACE_WIN")
30[ "$MODE" = run ] && args+=(--trace-d3d12) 79[ "$MODE" = run ] && args+=(--trace-d3d12)
31echo "[boot] $MODE gta6rt=$GTA6RT trace=$T/boot-$MODE-$STAMP.jsonl d3d12=$D3D" 80echo "[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
33if [ "$MODE" = run ]; then 82if [ "$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"
35else 84else
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"
37fi 86fi
38rc=$?; echo "[boot] exit=$rc" 87rc=$?; echo "[boot] exit=$rc"
39sleep 0 88sleep 0
40python3 -I "$REPO/tools/boot_trace.py" "$T/boot-$MODE-$STAMP.jsonl" --d3d12 "$D3D" > "$T/summary-$MODE-$STAMP.txt" 2>&1 89if [ -f "$REPO/tools/boot_trace.py" ]; then
41echo "[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
42exit $rc 91 echo "[boot] summary: $T/summary-$MODE-$STAMP.txt"
92fi
93exit "$rc"