-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sops support, add rekeying script
- Loading branch information
1 parent
0a24336
commit 6b54e65
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
gnupg | ||
rage | ||
shellcheck | ||
sops | ||
] ++ lib.optionals stdenv.isDarwin [ | ||
zfs-mac | ||
(sanoid.override { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
action="${1}" | ||
creds_dir="${2}" | ||
|
||
case "${action}" in | ||
encrypt) | ||
tmp="${creds_dir}/.creds.json.${RANDOM}" | ||
cat > "${tmp}" | ||
sops --input-type json --in-place --encrypt "${tmp}" </dev/null | ||
mv "${tmp}" "${creds_dir}/creds.json" | ||
;; | ||
decrypt) | ||
sops --output-type json --decrypt "${creds_dir}/creds.json" </dev/null | ||
;; | ||
*) | ||
echo >&2 "Unsupported action '${action}'" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
scriptdir="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")" | ||
source "${scriptdir}/common.sh" | ||
|
||
repo="${1}" | ||
credsdir="$(creds_dir "${repo}")" | ||
current_type="$(_determine_key_prog "${credsdir}")" | ||
|
||
new_credsdir="$(dirname -- "${credsdir}")/.$(basename -- "${credsdir}").${RANDOM}" | ||
new_type="${2:-"${current_type}"}" | ||
|
||
[ -n "${credsdir}" ] | ||
[ -n "${new_credsdir}" ] | ||
[ -n "${new_type}" ] | ||
|
||
mkdir -p "${new_credsdir}" | ||
|
||
cleanup () { | ||
if [ -d "${new_credsdir}" ]; then | ||
rm -rf "${new_credsdir}" | ||
fi | ||
} | ||
|
||
trap 'cleanup' EXIT | ||
|
||
decrypt_key "${credsdir}" | encrypt_key "${new_credsdir}" "${new_type}" | ||
rm -rf "${credsdir}" | ||
mv "${new_credsdir}" "${credsdir}" |