From ff5f7166f6c818d6615a651a3ac3548ad76e7723 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 7 Apr 2025 20:09:49 +0200 Subject: [PATCH] Fix. --- testing/home/desktop/.local/bin/borgplom | 2 +- testing/scripts/_setup_secrets_user.sh | 2 +- testing/scripts/lib/mount_secrets | 2 +- testing/scripts/lib/retry_until | 12 +++++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index 962bbed..7e25658 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -37,7 +37,7 @@ _run_borg_with_passphrase() { echo "" fi ' - _TO_TEST='"$(borg '"$@"')"' + _TO_TEST='borg '"$@" _ON_FAIL='echo "unexpected borg error, code ${_RESULT}."' _ON_LOOP_END='export BORG_PASSPHRASE=' retry_until 52 "${_PREPARE}" "${_TO_TEST}" "${_ON_FAIL}" "${_ON_LOOP_END}" diff --git a/testing/scripts/_setup_secrets_user.sh b/testing/scripts/_setup_secrets_user.sh index 1035f92..a485ca0 100644 --- a/testing/scripts/_setup_secrets_user.sh +++ b/testing/scripts/_setup_secrets_user.sh @@ -50,5 +50,5 @@ ls -1 | while read _FILENAME; do "${NAME_BORGAPP}" claim "${_FILENAME}" done cd - -retry_until 2 '' "${NAME_BORGAPP} orgpull" "echo 'Aborting due to unexpected ${NAME_BORGAPP} error.'" +retry_until 2 '' "${NAME_BORGAPP} orgpull" "echo 'Aborting due to unexpected ${NAME_BORGAPP} error.'" '' 'direct' echo "${_OUTPUT}" diff --git a/testing/scripts/lib/mount_secrets b/testing/scripts/lib/mount_secrets index 53b30d9..d262c52 100644 --- a/testing/scripts/lib/mount_secrets +++ b/testing/scripts/lib/mount_secrets @@ -20,7 +20,7 @@ mount_secrets() { _PREPARE='printf "Passphrase: "; PASSPHRASE=$(get_passphrase); echo ""' _TO_TEST='echo "${PASSPHRASE}" | pmount "${PATH_DEV}" 2>&1' _ON_FAIL='echo "Aborting due to pmount error:' - retry_until 100 ${_PREPARE}" "${_TO_TEST}" "${_ON_FAIL}" + retry_until 100 "${_PREPARE}" "${_TO_TEST}" "${_ON_FAIL}" echo "${_OUTPUT}" } diff --git a/testing/scripts/lib/retry_until b/testing/scripts/lib/retry_until index 2d0297d..5179ba1 100644 --- a/testing/scripts/lib/retry_until +++ b/testing/scripts/lib/retry_until @@ -4,15 +4,21 @@ retry_until() { _TO_TEST="$3" _ON_FAIL="$4" _ON_LOOP_END="$5" + _OUTPUT_MODE="$6" while true; do eval "${_ON_LOOP_START}" set +e - _OUTPUT="$(eval ${_TO_TEST})" - _RESULT=$? + if [ "${_OUTPUT_MODE}" = 'direct' ]; then + eval ${_TO_TEST} + _RESULT=$? + else + _OUTPUT="$(eval ${_TO_TEST})" + _RESULT=$? + fi set -e if [ "${_RESULT}" = '0' ]; then break - elif [ "${RESULT}" != "${_CODE_FOR_CONTINUE}" ]; then + elif [ "${_RESULT}" != "${_CODE_FOR_CONTINUE}" ]; then eval "${_ON_FAIL}" abort fi -- 2.30.2