Merge pull request #1150 from linux-surface/contrib/fedora-default-kernel

contrib/fedora-default-kernel: Make more robust and add rEFInd support
This commit is contained in:
Dorian Stoll 2023-06-02 22:02:23 +02:00 committed by GitHub
commit 4de7208e1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View file

@ -12,6 +12,8 @@ selection every time.
```bash
$ sudo dnf install /usr/sbin/grubby
$ sudo cp default-kernel.{path,service} /etc/systemd/system/
$ sudo cp default-kernel.sh /usr/local/bin/default-kernel
$ sudo chmod 755 /usr/local/bin/default-kernel
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now default-kernel.path
```

View file

@ -3,4 +3,4 @@ Description=linux-surface default kernel watchdog
[Service]
Type=oneshot
ExecStart=/bin/sh -c "grubby --set-default /boot/vmlinuz*surface*"
ExecStart=/usr/local/bin/default-kernel

View file

@ -0,0 +1,20 @@
#!/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}"