From 8e6582b18989d7749158b6bad4b79e4245af09de Mon Sep 17 00:00:00 2001 From: Francis Rowe Date: Sat, 02 Jan 2016 12:29:53 -0500 Subject: grub.cfg: simplify isolinux parsing to a single function --- (limited to 'resources/grub/config/menuentries') diff --git a/resources/grub/config/menuentries/common.cfg b/resources/grub/config/menuentries/common.cfg index ef0bbef..3739b45 100644 --- a/resources/grub/config/menuentries/common.cfg +++ b/resources/grub/config/menuentries/common.cfg @@ -9,6 +9,16 @@ function switch_to_grub_config { fi done } +function parse_isolinux_config { + set root=${1} + for p in /isolinux /syslinux; do + if [ -f "${p}${p}.cfg" ]; then + syslinux_configfile -i ${p}${p}.cfg + elif [ -f "/boot${p}${p}.cfg" ]; then + syslinux_configfile -i /boot${p}${p}.cfg + fi + done +} menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { # GRUB handles (almost) every possible disk setup, but only the location of /boot is actually important, @@ -67,65 +77,24 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o menuentry 'Parse ISOLINUX menu (AHCI) [a]' --hotkey='a' { for i in 0 1; do # Check for filesystem on raw device without partition table (MBR/GPT), e.g. BTRFS or ZFS - set root=ahci${i} - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done + parse_isolinux_config ahci${i} # Look for partitions # GPT allows more than 4 partitions, /boot on /dev/sda7 is quite unlikely but still possible - for j in 0 1 2 3 4 5 6 7 8 9; do - set root="ahci${i},${j}" - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for j in 0 1 2 3 4 5 6 7 8 9; do parse_isolinux_config "ahci${i},${j}"; done done } menuentry 'Parse ISOLINUX menu (USB) [u]' --hotkey='u' { for i in 0 1; do # Check for filesystem on raw device without partition table (MBR/GPT), e.g. BTRFS or ZFS - set root=usb${i} - for p in /isolinux /syslinux; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done + parse_isolinux_config usb${i} # Look for partitions # GPT allows more than 4 partitions, /boot on /dev/sda7 is quite unlikely but still possible - for j in 0 1 2 3 4 5 6 7 8 9; do - set root=usb${i},${j} - for p in "/isolinux" "/syslinux"; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for j in 0 1 2 3 4 5 6 7 8 9; do parse_isolinux_config "usb${i},${j}"; done done } menuentry 'Parse ISOLINUX menu (CD/DVD) [d]' --hotkey='d' { insmod ata - for x in ata0 ahci1; do - set root=${x} - for p in "/isolinux" "/syslinux"; do - if [ -f "${p}${p}.cfg" ]; then - syslinux_configfile -i ${p}${p}.cfg - elif [ -f "/boot${p}${p}.cfg" ]; then - syslinux_configfile -i /boot${p}${p}.cfg - fi - done - done + for x in ata0 ahci1; do parse_isolinux_config ${x}; done } menuentry 'Switch to grubtest.cfg [t]' --hotkey='t' { set root=cbfsdisk -- cgit v0.9.1