From 2e495e5ab5907141dc28af46a7d42dbb5db98e42 Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Thu, 3 Sep 2020 13:21:43 -0700 Subject: [PATCH] remove old script file --- age.sh | 68 ---------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 age.sh diff --git a/age.sh b/age.sh deleted file mode 100644 index febbdfd..0000000 --- a/age.sh +++ /dev/null @@ -1,68 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i bash -p age yq-go -set -euxo pipefail - -RULES=example.yaml - -function cleanup { - if [ ! -z ${CLEARTEXT_DIR+x} ] - then - rm -rf "$CLEARTEXT_DIR" - fi - if [ ! -z ${REENCRYPTED_DIR+x} ] - then - rm -rf "$REENCRYPTED_DIR" - fi -} -trap "cleanup" 0 2 3 15 - -function ageEdit { - FILE=$1 - KEYS=$(yq r "$RULES" "secrets.(name==$FILE).public_keys.**") - if [ -z "$KEYS" ] - then - >&2 echo "There is no rule for $FILE in $RULES." - exit 1 - fi - - CLEARTEXT_DIR=$(mktemp -d) - CLEARTEXT_FILE="$CLEARTEXT_DIR/$(basename "$FILE")" - - - if [ -f "$FILE" ] - then - DECRYPT=(--decrypt) - while IFS= read -r key - do - DECRYPT+=(--identity "$key") - done <<<$(find ~/.ssh -maxdepth 1 -type f -not -name "*pub" -not -name "config" -not -name "authorized_keys" -not -name "known_hosts") - DECRYPT+=(-o "$CLEARTEXT_FILE" "$FILE") - age "${DECRYPT[@]}" - fi - - $EDITOR "$CLEARTEXT_FILE" - - ENCRYPT=() - while IFS= read -r key - do - echo "$key" - ENCRYPT+=(--recipient "$key") - done <<< "$KEYS" - - REENCRYPTED_DIR=$(mktemp -d) - REENCRYPTED_FILE="$REENCRYPTED_DIR/$(basename "$FILE")" - - ENCRYPT+=(-o "$REENCRYPTED_FILE") - - cat "$CLEARTEXT_FILE" | age "${ENCRYPT[@]}" - - mv -f "$REENCRYPTED_FILE" "$1" -} - -function rekey { - FILES=$(yq r "$RULES" "secrets.*.name") - for FILE in $FILES - do - EDITOR=echo ageEdit $FILE - done -}