Skip to content

Commit

Permalink
add kernel-check based reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
thilobillerbeck committed Jan 15, 2024
1 parent fbe30e8 commit 04ebaf6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix-shell --run "colmena apply -v"
if: ${{ github.event_name != 'schedule' }}
name: Update machines
- run: nix-shell --run "colmena apply -v --reboot"
- run: nix-shell --run "colmena exec -v \"kernel-check-reboot\""
if: ${{ github.event_name == 'schedule' }}
name: Update machines (with reboot)
name: Check for kenrel update and reboot
13 changes: 13 additions & 0 deletions configs/packages-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,18 @@
curl
unzip
ncdu
(pkgs.writeShellScriptBin "kernel-check-reboot" ''
currentKernel=$(readlink /run/current-system/kernel)
bootedKernel=$(readlink /run/booted-system/kernel)
echo "Current Kernel Path:" $currentKernel
echo "Booted Kernel Path:" $bootedKernel
if [[ "$currentKernel" != "$bootedKernel" ]]; then
echo "Kernel Versions differ. Rebooting...."
systemctl reboot -i
else
echo "Current kernel is booted. Skipping...."
fi
'')
];
}

0 comments on commit 04ebaf6

Please sign in to comment.