linux-surface-default-watchdog.sh 574 B

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