Allow age key from ~/.config/age or creds/age-key
This commit is contained in:
parent
b89f7ce129
commit
4c9da9c604
1 changed files with 16 additions and 2 deletions
|
|
@ -4,7 +4,21 @@ set -euo pipefail
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
source deploy/env.sh
|
source deploy/env.sh
|
||||||
|
|
||||||
AGE_KEY_FILE="${SOPS_AGE_KEY_FILE:-$HOME/.config/age/keys.txt}"
|
AGE_KEY_FILE_CANDIDATES=(
|
||||||
|
"${SOPS_AGE_KEY_FILE:-}"
|
||||||
|
"$HOME/.config/age/keys.txt"
|
||||||
|
"$PWD/creds/age-key.txt"
|
||||||
|
)
|
||||||
|
AGE_KEY_FILE=""
|
||||||
|
for candidate in "${AGE_KEY_FILE_CANDIDATES[@]}"; do
|
||||||
|
if [[ -n "$candidate" && -f "$candidate" ]]; then
|
||||||
|
AGE_KEY_FILE="$candidate"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -z "$AGE_KEY_FILE" ]]; then
|
||||||
|
AGE_KEY_FILE="$HOME/.config/age/keys.txt"
|
||||||
|
fi
|
||||||
AGE_RECIPIENT="age1hkehkc2rryjl975c2mg5cghmjr54n4wjshncl292h2eg5l394fhs4uydrh"
|
AGE_RECIPIENT="age1hkehkc2rryjl975c2mg5cghmjr54n4wjshncl292h2eg5l394fhs4uydrh"
|
||||||
ENCRYPTED_SECRETS_FILE="${ENCRYPTED_SECRETS_FILE:-$PWD/creds/secrets.enc.env}"
|
ENCRYPTED_SECRETS_FILE="${ENCRYPTED_SECRETS_FILE:-$PWD/creds/secrets.enc.env}"
|
||||||
|
|
||||||
|
|
@ -34,7 +48,7 @@ check_age_setup() {
|
||||||
require_cmd sops
|
require_cmd sops
|
||||||
local repo_age_key="$PWD/creds/age-key.txt"
|
local repo_age_key="$PWD/creds/age-key.txt"
|
||||||
if [[ ! -f "$AGE_KEY_FILE" ]]; then
|
if [[ ! -f "$AGE_KEY_FILE" ]]; then
|
||||||
echo "Age key file not found at $AGE_KEY_FILE. Copy creds/age-key.txt or set SOPS_AGE_KEY_FILE." >&2
|
echo "Age key file not found at $AGE_KEY_FILE. Copy $repo_age_key or set SOPS_AGE_KEY_FILE." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
local has_key="0"
|
local has_key="0"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue