It gathers all .age files and decrypts into secrets folder that is .gitignored. Assembly of the distribution plucks the decrypted files from secrets folder
40 lines
626 B
Bash
Executable File
40 lines
626 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
FILES_IN_VAULT=$(find . -name *.age)
|
|
|
|
age_encrypt() {
|
|
if [ $# -ne 1 ] ; then
|
|
echo "invalid argument"
|
|
exit 1
|
|
fi
|
|
|
|
AGE_PASSPHRASE=$(cat ./.vault_password_file) age --encrypt --passphrase --armor --output "$2" "$1"
|
|
}
|
|
|
|
age_decrypt() {
|
|
if [ $# -ne 1 ] ; then
|
|
echo "invalid argument"
|
|
exit 1
|
|
fi
|
|
|
|
BASENAME=$(basename $1 .age)
|
|
|
|
AGE_PASSPHRASE=$(cat ./.vault_password_file) age --decrypt --output "secrets/$BASENAME" "$1"
|
|
}
|
|
|
|
|
|
encrypt() {
|
|
for FILE in $FILES_IN_VAULT; do
|
|
age_encrypt "$FILE"
|
|
done
|
|
}
|
|
|
|
decrypt() {
|
|
for FILE in $FILES_IN_VAULT; do
|
|
age_decrypt "$FILE"
|
|
done
|
|
}
|
|
|
|
$1
|