add a reboot timer

This commit is contained in:
Solène Rapenne 2023-06-24 11:31:49 +02:00
parent 189d476424
commit 98361e3555
Signed by: solene
GPG Key ID: 8CD42DFD57F0A909
2 changed files with 21 additions and 1 deletions

View File

@ -55,7 +55,9 @@ This adds at least 8 kB of inbound bandwidth for each input when checking for ch
# Auto reboot
You can create a file named `REBOOT` in a host directory. When that host will rebuild the system, it will look at the new kernel, kernel modules and initrd, if they changed, a reboot will occur immediately after reporting a successful upgrade. A kexec is used for UEFI systems for a faster reboot (this avoids BIOS and bootloader steps).
You can create a file named `REBOOT` in a host directory. When that host will rebuild the system, it will look at the new kernel, kernel modules and initrd, if they changed, a reboot will occur immediately after reporting a successful upgrade. A kexec is used for UEFI systems for a faster reboot (this avoids BIOS and bootloader steps).
Independently of the `REBOOT` file, in the provided `utils/bento.nix`, there is a systemd service that can be enabled to automatically reboot at a given systemd calendar if the kernel/mdoules/initrd changed. This is more convenient for servers.
# Status report of the fleet

View File

@ -17,6 +17,24 @@ in {
restartIfChanged = false;
};
systemd.services.bento-reboot = {
# this is disabled by default
# to avoid wrong expectations from users
enable = false;
startAt = "04:00";
path = with pkgs; [coreutils systemd];
serviceConfig.Type = "oneshot";
script = ''
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
built="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
if [ ! "$booted" = "$built" ]
then
systemctl kexec || systemctl reboot
fi
'';
};
systemd.sockets.listen-update = {
enable = true;
wantedBy = ["sockets.target"];