From fec1842d1280338dade0b1338ecd79c085868b78 Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 25 Mar 2024 15:34:22 +0100 Subject: small script for creating secrets --- secret_create.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 secret_create.sh (limited to 'secret_create.sh') diff --git a/secret_create.sh b/secret_create.sh new file mode 100755 index 0000000..fcd05cb --- /dev/null +++ b/secret_create.sh @@ -0,0 +1,27 @@ +# usage: +# $1 = hostname +# $2 = secretname (with .age suffix) + +if [ $# -lt 2 ]; then + # TODO: print usage + echo "USAGE: ./secret_create.sh " + echo "EXAMPLE: ./secret_create.sh corrino abc.age" + exit 1 +fi + +# the path we'll use to store our secret in the end +SECRET_FILE="nix/hosts/$1/secrets/$2" + +# but first, we're editing the default "new" secret +NEW_FILE="nix/hosts/$1/secrets/new" + +echo "Editing the 'new' file: '$NEW_FILE'" +EDITOR=hx nix run git+https://github.com/ryantm/agenix -- -e $NEW_FILE + +echo "Moving the 'new' file to the specified secret file '$2'" +mv $NEW_FILE $SECRET_FILE + +echo "Adding the secret to git in order to use it" +git add $SECRET_FILE + +echo "Created secret $SECRET_FILE" -- cgit 1.4.1