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