From: Christian Heller Date: Fri, 4 Apr 2025 13:55:01 +0000 (+0200) Subject: Fix. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/%7B%7Bdb.prefix%7D%7D/foo.html?a=commitdiff_plain;h=a901c09a5e8732c4fc0e656662a4f0f9f99f147a;p=config Fix. --- diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index 0a648f0..c850818 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -36,6 +36,26 @@ _check_args_n() { fi } +_run_borg_with_passphrase() { + while true; do + if [ -z "${BORG_PASSPHRASE}" ]; then + printf 'Passphrase:' + export BORG_PASSPHRASE="$(get_passphrase)" + echo '' + fi + set +e + _OUTPUT="$(borg $@)" + _RESULT=$? + set -e + if [ "${_RESULT}" = "0" ]; then + break + elif [ "${_RESULT}" != "2" ]; then + error_exit "unexpected ${NAME_BORGAPP} error." + fi + export BORG_PASSPHRASE= + done +} + _id_from_file() { head -1 "$1" | cut -d' ' -f2; } USAGE_ARGS_backup_keys='PATH' @@ -64,7 +84,7 @@ CMDFNC_backup_keys() { } USAGE_ARGS_claim='PATH' -USAGE_DESC_claim="register file of PATH as key to repo at \"$(location_from_servername SERVERNAME)\", with SERVERNAME the filename portion of PATH" +USAGE_DESC_claim="register file of PATH as key to repo at \"$(location_from_servername SERVER_NAME)\", with SERVER_NAME the filename portion of PATH" CMDFNC_claim() { _check_args_n 1 1 "$@" _PATH_SOURCE="$1" @@ -101,7 +121,7 @@ CMDFNC_help() { } USAGE_ARGS_info='SERVER_NAME [ARCHIVE]' -USAGE_DESC_info='run "borg info" against repo in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list most recent archives of repo' +USAGE_DESC_info="run 'borg info' against repo at \"$(location_from_servername SERVER_NAME)\"in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list most recent archives of repo" CMDFNC_info() { _check_args_n 1 2 "$@" _TARGET_REPO="$(location_from_servername ${1})" @@ -109,25 +129,8 @@ CMDFNC_info() { borg info "${_TARGET_REPO}::$2" exit 0 fi - while true; do - if [ -z "${BORG_PASSPHRASE}" ]; then - printf 'Passphrase:' - export BORG_PASSPHRASE="$(get_passphrase)" - echo '' - fi - set +e - _INFO=$(borg info "${_TARGET_REPO}") - _RESULT=$? - set -e - if [ "${_RESULT}" = "0" ]; then - break - elif [ "${_RESULT}" != "2" ]; then - error_exit "unexpected ${NAME_BORGAPP} error." - fi - export BORG_PASSPHRASE= - done - echo "${_INFO}" - echo "Most recent archives:" + _run_borg_with_passphrase info "${_TARGET_REPO}" + echo "${_OUTPUT}\n\nMost recent archives:" borg list "${_TARGET_REPO}" | tail -5 } @@ -185,24 +188,8 @@ CMDFNC_orgpull() { # determine passphrase and archive echo "Checking out ${_REPO} …" - while true; do - if [ -z "${BORG_PASSPHRASE}" ]; then - printf 'Passphrase:' - export BORG_PASSPHRASE="$(get_passphrase)" - echo '' - fi - set +e - _ARCHIVES=$(borg list "${_REPO}") # separate step so we may fail early on bad passphrase - _RESULT=$? - set -e - if [ "${_RESULT}" = "0" ]; then - break - elif [ "${_RESULT}" != "2" ]; then - error_exit "unexpected ${NAME_BORGAPP} error." - fi - export BORG_PASSPHRASE= - done - _ARCHIVE=$(echo "${_ARCHIVES}" | grep "${_NAME_ARCHIVE}" | tail -1 | cut -f1 -d' ') + _run_borg_with_passphrase list "${_REPO}" + _ARCHIVE=$(echo "${_OUTPUT}" | grep "${_NAME_ARCHIVE}" | tail -1 | cut -f1 -d' ') # pull archive echo "Pulling archive: ${_ARCHIVE}"