From 3b66298ecfc91187bafa9f4f881cb364952a9827 Mon Sep 17 00:00:00 2001
From: livio <livio@codeberg.org>
Date: Tue, 2 Apr 2024 18:43:25 +0200
Subject: [PATCH] Reduced non-existent media errors at boot by using "test"
 function, added crypto medias to scan and cryptomount -a on media list

---
 config/grub/config/grub.cfg | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/config/grub/config/grub.cfg b/config/grub/config/grub.cfg
index 6c2e2fc8..138475ac 100644
--- a/config/grub/config/grub.cfg
+++ b/config/grub/config/grub.cfg
@@ -102,9 +102,8 @@ function list_lmedia {
 # Create menuitems that boot any valid previously detected media
 function make_boot_menus {
 	for i in ${tgt_medias}; do
-		if [ ! -d ${i}/ ]; then # Root is invalid: maybe unsupported FS or encrypted one
-			cryptomount ${i}
-		else
+		test -e ${i}
+		if [ $? == 0 ]; then # Media exists so we search there
 			grub_create_menu ${i} # Look for grub entries in known directories
 		fi
 		echo -n "."
@@ -114,7 +113,7 @@ function make_boot_menus {
 
 # Scan every physical media to make boot menus
 function scan_p_media_menus {
-	for i in ata ahci usb fd; do
+	for i in ata ahci usb crypto fd; do
 		echo -n "Scanning ${i}"
 		list_pmedia ${i}
 		make_boot_menus
@@ -132,6 +131,7 @@ function scan_l_media_menus {
 
 menuentry "List all bootable medias" {
 	mediadetect
+	cryptomount -a
 	scan_p_media_menus
 	scan_l_media_menus
 }
@@ -342,4 +342,4 @@ menuentry 'Load MemTest86+  [m]' --hotkey='m' {
 	set root='cbfsdisk'
 	chainloader /img/memtest
 }
-fi
+fi
\ No newline at end of file
-- 
GitLab