Scripting stuff
This commit is contained in:
parent
bebdd082d2
commit
e6e1225858
1 changed files with 44 additions and 0 deletions
44
safe-remote-upgrade.bash
Executable file
44
safe-remote-upgrade.bash
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
echo 'safe-remote-upgrade.bash $flake $target_host'
|
||||
}
|
||||
|
||||
error() {
|
||||
echo "error: $1"
|
||||
usage
|
||||
}
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "error: no flake specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
flake="$1"; shift
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "error: no target host specified"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
target_host="$1"; shift
|
||||
|
||||
git add -A
|
||||
|
||||
ssh "root@$target_host" "bash -c '
|
||||
set -m
|
||||
# sleep 5 mins
|
||||
(sleep 300; reboot;) &
|
||||
jobs -p
|
||||
bg
|
||||
disown
|
||||
'"
|
||||
|
||||
nix run nixpkgs#nixos-rebuild -- --flake "$flake" \
|
||||
--target-host "root@$target_host" test --show-trace
|
||||
|
||||
echo "Upgrade ready for verification. If you still have SSH access you can bail out without waiting with the following command:"
|
||||
echo " ssh 'root@$target_host' nixos-rebuild --rollback switch"
|
||||
echo
|
||||
echo 'Done!'
|
||||
|
Loading…
Reference in a new issue