nixos/scripts/remote_switch.sh

28 lines
494 B
Bash
Raw Normal View History

2022-01-31 12:42:56 +01:00
#!/usr/bin/env bash
2022-01-31 15:45:25 +01:00
hosts=(
2022-01-31 12:42:56 +01:00
"mail"
2022-01-31 15:45:25 +01:00
"nextcloud"
2022-01-31 12:42:56 +01:00
"plex"
2022-10-14 08:39:51 +02:00
"management"
2022-02-28 15:15:11 +01:00
"restic-server"
2022-01-31 12:42:56 +01:00
"ttrss"
"git"
2022-09-06 22:42:27 +02:00
"proxy"
2022-07-18 12:01:47 +02:00
"pihole"
2022-01-31 12:42:56 +01:00
)
2022-01-31 15:45:25 +01:00
rsa_key="$HOME/.nixos/secrets/ssh_keys/ansible/ansible.key"
export NIX_SSHOPTS="-t -i $rsa_key"
2022-01-31 12:42:56 +01:00
2022-01-31 15:45:25 +01:00
for host in "${hosts[@]}"
do
2022-01-31 12:42:56 +01:00
fqdn="$host.2li.local"
echo $fqdn
nixos-rebuild switch -j auto --use-remote-sudo --build-host localhost --target-host $fqdn --flake ".#$host"
2022-05-20 13:29:35 +02:00
echo "reboot $fqdn"
2022-05-20 13:35:18 +02:00
ssh -i $rsa_key $fqdn 'sudo reboot'
2022-05-20 13:29:35 +02:00
echo
echo
done