1
0

modules/clerie-system-upgrade: Always reboot after an update

This commit is contained in:
2025-06-30 18:35:57 +02:00
parent 4245ae84ed
commit 43d1133772
9 changed files with 3 additions and 25 deletions
hosts
dn42-il-gw1
dn42-il-gw5
dn42-il-gw6
dn42-ildix-clerie
dn42-ildix-service
nonat
storage-2
modules/clerie-system-upgrade
pkgs/clerie-system-upgrade

@@ -238,7 +238,6 @@
}; };
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
}; };

@@ -112,7 +112,6 @@
}; };
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
startAt = "*-*-* 06:22:00"; startAt = "*-*-* 06:22:00";
}; };

@@ -106,7 +106,6 @@
}; };
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
startAt = "*-*-* 07:22:00"; startAt = "*-*-* 07:22:00";
}; };

@@ -162,7 +162,6 @@
''; '';
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
}; };

@@ -71,7 +71,6 @@
networking.firewall.allowedTCPPorts = [ 80 443 ]; networking.firewall.allowedTCPPorts = [ 80 443 ];
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
}; };

@@ -42,7 +42,6 @@
networking.firewall.allowedUDPPorts = []; networking.firewall.allowedUDPPorts = [];
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
}; };

@@ -53,7 +53,6 @@
}; };
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
allowReboot = true;
autoUpgrade = true; autoUpgrade = true;
}; };

@@ -10,11 +10,6 @@ in
options = { options = {
clerie.system-auto-upgrade = { clerie.system-auto-upgrade = {
enable = mkEnableOption "clerie system upgrade"; enable = mkEnableOption "clerie system upgrade";
allowReboot = mkOption {
type = types.bool;
default = false;
description = "Monitor NixOS";
};
autoUpgrade = mkOption { autoUpgrade = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@@ -38,7 +33,7 @@ in
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
ExecStart = pkgs.clerie-system-upgrade + "/bin/clerie-system-upgrade --no-confirm${optionalString cfg.allowReboot " --allow-reboot"}${optionalString (config.clerie.monitoring.enable) " --node-exporter-metrics-path /var/lib/prometheus-node-exporter/textfiles/clerie-system-upgrade.prom"}"; ExecStart = pkgs.clerie-system-upgrade + "/bin/clerie-system-upgrade --no-confirm${optionalString (config.clerie.monitoring.enable) " --node-exporter-metrics-path /var/lib/prometheus-node-exporter/textfiles/clerie-system-upgrade.prom"}";
}; };
}; };
systemd.timers.clerie-system-auto-upgrade = mkIf cfg.autoUpgrade { systemd.timers.clerie-system-auto-upgrade = mkIf cfg.autoUpgrade {

@@ -2,16 +2,11 @@
set -euo pipefail set -euo pipefail
ALLOW_REBOOT=
NO_CONFIRM= NO_CONFIRM=
NODE_EXPORTER_METRICS_PATH= NODE_EXPORTER_METRICS_PATH=
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--allow-reboot)
ALLOW_REBOOT=1
shift
;;
--no-confirm) --no-confirm)
NO_CONFIRM=1 NO_CONFIRM=1
shift shift
@@ -63,13 +58,8 @@ ACTIVATING_SYSTEM_KERNEL="$(readlink /nix/var/nix/profiles/system/{initrd,kernel
if [[ "$BOOTED_SYSTEM_KERNEL" != "$ACTIVATING_SYSTEM_KERNEL" ]]; then if [[ "$BOOTED_SYSTEM_KERNEL" != "$ACTIVATING_SYSTEM_KERNEL" ]]; then
echo "Reboot is required" echo "Reboot is required"
if [[ -n "$ALLOW_REBOOT" ]]; then echo "Rebooting system now"
echo "Rebooting system now" shutdown -r +1 "System update requires reboot"
shutdown -r +1 "System update requires reboot"
else
echo "Automatic reboot not allowed (maybe use --allow-reboot next time)"
echo "The system upgrade is staged, please reboot manually soon"
fi
else else
echo "No reboot is required" echo "No reboot is required"
echo "Activating system now" echo "Activating system now"