From 4bed25e00a5873f27554c385d669756d2da15660 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 22 Mar 2026 18:02:28 +0100 Subject: scripts/update_hosts: Init That works cleaner than the `deploy-rs` based solution. --- scripts/update_hosts.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 scripts/update_hosts.sh (limited to 'scripts/update_hosts.sh') diff --git a/scripts/update_hosts.sh b/scripts/update_hosts.sh new file mode 100755 index 0000000..505f061 --- /dev/null +++ b/scripts/update_hosts.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env sh +set -e + +base_dir="$(git rev-parse --show-toplevel)" + +user="${1-$USER}" +hosts="${2-server2 server3}" +branch="${3-main}" + +for host in $hosts; do + echo "Updating '$user@$host.vhack.eu' ..." + + new_system="$(nix build ".#nixosConfigurations.$host.config.system.build.toplevel" --no-link --print-out-paths)" + + printf "Copying closure ..\n" + nix-copy-closure "$user@$host.vhack.eu" "$new_system" + + printf "Deploying remote side script ..\n" + scp "$base_dir/scripts/update_hosts.remote" "$user@$host.vhack.eu:update_host.remote" + + printf "Executing remote side script ..\n" + ssh -t "$user@$host.vhack.eu" "chmod +x update_host.remote; ./update_host.remote '$branch'" +done +# vim: ft=sh -- cgit 1.4.1