clan-infra/targets/web01/decrypt.sh

19 lines
422 B
Bash
Raw Normal View History

2023-07-17 08:31:59 +00:00
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils sops openssh
set -euox pipefail
2023-07-19 12:43:30 +00:00
HOST=clan.lol
2023-07-17 08:31:59 +00:00
temp=$(mktemp -d)
trap 'rm -rf $temp' EXIT
sops --extract '["cryptsetup_key"]' -d secrets.yaml > "$temp/secret.key"
while ! ping -4 -W 1 -c 1 "$HOST"; do
sleep 1
done
while ! timeout 4 ssh -p 2222 "root@$HOST" true; do
sleep 1
done
ssh -p 2222 "root@$HOST" "cat > /crypt-ramfs/passphrase" < "$temp/secret.key"