modules/nixos/common/update: cancel unnecessary reboots
this is needed if the host is updated to a newer generation that doesn't require a reboot or is reverted to the current generation
This commit is contained in:
parent
55ea0aed0f
commit
8528527e06
1 changed files with 9 additions and 0 deletions
|
@ -2,7 +2,15 @@ arch=$(uname -m)
|
||||||
hostname=$(uname -n)
|
hostname=$(uname -n)
|
||||||
p=$(curl -L https://buildbot.nix-community.org/nix-outputs/nix-community/infra/master/"$arch"-linux.host-"$hostname")
|
p=$(curl -L https://buildbot.nix-community.org/nix-outputs/nix-community/infra/master/"$arch"-linux.host-"$hostname")
|
||||||
|
|
||||||
|
cancel_reboot() {
|
||||||
|
if [[ -e /run/systemd/shutdown/scheduled ]]; then
|
||||||
|
shutdown -c
|
||||||
|
kexec --unload
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ "$(readlink /run/current-system)" == "$p" ]]; then
|
if [[ "$(readlink /run/current-system)" == "$p" ]]; then
|
||||||
|
cancel_reboot
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -26,5 +34,6 @@ if [[ $booted != "$built" ]]; then
|
||||||
shutdown -r "+$(shuf -i 5-60 -n 1)"
|
shutdown -r "+$(shuf -i 5-60 -n 1)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
cancel_reboot
|
||||||
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue