linux-surface/contrib/fedora-default-kernel/default-kernel.sh
Maximilian Luz 20ca44dc7f
contrib/fedora-default-kernel: Make more robust and add rEFInd support
Add a script to explicitly handle multiple Surface kernel versions being
installed in parallel, sorting kernels by timestamp and choosing the
latest one.

Further, add support for rEFInd by updating the vmlinuz file timestamp
to ensure it's always seen as the last modified file (which will be
picked by rEFInd as the "default" kernel in that directory).

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
2023-06-02 21:55:09 +02:00

21 lines
510 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
# get list of surface kernels with timestamp
kernels=$(find /boot -maxdepth 1 -name "vmlinuz-*.surface.*" -printf '%T@\t%p\n')
# sort by timestamp
kernels=$(echo "${kernels}" | sort -n)
# get latest kernel (last line) and extract path
kernel=$(echo "${kernels}" | tail -n1 | cut -f2)
echo $kernel
# update GRUB config
grubby --set-default "${kernel}"
# update timestamp for rEFInd (ensure it's marked as latest across all kernels,
# not just surface ones)
touch "${kernel}"