Skip to content
Snippets Groups Projects
Commit da44f929 authored by livio's avatar livio Committed by Libreboot project
Browse files

Created routines for automatic generation of boot menu items from every scanned media.

parent 05bafde3
Branches
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ function list_pmedia {
done
done
done
echo $tgt_medias
#echo $tgt_medias
}
set lvmnames="crypt-bootvol crypt-rootvol crypt-boot crypt-root grubcrypt-bootvol grubcrypt-rootvol"
......@@ -85,20 +85,42 @@ function list_lmedia {
done
done
done
echo $tgt_medias
#echo $tgt_medias
}
mediadetect
menuentry "Media detection test" {
cryptomount -a -p assword
#list_pmedia ata
list_lmedia lvm
# Create menuitems that boot any valid previously detected media
function make_boot_menus {
for i in ${tgt_medias}; do
grub_create_menu ${i}
echo -n "."
done
echo
}
# Scan every physical media to make boot menus
function scan_p_media_menus {
for i in ata ahci usb fd; do
echo -n "Scanning ${i}"
list_pmedia ${i}
make_boot_menus
done
}
# Scan every logical media to make boot menus
function scan_l_media_menus {
for i in lvm md; do
echo -n "Scanning ${i}"
list_lmedia ${i}
make_boot_menus
done
}
menuentry "List all bootable medias" {
mediadetect
scan_p_media_menus
scan_l_media_menus
}
# FIXME Make an automatic override for BTRFS directories instead of copypasting with a "@/" in front of every element
# Default list of GRUB possible directories. The @/... entries are for cases where the BTRFS filesystem is being used
......@@ -106,25 +128,30 @@ set grub_dirs="boot grub grub2 boot/grub boot/grub2 @/boot @/grub @/grub2 @/boot
# Default list of GRUB possible config files prefixes
set grub_conf_names="'' osboot_ autoboot_ libreboot_ coreboot_"
# Creates a menuentry for GRUB. First argument is menu text without spaces then root and configfile
function grub_menuentry {
menuentry ${1} ${2} ${3} {
set root="${2}"
unset superusers
configfile ${3}
}
}
function grub_create_menu {
echo "[GRUB] Looking on ${1}"
set root="${1}"
# The @/... entries are for cases where the BTRFS filesystem is being used
if [ ! -d / ]; then # Root is invalid: maybe unknown FS or encrypted one
cryptomount ${1}
return;
fi
for dir in ${grub_dirs}; do
# In order to save time, we do not attempt anything on non existing directory.
if [ -d / ]; then
if [ -d /"${dir}"/ ]; then
for name in '' ${grub_conf_names}; do
if [ -f /"${dir}"/"${name}"grub.cfg ]; then
menuentry "${1} load GRUB" ${1} /"${dir}"/"${name}"grub.cfg {
set root="${2}"
unset superusers
configfile ${3}
}
grub_menuentry ${1}:GRUB ${1} /${dir}/${name}grub.cfg
fi
done
fi
fi
done
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment