From de8e31193bdde9b89e2a9d992fb4f8ec25662fe3 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 16 Jan 2023 07:54:03 +0100 Subject: [PATCH] make_mirror.sh: output log and exit status to two individual files --- make_mirror.sh | 4 ++-- run_null.sh | 4 ++-- run_qemu.sh | 12 ++++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/make_mirror.sh b/make_mirror.sh index ed0a79b..1d634d6 100755 --- a/make_mirror.sh +++ b/make_mirror.sh @@ -594,12 +594,12 @@ handler () { } 2>&1; } | { read xs; exit $xs; }; } 3>&1 || ret=$? + echo $ret > /mnt/exitstatus.txt if [ -e cover_db.img ]; then df -h cover_db umount cover_db fi - echo $ret -) > /mnt/result.txt 2>&1 +) > /mnt/output.txt 2>&1 umount /mnt systemctl poweroff END diff --git a/run_null.sh b/run_null.sh index 3e3b632..e034962 100755 --- a/run_null.sh +++ b/run_null.sh @@ -23,8 +23,8 @@ done cd ./shared; $SUDO sh -x ./test.sh; echo $?; -) 2>&1 | tee shared/result.txt | head --lines=-1 -if [ "$(tail --lines=1 shared/result.txt)" -ne 0 ]; then +) 2>&1 | tee shared/output.txt +if [ "$(cat shared/exitstatus.txt)" -ne 0 ]; then echo "test.sh failed" exit 1 fi diff --git a/run_qemu.sh b/run_qemu.sh index b95e0dd..d80ba12 100755 --- a/run_qemu.sh +++ b/run_qemu.sh @@ -11,10 +11,8 @@ cleanup() { rm -f "$tmpdir/debian-$DEFAULT_DIST-overlay.qcow" rm -f "$tmpdir/log" [ -e "$tmpdir" ] && rmdir "$tmpdir" - if [ -e shared/result.txt ]; then - head --lines=-1 shared/result.txt - res="$(tail --lines=1 shared/result.txt)" - rm shared/result.txt + if [ -e shared/output.txt ]; then + res="$(cat shared/exitstatus.txt)" if [ "$res" != "0" ]; then # this might possibly overwrite another non-zero rv rv=1 @@ -45,6 +43,12 @@ case $ARCH in *) echo "qemu kvm not supported on $ARCH" >&2;; esac +echo 1 > shared/exitstatus.txt +if [ -e shared/output.txt ]; then + rm shared/output.txt +fi +touch shared/output.txt + # the path to debian-$DEFAULT_DIST.qcow must be absolute or otherwise qemu will # look for the path relative to debian-$DEFAULT_DIST-overlay.qcow qemu-img create -f qcow2 -b "$(realpath "$cachedir")/debian-$DEFAULT_DIST.qcow" -F qcow2 "$tmpdir/debian-$DEFAULT_DIST-overlay.qcow"