pkg: fedora: Some updates for default kernel watchdog script

This commit is contained in:
Dorian Stoll 2023-09-05 15:18:54 +02:00
parent 32c55fe01c
commit 8f73c0b34b

View file

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