From 0e381196fe219469002d3988f25e8dd9f9b68f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Avic=20Simmons?= Date: Sun, 13 Sep 2026 17:51:59 -0400 Subject: [PATCH] fix(autorun): actually load default.env and honor RESULTS_DIR (FR-082) lib.sh documented loading config/default.env but never read it, so the baked-in tunables (STRESS_DURATION_SEC, MEMTESTER_PCT, RESULTS_DIR) were ignored. Source it from /run/sysrescue-config (falling back to /default.env), make RESULTS_DIR empty-by-default so autorun0's writable-partition logic applies, and have setup_results_dir honor an explicitly configured RESULTS_DIR with a /run/results fallback. --- autorun/autorun0 | 11 +++++++++-- autorun/lib.sh | 19 +++++++++++++++---- config/default.env | 5 +++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/autorun/autorun0 b/autorun/autorun0 index 3c7dd2b..9a96abe 100755 --- a/autorun/autorun0 +++ b/autorun/autorun0 @@ -43,7 +43,10 @@ find_results_partition() { setup_results_dir() { local part - if part="$(find_results_partition)"; then + if [[ -n "${RESULTS_DIR:-}" ]]; then + # Explicitly configured via config/default.env. + : + elif part="$(find_results_partition)"; then RESULTS_DIR="${part}/results" # Remount rw if we landed on a read-only mount mount -o remount,rw "$part" 2> /dev/null || true @@ -51,7 +54,11 @@ setup_results_dir() { log "WARN: no writable FAT32 partition found; results will live in tmpfs (/run/results) and will NOT survive reboot" RESULTS_DIR=/run/results fi - mkdir -p "$RESULTS_DIR" + if ! mkdir -p "$RESULTS_DIR" 2> /dev/null; then + log "WARN: could not create RESULTS_DIR=$RESULTS_DIR; falling back to /run/results" + RESULTS_DIR=/run/results + mkdir -p "$RESULTS_DIR" + fi export RESULTS_DIR } diff --git a/autorun/lib.sh b/autorun/lib.sh index dd2f589..2b44571 100644 --- a/autorun/lib.sh +++ b/autorun/lib.sh @@ -1,12 +1,23 @@ # Shared helpers for autorun test scripts. # Sourced by autorun0 and by each autorun/tests/*.sh. -# Default config — overridden by /run/sysrescue-config/default.env if present -# (build-rescue-usb.sh writes config/default.env to that location on the FAT32 -# partition). +# Load the baked-in tunables. build-rescue-usb.sh writes config/default.env +# onto the FAT32 partition, which SystemRescue mounts under +# /run/sysrescue-config. Anything set there overrides the defaults below. +for _cfg in /run/sysrescue-config/default.env /default.env; do + if [[ -r "$_cfg" ]]; then + # shellcheck disable=SC1090 + source "$_cfg" + break + fi +done +unset _cfg + : "${STRESS_DURATION_SEC:=7200}" : "${MEMTESTER_PCT:=95}" -: "${RESULTS_DIR:=/run/results}" +# Empty => autorun0 writes results to the writable FAT32 partition when one is +# found (survives reboot); set an absolute path to override. +: "${RESULTS_DIR:=}" section() { printf '\n=== %s ===\n' "$1" diff --git a/config/default.env b/config/default.env index b9bb437..5c46f43 100644 --- a/config/default.env +++ b/config/default.env @@ -9,5 +9,6 @@ STRESS_DURATION_SEC=7200 # Percent of MemAvailable to test with memtester (default: 95) MEMTESTER_PCT=95 -# Where on the FAT32 partition to drop results files -RESULTS_DIR=/run/results +# Where to write results files. Leave unset to write to the writable FAT32 +# partition (so results survive reboot); set an absolute path to override. +# RESULTS_DIR=/mnt/results