Fix utility script bugs
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -17,7 +17,7 @@ ssh-keygen -t ed25519 -f "./hosts/${HOST}/secrets/ssh_host_ed25519_key" -N ""
|
||||
|
||||
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
|
||||
find . -type f -name "sops.yaml" | while IFS= read -r SOPS_FILE; do
|
||||
sed -i "/- hosts:/a\ - &${HOST} ${AGE_KEY}" "${SOPS_FILE}"
|
||||
sed -i "/- age:/a\ - *${HOST}" "${SOPS_FILE}"
|
||||
done
|
||||
|
@@ -59,7 +59,7 @@ setup_wifi() {
|
||||
fi
|
||||
|
||||
echo "Waiting for a network connection..."
|
||||
for i in {1..10}; do
|
||||
for _ in {1..10}; do
|
||||
if ping -c 1 google.com &>/dev/null; then
|
||||
echo "Connected to the network successfully."
|
||||
return
|
||||
@@ -73,8 +73,9 @@ setup_wifi() {
|
||||
|
||||
select_host() {
|
||||
echo "Available hosts:"
|
||||
echo $(nix --experimental-features "nix-command flakes" flake show --json |
|
||||
nix --experimental-features "nix-command flakes" shell nixpkgs#jq --command jq -r '.nixosConfigurations | keys[]')
|
||||
hosts=$(nix --experimental-features "nix-command flakes" flake show --json \
|
||||
| nix --experimental-features "nix-command flakes" shell nixpkgs#jq --command jq -r '.nixosConfigurations | keys[]')
|
||||
echo "${hosts}"
|
||||
|
||||
echo "Enter host:"
|
||||
read -r host
|
||||
@@ -120,8 +121,8 @@ copy_config() {
|
||||
read -r copy_config
|
||||
|
||||
if [[ "${copy_config}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
||||
rm -rf /mnt/etc/nixos
|
||||
cp -r . /mnt/etc/nixos
|
||||
rm -rf /mnt/persist/etc/nixos
|
||||
cp -r . /mnt/persist/etc/nixos
|
||||
echo "Configuration copied successfully."
|
||||
fi
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ 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
|
||||
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
|
||||
|
@@ -11,11 +11,13 @@ fi
|
||||
|
||||
export SOPS_AGE_KEY_FILE="$1"
|
||||
|
||||
for SOPS_FILE in $(find . -type f -name 'sops.yaml'); do
|
||||
find . -type f -name 'sops.yaml' | while IFS= read -r SOPS_FILE; do
|
||||
dir=$(dirname "${SOPS_FILE}")
|
||||
echo "${dir}"
|
||||
find "${dir}" -maxdepth 1 -type f -regextype posix-extended -regex '.+\.(yaml|yml|json|env|ini|bin)' | while read -r file; do
|
||||
echo "${file}"
|
||||
nix shell nixpkgs#sops --command sops --config "${SOPS_FILE}" updatekeys "${file}" -y
|
||||
done
|
||||
find "${dir}" -maxdepth 1 -type f -regextype posix-extended \
|
||||
-regex '.+\.(yaml|yml|json|env|ini|bin)' \
|
||||
! -name 'sops.yaml' | while IFS= read -r file; do
|
||||
echo "${file}"
|
||||
nix shell nixpkgs#sops --command sops --config "${SOPS_FILE}" updatekeys "${file}" -y
|
||||
done
|
||||
done
|
||||
|
Reference in New Issue
Block a user