Review shell scripts
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -9,21 +9,21 @@ if [[ "$#" -ne 2 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST="$1"
|
||||
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")
|
||||
age_key=$(nix shell nixpkgs#ssh-to-age --command bash -c "cat './hosts/$host/secrets/ssh_host_ed25519_key.pub' | ssh-to-age")
|
||||
|
||||
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}"
|
||||
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}/d" ./hosts/common/configs/system/ssh/default.nix
|
||||
sed -i "/${HOST}/d" ./hosts/common/configs/user/console/ssh/default.nix
|
||||
sed -i "/$host/d" ./hosts/common/configs/system/ssh/default.nix
|
||||
sed -i "/$host/d" ./hosts/common/configs/user/console/ssh/default.nix
|
||||
|
||||
"$(dirname "$0")/update-keys.sh" "$2"
|
||||
|
||||
rm -rf "./hosts/${HOST}"
|
||||
rm -rf "./hosts/$host"
|
||||
|
||||
echo "Host ${HOST} has been successfully removed."
|
||||
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