From 202cb69a25823a4ce60d0dd83f597ddfc5a848bd Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 6 May 2025 08:52:13 +0200 Subject: [PATCH] Fix. --- testing/scripts/_setup_secrets_user.sh | 6 +++--- testing/scripts/lib/mount_secrets | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/testing/scripts/_setup_secrets_user.sh b/testing/scripts/_setup_secrets_user.sh index 4662298..a2556b9 100644 --- a/testing/scripts/_setup_secrets_user.sh +++ b/testing/scripts/_setup_secrets_user.sh @@ -34,7 +34,7 @@ cp -a "${PATH_SECRETS_SSH}" "${PATH_USER_SSH}" eval $(ssh-agent) stty -echo trapp stty echo -retry_until 1 'echo ""' 'ssh-add -q' 'echo "Aborting due to ssh-add error"' +retry_until 1 'echo ""' 'ssh-add -q' 'prefixed_msg "Aborting due to ssh-add error"' stty echo trapp @@ -53,7 +53,7 @@ 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.'" '' 'direct' -echo "${_OUTPUT}" +retry_until 2 '' "${NAME_BORGAPP} orgpull" "prefixed_msg 'Aborting due to unexpected ${NAME_BORGAPP} error.'" '' 'direct' +prefixed_msg "${_OUTPUT}" prefixed_msg_exit diff --git a/testing/scripts/lib/mount_secrets b/testing/scripts/lib/mount_secrets index 4807cd0..8e44c4a 100644 --- a/testing/scripts/lib/mount_secrets +++ b/testing/scripts/lib/mount_secrets @@ -2,9 +2,11 @@ . lib/expect_n_args . lib/get_passphrase . lib/path_tmp_timestamped +. lib/prefixed_msg . lib/retry_until mount_secrets() { + prefixed_msg_init mount_secrets expect_n_args 1 1 "(device name, e.g. 'sda')" $@ SECRETS_DEV=$1 if [ -z "${SECRETS_DEV}" ]; then @@ -13,26 +15,29 @@ mount_secrets() { PATH_MOUNTED_SECRETS="${PATH_MEDIA}/${SECRETS_DEV}/${PATH_REL_SECRETS}" PATH_DEV="/dev/${SECRETS_DEV}" PATH_PMOUNT_ERR="$(path_tmp_timestamped 'err_mount')" - echo "Put secrets drive into slot for ${PATH_DEV}." + prefixed_msg "Put secrets drive into slot for ${PATH_DEV}." while [ ! -e "${PATH_DEV}" ]; do sleep 0.1 done - _ON_LOOP_START='printf "Passphrase: "; PASSPHRASE=$(get_passphrase); echo ""' + _ON_LOOP_START='prefixed_msg_no_nl "Passphrase: "; PASSPHRASE=$(get_passphrase); echo ""' _TO_TEST='echo "${PASSPHRASE}" | pmount "${PATH_DEV}" 2>&1' - _ON_FAIL='echo "Aborting due to pmount error:"' + _ON_FAIL='prefixed_msg "Aborting due to pmount error:"' retry_until 100 "${_ON_LOOP_START}" "${_TO_TEST}" "${_ON_FAIL}" - echo "${_OUTPUT}" + prefixed_msg "${_OUTPUT}" + prefixed_msg_exit } copy_and_unmount_secrets() { - echo "Copying over ${PATH_REL_SECRETS}." + prefixed_msg_init copy_and_unmount_secrets + prefixed_msg "Copying over ${PATH_REL_SECRETS}." if [ "$1" = "out" ]; then cp -a "${PATH_SECRETS}" "${PATH_MOUNTED_SECRETS}" elif [ "$1" = "in" ]; then cp -a "${PATH_MOUNTED_SECRETS}" "${PATH_SECRETS}" else - echo abort "Illegal argument to unmount_secrets." + abort "Illegal argument to unmount_secrets." fi pumount "${SECRETS_DEV}" - echo "You can remove device ${SECRETS_DEV} now." + prefixed_msg "You can remove device ${SECRETS_DEV} now." + prefixed_msg_exit } -- 2.30.2