Flakify lib, sas
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
29
scripts/remove-host.sh
Executable file
29
scripts/remove-host.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
if [[ "$#" -ne 1 ]]; then
|
||||
echo "Usage: $0 <host>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
host="$1"
|
||||
|
||||
age_key=$(ssh-to-age < "./secrets/hosts/$host/ssh_host_ed25519_key.pub")
|
||||
|
||||
find . -type f -name "sops.yaml" | while IFS= read -r sops_file; do
|
||||
sed -i "/ - &$host $age_key/d" "$sops_file"
|
||||
sed -i "/ - \*$host/d" "$sops_file"
|
||||
done
|
||||
|
||||
sed -i "/$host = mkNixosConfiguration/d" flake.nix
|
||||
sed -i "/\`$host\`/d" ./README.md
|
||||
|
||||
rm -rf "./hosts/$host"
|
||||
|
||||
"$(dirname "$0")/update-keys.sh"
|
||||
|
||||
echo "Please remove SSH key pairs for any users that used to connect to $host."
|
||||
echo "Host $host has been successfully removed."
|
Reference in New Issue
Block a user