Files
nix/lib/scripts/update-keys.sh
2024-12-20 10:00:01 +00:00

24 lines
583 B
Bash
Executable File

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <sops-master-key>"
exit 1
fi
export SOPS_AGE_KEY_FILE="$1"
find . -type f -name 'sops.yaml' | while IFS= read -r SOPS_FILE; do
dir=$(dirname "${SOPS_FILE}")
echo "${dir}"
find "${dir}" -maxdepth 1 -type f -regextype posix-extended \
-regex '.+\.(yaml|yml|json|env|ini|bin)' \
! -name 'sops.yaml' | while IFS= read -r file; do
echo "${file}"
nix shell nixpkgs#sops --command sops --config "${SOPS_FILE}" updatekeys "${file}" -y
done
done