1
1
Fork 0
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2024-05-13 01:46:04 +02:00

borg: allow out of place calls by prepending the root directory

This commit is contained in:
Levente Polyak 2021-07-01 19:42:29 +02:00
parent c225001bc8
commit d62f409642
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -4,6 +4,7 @@ set -eu
shopt -s extglob
OFFSITE_HOST=ch-s012.rsync.net
ROOT_DIR=$(dirname "${0}")/..
decrypted_gpg=$(mktemp arch-infrastructure-borg-XXXXXXXXX)
trap "rm -f \"${decrypted_gpg}\"" EXIT
@ -11,7 +12,7 @@ trap "rm -f \"${decrypted_gpg}\"" EXIT
# Find matching key
matching_key=""
for gpgkey in borg-keys/!(*-offsite.gpg); do
for gpgkey in "$ROOT_DIR"/borg-keys/!(*-offsite.gpg); do
key=$(basename "$gpgkey" .gpg)
if [[ "$*" =~ $key ]]; then
matching_key="$key"
@ -25,7 +26,7 @@ if [[ -z "$matching_key" ]]; then
echo "No matching keyfile found for this host"
exit 1
fi
gpg --batch --yes --decrypt -aq --output "$decrypted_gpg" borg-keys/"$matching_key.gpg"
gpg --batch --yes --decrypt -aq --output "$decrypted_gpg" "$ROOT_DIR/borg-keys/$matching_key.gpg"
BORG_KEY_FILE="$decrypted_gpg" borg "$@"