updates to deploy-host

This commit is contained in:
Don Harper 2024-09-18 16:37:37 -05:00
parent c5a7131ced
commit 427ee38d7a
2 changed files with 25 additions and 14 deletions

View file

@ -4,7 +4,7 @@ set -o errexit
set -o errtrace
# set -o nounset
debug=echo
# debug=echo
if [ "x" == "x$2" ]
then
@ -14,22 +14,32 @@ fi
nixanywhere=~/nixos/nixos-anywhere
nixsrc=~/nixos
ip="${1}"
host="${2}"
ip=${1}
host=${2}
if [ ! -f "${nixsrc}/hosts/${host}/default.nix" ]
if [ ! -f ${nixsrc}/hosts/${host}/default.nix ]
then
echo "Please set up ${nixsrc}/hosts/${host}/default.nix before running"
exit 1
fi
${debug} cd "${nixanywhere}"
${debug} ssh-keygen -R "${ip}"
${debug} nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@"${ip}"
${debug} cd "${nixsrc}"
${debug} ssh-keygen -R "${ip}"
${debug} ssh root@"${ip}" nixos-generate-config
${debug} scp root@"${ip}":/etc/nixos/hardware-configuration.nix hosts/${host}/hardware-configuration.nix
${debug} git add hosts/${host}/hardware-configuration.nix
${debug} nixos-rebuild switch --flake .#${host} --target-host "root@"${ip}""
${debug} rsync -av ~/.ssh ~/bin don@"${ip}":
cd ${nixanywhere}
ssh-keygen -R ${ip}
nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@${ip}
cd ${nixsrc}
sleep 5
until ping -c1 ${ip}
do
sleep 5
done
ssh-keygen -R ${ip}
ssh -o StrictHostKeyChecking=accept-new root@${ip} nixos-generate-config
scp root@${ip}:/etc/nixos/hardware-configuration.nix hosts/${host}/hardware-configuration.nix
git add hosts/${host}/hardware-configuration.nix
nixos-rebuild switch --flake .#${host} --target-host root@${ip}
sleep 5
until ping -c1 ${ip}
do
sleep 5
done
rsync -av ~/.ssh ~/bin don@${ip}:

View file

@ -59,6 +59,7 @@
"vm.swappiness" = 10;
};
};
};
services.openssh.enable = true;