Update
This commit is contained in:
parent
49e2004055
commit
8539911bfb
|
@ -8,36 +8,84 @@ function check_root {
|
|||
|
||||
check_root
|
||||
|
||||
ESP_PATH=$(bootctl --print-esp-path)
|
||||
echo $ESP_PATH
|
||||
echo "Searching rEFInd installation in EFI partition..."
|
||||
if ! __has_esp__; then
|
||||
echo "EFI partition not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ESP_PATH" ]; then
|
||||
# Copied from https://raw.githubusercontent.com/jaltuna/refind-theme-nord/main/setup.sh
|
||||
# Verify EFI System Partition
|
||||
__has_esp__() {
|
||||
__find_esp__
|
||||
|
||||
mount "${ESP}" &>/dev/null
|
||||
[[ -d "${ESP}/EFI" ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
__find_esp__() {
|
||||
local parttype
|
||||
local fstype
|
||||
local device
|
||||
|
||||
while read -r device; do
|
||||
read -r parttype fstype ESP <<<"$(lsblk -o "PARTTYPE,FSTYPE,MOUNTPOINT" "$device" 2>/dev/null | awk 'NR==2')"
|
||||
|
||||
[[ "${parttype,,}" != "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]] && continue
|
||||
[[ "${fstype,,}" != "vfat" ]] && continue
|
||||
[[ -z $(findmnt -sn "${ESP}") ]] && continue
|
||||
|
||||
done <<<"$(fdisk -l 2>/dev/null | grep -i efi | cut -d " " -f 1)"
|
||||
|
||||
if [ -z "${ESP}" ]; then
|
||||
ESP=$(grep -i "/efi" /etc/fstab | awk '{print $2}')
|
||||
if [ -z "${ESP}" ]; then
|
||||
ESP=$(grep -i "/boot" /etc/fstab | awk '{print $2}')
|
||||
if [ -z "${ESP}" ]; then
|
||||
ESP=$(bootctl --print-esp-path)
|
||||
if [ -z "${ESP}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Found ${ESP}"
|
||||
readonly ESP
|
||||
}
|
||||
|
||||
|
||||
REFIND_DIR=$(find "${ESP}" -type d -iname refind)
|
||||
if ! [[ -d "${REFIND_DIR}" ]]; then
|
||||
echo "rEFInd not installed in ${ESP}" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Found rEFInd in ${REFIND_DIR}"
|
||||
|
||||
|
||||
if [ -z "${ESP}" ]; then
|
||||
exit 1
|
||||
else
|
||||
|
||||
if [ ! -d "${ESP_PATH}/EFI/Linux" ]; then
|
||||
if [ -d "${ESP_PATH}/EFI/linux" ]; then
|
||||
KERNEL_DIR="${ESP_PATH}/EFI/linux"
|
||||
if [ ! -d "${ESP}/EFI/Linux" ]; then
|
||||
mkdir -p "${ESP}/EFI/Linux"
|
||||
if [ -d "${ESP}/EFI/linux" ]; then
|
||||
KERNEL_DIR="${ESP}/EFI/linux"
|
||||
fi
|
||||
else
|
||||
KERNEL_DIR="${ESP_PATH}/EFI/Linux"
|
||||
fi
|
||||
|
||||
if [ -z "$KERNEL_DIR" ]; then
|
||||
mkdir -p "${ESP_PATH}/EFI/Linux"
|
||||
KERNEL_DIR="${ESP_PATH}/EFI/linux"
|
||||
KERNEL_DIR="${ESP}/EFI/Linux"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
echo $KERNEL_DIR
|
||||
echo "Found $KERNEL_DIR"
|
||||
|
||||
theme=$(cat "$ESP_PATH/EFI/refind/refind.conf" | grep themes | cut -d"/" -f2)
|
||||
theme=$(cat "${ESP}/EFI/refind/refind.conf" | grep themes | cut -d"/" -f2)
|
||||
|
||||
if [ -d $KERNEL_DIR ]; then
|
||||
|
||||
if [ -f "$ESP_PATH/EFI/Linux/cmdline.txt" ]; then
|
||||
CMDLINE=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' "$ESP_PATH/EFI/Linux/cmdline.txt")
|
||||
if [ -f "${ESP}/EFI/Linux/cmdline.txt" ]; then
|
||||
CMDLINE=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' "${ESP}/EFI/Linux/cmdline.txt")
|
||||
elif [ -f "/etc/kernel/cmdline" ]; then
|
||||
CMDLINE=$(sed -e 's/^[[:space:]]//g' -e 's/[[:space:]]$//g' "/etc/kernel/cmdline")
|
||||
else
|
||||
|
@ -50,7 +98,7 @@ if [ -d $KERNEL_DIR ]; then
|
|||
|
||||
template="/etc/refind-menu-generator/menu-template.txt"
|
||||
|
||||
for i in $(ls -1 /efi/EFI/Linux/ | grep 'linu' | grep -v 'fallback' | grep '\.efi$');
|
||||
for i in $(ls -1 "${ESP}/EFI/Linux/" | grep 'linu' | grep -v 'fallback' | grep '\.efi$');
|
||||
do
|
||||
kernel=$(echo $i | sed 's/\.efi//g')
|
||||
kernel_efi=$kernel
|
||||
|
@ -74,8 +122,11 @@ if [ -d $KERNEL_DIR ]; then
|
|||
|
||||
cat $manual_end_conf >> $manual_conf
|
||||
|
||||
sudo cp -vf $manual_conf "$ESP_PATH/EFI/refind/manual.conf"
|
||||
sudo cp -vf $manual_conf "$ESP_PATH/EFI/boot/manual.conf"
|
||||
cp -vf $manual_conf "${ESP}/EFI/refind/manual.conf"
|
||||
|
||||
if [ -d "${ESP}/EFI/boot" ]; then
|
||||
cp -vf $manual_conf "${ESP}/EFI/boot/manual.conf"
|
||||
fi
|
||||
|
||||
rm -f $manual_conf
|
||||
rm -f $manual_end_conf
|
||||
|
|
Loading…
Reference in New Issue