From 77e66d8c63313c60bfc87da0438155e5d50d8a68 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 2 Apr 2025 16:15:25 +0200 Subject: [PATCH] Fix. --- testing/home/desktop/.local/bin/borgplom | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom index 41a0a28..379e934 100755 --- a/testing/home/desktop/.local/bin/borgplom +++ b/testing/home/desktop/.local/bin/borgplom @@ -50,26 +50,26 @@ cmd_claim() { error_exit "refusing to overwrite pre-existing file at $1" fi } - _PATH="$1" - _FILENAME=$(basename ${_PATH}) - _TARGET_PATH_KEY="${PATH_BORG_CONF_KEYS}/${_FILENAME}" - if [ ! -f "${_PATH}" ]; then - error_exit "no file at ${_PATH}" + _PATH_SOURCE="$1" + _FILENAME=$(basename ${_PATH_SOURCE}) + _PATH_TARGET_KEY="${PATH_BORG_CONF_KEYS}/${_FILENAME}" + if [ ! -f "${_PATH_SOURCE}" ]; then + error_exit "no file at ${_PATH_SOURCE}" fi - _ensure_no_overwrite_at "${_TARGET_PATH_KEY}" - _REPO_ID="$(head -1 ${_PATH} | cut -d' ' -f2)" + _ensure_no_overwrite_at "${_PATH_TARGET_KEY}" + _REPO_ID="$(head -1 ${_PATH_SOURCE} | cut -d' ' -f2)" if [ ! -z "$(echo ${_REPO_ID} | sed 's/[a-f0-9]//g')" ]; then - error_exit "inability to parse valid repo ID from alleged key file at ${_PATH}" + error_exit "inability to parse valid repo ID from alleged key file at ${_PATH_SOURCE}" fi - _TARGET_PATH_LOCATION="$(path_repo_location ${_REPO_ID})" - _ensure_no_overwrite_at "${_TARGET_PATH_LOCATION}" - mkdir -p "${PATH_BORG_CONF_KEYS}" "${PATH_BORG_CONF_SECURITY}" - echo "Copying ${_PATH} to ${_TARGET_PATH_KEY} …" - cp "${_PATH}" "${_TARGET_PATH_KEY}" - echo "Writing ${_TARGET_PATH_LOCATION} …" - echo "$(location_from_servername ${_FILENAME})" > "${_TARGET_PATH_LOCATION}" - chmod a-rwx "${_TARGET_PATH_KEY}" "${_TARGET_PATH_LOCATION}" - chmod u+rw "${_TARGET_PATH_KEY}" "${_TARGET_PATH_LOCATION}" + _PATH_TARGET_LOCATION="$(path_repo_location ${_REPO_ID})" + _ensure_no_overwrite_at "${_PATH_TARGET_LOCATION}" + mkdir -p "${PATH_BORG_CONF_KEYS}" "$(dirname ${_PATH_TARGET_LOCATION})" + echo "Copying ${_PATH_SOURCE} to ${_PATH_TARGET_KEY} …" + cp "${_PATH_SOURCE}" "${_PATH_TARGET_KEY}" + echo "Writing ${_PATH_TARGET_LOCATION} …" + echo "$(location_from_servername ${_FILENAME})" > "${_PATH_TARGET_LOCATION}" + chmod a-rwx "${_PATH_TARGET_KEY}" "${_PATH_TARGET_LOCATION}" + chmod u+rw "${_PATH_TARGET_KEY}" "${_PATH_TARGET_LOCATION}" } cmd_keys() { -- 2.30.2