#!/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