#3 Remove unneeded SOPS_AGE_RECIPIENTS configuration from decrypt, cd to repo root

This commit is contained in:
Joey Hafner 2024-08-16 12:43:31 -07:00
parent 1b33a96e93
commit f9ca3ca219
No known key found for this signature in database
2 changed files with 3 additions and 11 deletions

View File

@ -15,20 +15,11 @@ export SOPS_AGE_KEY_FILE=$HOME/.age/key
{
AGE_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
REPO_ROOT=$(realpath "$AGE_DIR/../../")
SOPS_AGE_RECIPIENTS="$(<$AGE_DIR/.age-author-pubkeys)"
cd $REPO_ROOT
FILE_PATH=$(realpath "${REPO_ROOT}/$1")
echo "FILE_PATH: $FILE_PATH"
} > ~/decrypt-filter.stdout.log 2> ~/decrypt-filter.stderr.log
# Check for host pubkey, add as recipient if present
{
if [[ -f "$AGE_DIR/../$(realpath -m --relative-to=$AGE_DIR $FILE_PATH | cut -d'/' -f2)/.age-pubkey" ]]; then
HOST_AGE_PUBKEY=$AGE_DIR/../$(realpath -m --relative-to=$AGE_DIR $FILE_PATH | cut -d'/' -f2)/.age-pubkey
HOST_AGE_PUBKEY=$(realpath $HOST_AGE_PUBKEY)
SOPS_AGE_RECIPIENTS="$SOPS_AGE_RECIPIENTS,$(<$HOST_AGE_PUBKEY)"
fi
} >> ~/decrypt-filter.stdout.log 2>> ~/decrypt-filter.stderr.log
{
sops --decrypt --age ${SOPS_AGE_RECIPIENTS} $FILE_PATH
sops --decrypt $FILE_PATH
} 2>> ~/decrypt-filter.stderr.log

View File

@ -6,6 +6,7 @@
{
AGE_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
REPO_ROOT=$(realpath "$AGE_DIR/../../")
cd $REPO_ROOT
SOPS_AGE_RECIPIENTS="$(<$AGE_DIR/.age-author-pubkeys)"
FILE_PATH=$(realpath "${REPO_ROOT}/$1")
} >> ~/encrypt-filter.stdout.log 2>> ~/encrypt-filter.stderr.log