From 1f21c2b9115689db8efff0ef6f3ce25312d62351 Mon Sep 17 00:00:00 2001 From: clerie Date: Fri, 19 May 2023 20:38:40 +0200 Subject: [PATCH] Add script for backup secrets generation --- bin/generate-backup-secrets.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/generate-backup-secrets.sh diff --git a/bin/generate-backup-secrets.sh b/bin/generate-backup-secrets.sh new file mode 100755 index 0000000..efaa83b --- /dev/null +++ b/bin/generate-backup-secrets.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -euo pipefail + +cd $(git rev-parse --show-toplevel) + +host=$1 + +job_main=$(nix run nixpkgs#pwgen -- -1 64 1) +target_cyan=$(nix run nixpkgs#pwgen -- -1 64 1) +target_cyan_htpasswd=$(nix shell nixpkgs#apacheHttpd -c htpasswd -nbB ${host} ${target_cyan}) +target_magenta=$(nix run nixpkgs#pwgen -- -1 64 1) +target_magenta_htpasswd=$(nix shell nixpkgs#apacheHttpd -c htpasswd -nbB ${host} ${target_magenta}) + +mkdir -p hosts/${host}/secrets + +echo "$job_main" | nix run github:ryantm/agenix -- -e hosts/${host}/secrets/new +mv hosts/${host}/secrets/new hosts/${host}/secrets/clerie-backup-job-main.age + +echo "$target_cyan" | nix run github:ryantm/agenix -- -e hosts/${host}/secrets/new +mv hosts/${host}/secrets/new hosts/${host}/secrets/clerie-backup-target-cyan.age + +echo "$target_magenta" | nix run github:ryantm/agenix -- -e hosts/${host}/secrets/new +mv hosts/${host}/secrets/new hosts/${host}/secrets/clerie-backup-target-magenta.age + +echo "$target_cyan_htpasswd" | nix run github:ryantm/agenix -- -e hosts/clerie-backup/secrets/restic-server-cyan-htpasswd.age +echo "$target_magenta_htpasswd" | nix run github:ryantm/agenix -- -e hosts/backup-4/secrets/restic-server-magenta-htpasswd.age