Simplify vault script

It gathers all .age files and decrypts into secrets folder that is .gitignored. Assembly of the distribution plucks the decrypted files from secrets folder
This commit is contained in:
Lukas Stancik
2025-03-17 17:42:46 +00:00
parent 64ec3e48b4
commit 95f487fa2a
+16 -16
View File
@@ -1,38 +1,38 @@
#!/bin/sh #!/bin/sh
set -e set -e
FILES_IN_VAULT='./src/wifi-password.txt FILES_IN_VAULT=$(find . -name *.age)
./src/repository-builder/packager.rsa
./src/repository-builder/packager.rsa.pub
./src/wireguard.private.key
./src/wireguard.public.key
./src/authorized_keys'
age_encrypt() { age_encrypt() {
local input="$1" if [ $# -ne 1 ] ; then
local output="$1.tmp" echo "invalid argument"
local AGE_PASSPHRASE=`cat ./.vault_password_file` exit 1
fi
./cache/age/age --encrypt --passphrase --armor --output $output $input && rm $input && mv $output $input AGE_PASSPHRASE=$(cat ./.vault_password_file) age --encrypt --passphrase --armor --output "$2" "$1"
} }
age_decrypt() { age_decrypt() {
local input="$1" if [ $# -ne 1 ] ; then
local output="$1.tmp" echo "invalid argument"
local AGE_PASSPHRASE=`cat ./.vault_password_file` exit 1
fi
./cache/age/age --decrypt --output $output $input && rm $input && mv $output $input BASENAME=$(basename $1 .age)
AGE_PASSPHRASE=$(cat ./.vault_password_file) age --decrypt --output "secrets/$BASENAME" "$1"
} }
encrypt() { encrypt() {
for FILE in $FILES_IN_VAULT; do for FILE in $FILES_IN_VAULT; do
age_encrypt $FILE age_encrypt "$FILE"
done done
} }
decrypt() { decrypt() {
for FILE in $FILES_IN_VAULT; do for FILE in $FILES_IN_VAULT; do
age_decrypt $FILE age_decrypt "$FILE"
done done
} }