2024-12-11 00:39:24 +03:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
export EFI_PATH=/boot/efi
|
|
|
|
|
2024-12-11 00:51:09 +03:00
|
|
|
if [ "$EUID" -ne 0 ]
|
|
|
|
then echo "Please run as root"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-12-11 00:39:24 +03:00
|
|
|
if [[ -f $EFI_PATH/EFI/refind/refind.conf ]]
|
|
|
|
then
|
|
|
|
export DO_STANDARD_REFIND_PATH=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f $EFI_PATH/EFI/BOOT/refind.conf ]]
|
|
|
|
then
|
|
|
|
export DO_BOOTX64_REFIND_PATH=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
REFIND_CMDLINE_OPTIONS="$(cat /boot/refind_linux.conf | cut -f4 -d"\"" | head -n1 | sed 's/---//g' | sed -E 's/root=[^ ]* //g')"
|
|
|
|
ROOT_PARTUUID="$(blkid -s PARTUUID -o value $(df -P -h -T / | awk 'END{print $1}'))"
|
|
|
|
|
|
|
|
if [[ -z "$ROOT_PARTUUID" ]]
|
|
|
|
then
|
|
|
|
echo "Current Root partition type doesn't support PARTUUID"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
create_entries() {
|
|
|
|
REFIND_PATH="$1"
|
|
|
|
grep -qxF 'include pika-refind-btrfs.conf' $EFI_PATH/$REFIND_PATH/refind.conf || echo 'include pika-refind-btrfs.conf' >> $EFI_PATH/$REFIND_PATH/refind.conf
|
|
|
|
rm -rfv $EFI_PATH/$REFIND_PATH/pika-refind-btrfs.conf || true
|
2024-12-11 00:51:29 +01:00
|
|
|
linux-version list | while read kernel_version
|
2024-12-11 00:39:24 +03:00
|
|
|
do
|
2024-12-11 00:51:09 +03:00
|
|
|
echo "Creating refind stanza for: $kernel_version"
|
2024-12-11 00:51:29 +01:00
|
|
|
echo -e "menuentry \"PikaOS Snapper Stanza - $kernel_version\" {\n icon /$REFIND_PATH/refind-dark/icons/os_pika.png\n volume \"PikaOS\"\n loader /vmlinuz-$kernel_version\n initrd /booster.img-$kernel_version\n options \"root=PARTUUID=$ROOT_PARTUUID $REFIND_CMDLINE_OPTIONS\"\n}\n" >> "$EFI_PATH/$REFIND_PATH/pika-refind-btrfs.conf"
|
2024-12-11 00:39:24 +03:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $DO_STANDARD_REFIND_PATH == true ]]
|
|
|
|
then
|
2024-12-11 00:51:09 +03:00
|
|
|
echo "Standard Refind Path Detected"
|
|
|
|
create_entries "EFI/refind"
|
2024-12-11 00:39:24 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $DO_BOOTX64_REFIND_PATH == true ]]
|
|
|
|
then
|
2024-12-11 00:51:09 +03:00
|
|
|
echo "Bootx64 Refind Path Detected"
|
|
|
|
create_entries "EFI/BOOT"
|
|
|
|
fi
|