linux-surface/pkg/fedora/kernel-surface/files/linux-surface-default-watchdog.sh
Dorian Stoll 7eb766437e pkg: fedora: Use the proper path to set the default kernel
grubby --set-default expects the path that GRUB will use to access
the kernel. This adds compatibility with /boot on a BTRFS subvolume.
2023-09-06 17:23:53 +02:00

24 lines
596 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
# Get list of surface kernels with timestamp
KERNELS="$(
find /boot -maxdepth 1 -name 'vmlinuz-*.surface.*' -print0 | xargs -0 -I '{}' \
stat -c "%W %n" {}
)"
# Sort by timestamp
KERNELS="$(echo "${KERNELS}" | sort -n)"
# Get latest kernel (last line) and extract the path
VMLINUX="$(echo "${KERNELS}" | tail -n1 | cut -d' ' -f2)"
echo "${VMLINUX}"
# update GRUB config
grubby --set-default "$(grub2-mkrelpath "${BOOTPATH}")"
# Update timestamp for rEFInd
# Ensure it's marked as latest across all kernels, not just surface ones
touch "${VMLINUX}"