Housekeeping
- Update README - Run shellcheck on .sh files - Add helper scripts - Remove eirene vm variant - Add post-install checklist Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
24
scripts/remove-host.sh
Executable file
24
scripts/remove-host.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$#" -ne 2 ]]; then
|
||||
echo "Usage: $0 <host> <sops-master-key>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST="$1"
|
||||
|
||||
AGE_KEY=$(nix shell nixpkgs#ssh-to-age --command bash -c "cat './hosts/${HOST}/secrets/ssh_host_ed25519_key.pub' | ssh-to-age")
|
||||
|
||||
for SOPS_FILE in $(find . -type f -name "sops.yaml"); do
|
||||
sed -i "/ - &${HOST} ${AGE_KEY}/d" "${SOPS_FILE}"
|
||||
sed -i "/ - \*${HOST}/d" "${SOPS_FILE}"
|
||||
done
|
||||
|
||||
sed -i "/${HOST}.publicKeyFile/d" ./hosts/common/system/configs/ssh/default.nix
|
||||
|
||||
"$(dirname "$0")/update-keys.sh" "$2"
|
||||
|
||||
rm -rf "./hosts/${HOST}"
|
||||
|
||||
echo "Host ${HOST} has been successfully removed."
|
||||
echo "Please remove SSH key pairs for any users that used to connect to this host."
|
Reference in New Issue
Block a user