2024-08-31 22:22:00 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-09-08 00:48:56 +02:00
|
|
|
set -Eeuo pipefail
|
2024-08-31 22:22:00 +02:00
|
|
|
|
|
|
|
ssh_command=${SSH_COMMAND-ssh}
|
2024-09-08 00:48:56 +02:00
|
|
|
root_prefix=${ROOT_PREFIX-/}
|
2024-08-31 22:22:00 +02:00
|
|
|
|
|
|
|
reboot="reboot"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"--no-reboot")
|
|
|
|
unset reboot
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
"--fast")
|
|
|
|
reboot="soft"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
target_host=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [ -z "$target_host" ] ; then
|
|
|
|
echo Usage: liminix-rebuild \[--no-reboot\] target-host params
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-09-01 17:20:37 +02:00
|
|
|
if toplevel="$(nom-build $(colmena eval -E "{ nodes, ... }: nodes.$@.config.system.outputs.systemConfiguration" --instantiate))"; then
|
2024-09-08 00:48:56 +02:00
|
|
|
echo systemConfiguration $toplevel aimed at $root_prefix
|
|
|
|
sleep 3
|
|
|
|
min-copy-closure --root "$root_prefix" $target_host $toplevel
|
|
|
|
$ssh_command $target_host "$root_prefix/$toplevel/bin/install" "$root_prefix"
|
2024-08-31 22:22:00 +02:00
|
|
|
case "$reboot" in
|
|
|
|
reboot)
|
|
|
|
$ssh_command $target_host "sync; source /etc/profile; reboot"
|
|
|
|
;;
|
|
|
|
soft)
|
|
|
|
$ssh_command $target_host $toplevel/bin/restart-services
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo Rebuild failed
|
|
|
|
fi
|