updates to deploy-host
This commit is contained in:
parent
c5a7131ced
commit
427ee38d7a
2 changed files with 25 additions and 14 deletions
38
deploy-host
38
deploy-host
|
|
@ -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}:
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
"vm.swappiness" = 10;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh.enable = true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue