aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Rowe <info@gluglug.org.uk>2016-01-02 17:15:14 +0000
committerFrancis Rowe <info@gluglug.org.uk>2016-01-02 17:15:14 +0000
commit818db48b4fa355255a87f76ae27f65b8fe1a7160 (patch)
treeb3daeba7a54cf5639ccfeaf48058be6358b2cf23
parent417361f8b794ffe433f1400e043c6bd6e9778ffc (diff)
downloadlibrebootfr-818db48b4fa355255a87f76ae27f65b8fe1a7160.tar.gz
librebootfr-818db48b4fa355255a87f76ae27f65b8fe1a7160.zip
grub.cfg: re-factor switching to grub.cfg to a function
-rw-r--r--resources/grub/config/menuentries/common.cfg61
1 files changed, 18 insertions, 43 deletions
diff --git a/resources/grub/config/menuentries/common.cfg b/resources/grub/config/menuentries/common.cfg
index b64b4deb..ef0bbefc 100644
--- a/resources/grub/config/menuentries/common.cfg
+++ b/resources/grub/config/menuentries/common.cfg
@@ -1,3 +1,14 @@
+function switch_to_grub_config {
+ set root="${1}"
+ # a) Check possible file locations...
+ for p in boot/grub/libreboot_ grub/libreboot_ boot/grub/ grub/ boot/grub2 grub2/; do
+ if [ -f "/${p}grub.cfg" ]; then
+ # b) And eventually try to load the config. Using ESC one can still exit and revert back to
+ # libreboot's menu.
+ configfile /${p}grub.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,
@@ -11,14 +22,10 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
# a) Try RAID first, they might be used (accross multiple (raw) devices)
# b) Try MBR/GPT partitions at last, one might still conviniently uses a single partition
- for d in md/0 ahci0 ahci1; do
- # prompt user for passphrase if LUKS header is found
- cryptomount ${d}
- done
+ # prompt user for passphrase if LUKS header is found
+ for d in md/0 ahci0 ahci1; do cryptomount ${d}; done
for j in 1 2 3 4 5 6 7 8 9; do
- for d in ahci0 ahci1; do
- cryptomount "${d},${j}"
- done
+ for d in ahci0 ahci1; do cryptomount "${d},${j}"; done
done
# (This way, we only need to scan for encrypted data once while covering every possible disk setup,
@@ -27,29 +34,9 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
# 2. Look for user config. If the above routine successfully decrypted a LUKS container, its content
# will be searched before everything else for obvious reasons. Regardless of this, the devices'
# hirachy stays the same.
- for d in crypto0 md/0 ahci0 ahci1; do
- set root="${d}"
- # a) Check possible file locations...
- for p in boot/grub/libreboot_ grub/libreboot_ boot/grub/ grub/ boot/grub2 grub2/; do
- if [ -f "/${p}grub.cfg" ]; then
- # b) And eventually try to load the config. Using ESC one can still exit and revert back to
- # libreboot's menu.
- configfile /${p}grub.cfg
- fi
- done
- done
+ for d in crypto0 md/0 ahci0 ahci1; do switch_to_grub_config ${d}; done
for j in 1 2 3 4 5 6 7 8 9; do
- for d in crypto0 ahci0 ahci1; do
- set root="${d},${j}"
- # a) Check possible file locations...
- for p in boot/grub/libreboot_ grub/libreboot_ boot/grub/ grub/ boot/grub2 grub2/; do
- if [ -f "/${p}grub.cfg" ]; then
- # b) And eventually try to load the config. Using ESC one can still exit and revert back to
- # libreboot's menu.
- configfile /${p}grub.cfg
- fi
- done
- done
+ for d in crypto0 ahci0 ahci1; do switch_to_grub_config "${d},${j}"; done
done
# prompt user for passphrase if LUKS header is found but try using external keyfiles first
@@ -63,20 +50,8 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
cryptomount ${kf} ${d}
done
# 3. Do the same routine again, but for possibly decrypted data this time.
- set root=crypto0
- for p in boot/grub/libreboot_ grub/libreboot_ boot/grub/ grub/ boot/grub2 grub2/; do
- if [ -f "/${p}grub.cfg" ]; then
- configfile /${p}grub.cfg
- fi
- done
- for j in 1 2 3 4 5 6 7 8 9; do
- set root=crypto0
- for p in boot/grub/libreboot_ grub/libreboot_ boot/grub/ grub/ boot/grub2 grub2/; do
- if [ -f "/${p}grub.cfg" ]; then
- configfile /${p}grub.cfg
- fi
- done
- done
+ switch_to_grub_config crypto0
+ for j in 1 2 3 4 5 6 7 8 9; do switch_to_grub_config "crypto0,${j}"; done
# 3. Last resort, if none of the above succeeds, all you have is GRUB's shell
set root=ahci0,1