#------------------------------------------------------------------ # rescue menu configurations # #------------------------------------------------------------------ function find_efi_bootloader { if secure_boot; then find_shim_efi_bootloader else find_grub_efi_bootloader fi } function check_efi_bootloader { for E in (hd${H},${P})/EFI/*; do if ! test -d $E; then continue; fi efi_loader="$E/${grub_efi}" if ! test -s "$efi_loader"; then continue; fi efi_device="hd${H},${P}" regexp -s 1:efi_name ".*/EFI/(.*)/${grub_efi}" "${efi_loader}" #regexp -s 1:efi_device -s 2:efi_name -s 3:efi_ldr '^\((.*)\)/EFI/(.*)/(.*)' "${efi_loader}" found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"EFI Bootloader"" <===" {true} fi regexp -s efi_found '^(.........)' "(${efi_device}) " regexp -s name '^(............)' "${efi_name} " echo $"found EFI bootloader at"" ""${efi_found}: ${efi_name}" probe -s fs_type -f "(${efi_device})" probe -s label -l "(${efi_device})" menuentry --class=found.efi "${name} @$label ${efi_loader}" "${fs_type}" "${efi_device}" "${efi_loader}" { if [ -n "${2}" ]; then insmod "${2}" fi if [ -n "${3}" ]; then set root=(${3}) terminal_output console chainloader "${4}" fi } unset fs_type unset label unset name unset efi_device unset efi_loader done } function find_shim_efi_bootloader { if [ "$grub_platform" != "efi" ] ; then return ; fi submenu " "$"Shim-EFI bootloader" --class=efi_boot --hotkey=E --id 'find_efi_bootloader' { shim_efi_bootloader } } function shim_efi_bootloader { set last_chosen="$chosen"; found="false" found_one="" echo "" echo $"searching for Shim-EFI bootloader"" ..." if [ "$grub_cpu" = "x86_64" ]; then set efi_arc="x64" fi if [ "$grub_cpu" = "i386" ]; then set efi_arc="ia32" fi unset found_one if [ "$grub_cpu" = "x86_64" ]; then set grub_efi=shimx64.efi else set grub_efi=shim.efi fi d="0 1 2 3 4 5 6 7 8 9 10 11" p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" for H in $d; do for P in $p; do if ! test -d (hd$H,$P); then continue; fi fs_type="" probe -s fs_type -f "(hd${H},${P})" if [ "$fs_type" != "fat" ]; then continue; fi check_efi_bootloader done done if [ x"${found}" == x"true" ]; then echo "... "$"finished" echo -n $"Press »Enter« to continue"" " read key unset key back_to_main_menu else secure_boot_warning menuentry --hotkey=q --class=found.none $"No Shim-EFI bootloader found." {main_menu} fi unset d unset p } function find_grub_efi_bootloader { if [ "$grub_platform" != "efi" ] ; then return ; fi #if secure_boot; then return; fi submenu " "$"GRUB-EFI bootloader" --class=efi_boot --hotkey=E --id 'find_efi_bootloader' { grub_efi_bootloader } } function grub_efi_bootloader { set last_chosen="$chosen"; found="false" found_one="" echo "" echo $"searching for GRUB-EFI bootloader"" ..." if [ "$grub_cpu" = "x86_64" ]; then set efi_arc="x64" set g2bootmgr="gnugrub.kernel64.efi" set efi_bldrs="bootx64.efi shimx64.efi grubx64.efi systemd-bootx64.efi refind_x64.efi g2bootmgr/$g2bootmgr" elif [ "$grub_cpu" = "i386" ]; then set efi_arc="ia32" set g2bootmgr="gnugrub.kernel32.efi" set efi_bldrs="bootia32.efi grubia32.efi grub.efi systemd-bootia32.efi refind_ia32.efi g2bootmgr/$g2bootmgr" else return fi unset found_one set grub_efi=grub${efi_arc}.efi d="0 1 2 3 4 5 6 7 8 9 10 11" p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" for H in $d; do for P in $p; do if ! test -d (hd$H,$P); then continue; fi #set grub_efi=bootx64.efi #check_efi_bootloader #set grub_efi=systemd-bootx64.efi #check_efi_bootloader #set grub_efi=grub${efi_arc}.efi #check_efi_bootloader fs_type="" probe -s fs_type -f "(hd${H},${P})" if [ "$fs_type" == "fat" ]; then for E in (hd${H},${P})/EFI/*; do if ! test -d $E; then continue; fi for bld_efi in $efi_bldrs; do #efi_loader="$E/${grub_efi}" efi_loader="$E/${bld_efi}" if ! test -f "$efi_loader"; then continue; fi #if ! test -s "$efi_loader"; then continue; fi #echo "found "efi_loader="$efi_loader" efi_device="hd${H},${P}" regexp -s 1:efi_name ".*/EFI/(.*)/${bld_efi}" "${efi_loader}" #regexp -s 1:efi_device -s 2:efi_name -s 3:efi_ldr '^\((.*)\)/EFI/(.*)/(.*)' "${efi_loader}" found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"EFI Bootloader"" <===" {true} fi regexp -s efi_found '^(.........)' "(${efi_device}) " regexp -s name '^(............)' "${efi_name} " echo $"found EFI bootloader at"" ""${efi_found}: ${efi_name}" probe -s fs_type -f "(${efi_device})" #probe -s label -l "(${efi_device})" label="[fat]" # menuentry --class=found.efi "${name} @$label ${efi_loader}" "${fs_type}" "${efi_device}" "${efi_loader}" { if [ -n "${2}" ]; then insmod "${2}" fi if [ -n "${3}" ]; then set root=(${3}) fi terminal_output console chainloader "${4}" } unset fs_type unset label unset name unset efi_device unset efi_loader done # efi_bldrs done # /EFI/* fi set core_efi="${grub_cpu}-efi/grub.efi" for efi_loader in \ (hd${H},${P})/boot/grub/${core_efi} \ (hd${H},${P})/grub/${core_efi} \ (hd${H},${P})/${core_efi} \ (hd${H},${P})/grub2/g2bootmgr/${g2bootmgr}; do if secure_boot; then break; fi if ! test -f ${efi_loader}; then continue; fi #if ! test -s ${efi_loader}; then continue; fi efi_device="hd${H},${P}" found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"EFI Bootloader"" <===" {true} fi probe -s fs_type -f "(${efi_device})" efi_name="[no label]" probe -s efi_name -l "(${efi_device})" regexp -s efi_found '^(...............)' "(${efi_device}) " echo $"found EFI bootloader at"" ""${efi_found}: ${efi_name}" g2="" regexp -s g2 ".*(${g2bootmgr})" "${efi_loader}" if [ -n "$g2" ]; then set efi_name="Grub2Win"; fi unset g2 regexp -s name '^(............)' "${efi_name} " if [ "$fs_type" == "ext2" ]; then m_type="ext_"; else m_type="$fs_type"; fi menuentry --class=found.efi "${name} @[${m_type}] ${efi_loader}" "${fs_type}" "${efi_device}" "${efi_loader}" { if [ -n "${2}" ]; then insmod "${2}" fi if [ -n "${3}" ]; then set root=(${3}) terminal_output console chainloader "${4}" terminal_output gfxterm fi } done unset m_type unset fs_type unset efi_device unset efi_found unset efi_loader unset efi_name unset label unset name done done if [ x"${found}" == x"true" ]; then echo "... "$"finished" echo -n $"Press »Enter« to continue"" " read key unset key back_to_main_menu else secure_boot_warning menuentry --hotkey=q --class=found.none $"No EFI bootloader found." {main_menu} fi unset d unset p } function find_grub_bootloader { if [ "$grub_platform" != "pc" ] ; then return ; fi submenu " "$"GRUB bootloader" --class=grub.boot --hotkey=L --id 'find_grub_bootloader' { grub_bootloader } } function grub_bootloader { set last_chosen="$chosen"; found="false" found_one="" echo "" echo $"searching for GRUB bootloader"" ..." set g2bootmgr="gnugrub.kernel.bios" set core_img="${grub_cpu}-${grub_platform}/core.img" d="0 1 2 3 4 5 6 7 8 9 10 11" p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" for H in $d; do for P in $p; do if ! test -d (hd$H,$P); then continue; fi for grub in \ (hd${H},${P})/boot/grub/${core_img} \ (hd${H},${P})/grub/${core_img} \ (hd${H},${P})/${core_img} \ (hd${H},${P})/grub2/g2bootmgr/${g2bootmgr} do if ! test -s $grub; then continue; fi grub_device="hd${H},${P}" getdrive grub_drive $grub_device set found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"GRUB Bootloader"" <===" {true} fi unset grub_label probe -s grub_label -l ($grub_device) if [ -z "$grub_label" ] ; then set grub_label="[no label]"; fi regexp -s grub_found '^(........)' "(${grub_device}) " echo $"found GRUB bootloader at"" " "${grub_found}: ${grub_label}" unset fs_type probe -s fs_type -f "($grub_device)" menuentry --class=found.grub " "$"GRUB loader"" @ ${grub_found} ${grub_label}" "${fs_type}" "${grub_device}" "${grub}" { if [ -n "${2}" ]; then insmod "${2}" fi insmod multiboot set root=(${3}) multiboot ${4} set prefix="$boot_prefix" set root="$boot_root" } done done done if [ "${found}" != "true" ]; then menuentry --hotkey=Q --class=found.none $"No GRUB bootloader found." {main_menu} else echo "... "$"finished" echo -n $"Press »Enter« to continue"" " read key unset key back_to_main_menu fi unset d unset p unset H unset P } function find_grub_menus { submenu " "$"GRUB menus" --class=grub.menu --hotkey=M --id 'find_grub_menus' { grub_menus } } function grub_menus { set last_chosen="$chosen"; unset chosen found="false" set found_one="" echo "" echo $"searching for GRUB menus"" ..." d="0 1 2 3 4 5 6 7 8 9 10 11" p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" for H in $d; do for P in $p; do if ! test -d (hd$H,$P); then continue; fi for grub in \ (hd${H},${P})/boot/grub/grub.cfg \ (hd${H},${P})/grub/grub.cfg \ (hd${H},${P})/grub.cfg do if ! test -s "$grub"; then continue; fi grub_device="hd${H},${P}" if [ "$grub" = "(hd${H},${P})/boot/grub/grub.cfg" ]; then grub_prefix="/boot/grub" elif [ "$grub" = "(hd${H},${P})/grub/grub.cfg" ]; then grub_prefix="/grub" elif [ "$grub" = "(hd${H},${P})/grub.cfg" ]; then grub_prefix="" else continue fi found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"GRUB Menus"" <===" {true} fi unset grub_label probe -s grub_label -l ($grub_device) if [ -z "$grub_label" ] ; then set grub_label="[No Label]"; fi regexp -s grub_found '^(.........)' "(${grub_device}) " if secure_boot; then grub_found="(${grub_device})" grub_label="" fi echo $"found GRUB menu on"" ${grub_found}: ${grub_label}" unset fs_type probe -s fs_type -f "($grub_device)" menuentry --class=found.grub " "$"GRUB menu"" @ ${grub_found} ${grub_label}" "${fs_type}" "${grub_device}" "${grub_prefix}" "${grub}" { unset theme terminal_output console terminal_output gfxterm background_image have_defaults= have_options= have_grubenv= theme_loaded= if [ -n "${2}" ]; then insmod "${2}" fi if [ -n "${3}" ]; then set root="${3}" set prefix=($root)$4 fi configfile ${5} set prefix="$boot_prefix" set root=$boot_root configfile $prefix/grub.cfg main_menu } done done done if [ "${found}" != "true" ]; then secure_boot_warning menuentry --hotkey=q --class=found.none $"No GRUB CFG-Menu found." {main_menu} else echo "... "$"finished" echo -n $"Press »Enter« to continue"" " read key unset key back_to_main_menu fi unset d unset n unset H unset P unset grub } function find_frugal_menus { submenu " "$"Frugal menus" --class=frugal.boot --hotkey=F --id 'find_frugal_menus' { frugal_menus } } function frugal_menus { set last_chosen="$chosen"; unset chosen found="false" set found_one="" echo "" echo $"searching for Frugal grub.entry menus"" ..." d="0 1 2 3 4 5 6 7 8 9 10 11" p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" for H in $d; do for P in $p; do if ! test -d (hd$H,$P); then continue; fi frugal_device="hd${H},${P}" unset fs_type probe -s fs_type -f "($frugal_device)" for dir in (hd${H},${P})/?????*; do if [ "$dir" == "(hd${H},${P})/?????*" ]; then continue; fi if ! test -d "$dir"; then continue; fi if [ "$dir" == "(hd${H},${P})/lost+found" ]; then continue; fi grub="$dir/grub.entry" if ! test -s "$grub"; then continue; fi found=true if [ -z "$found_one" ]; then set found_one="y" menuentry " ===> "$"Frugal Menus"" <===" {true} fi unset frugal_label probe -s frugal_label -l ($frugal_device) if [ -z "$frugal_label" ] ; then set frugal_label="[No Label]"; fi frugal_dir="" regexp -s frugal_dir '^.*(/.*)/grub.entry' "${grub}" regexp -s frugal_found '^(.........)' "(${frugal_device}) " echo $"found Frugal menu at"" ${frugal_found}: ${frugal_label} $frugal_dir" menuentry --class=found.frugal " "$"Frugal menu"" @ ${frugal_found} ${frugal_label}: $frugal_dir" "${fs_type}" "${frugal_device}" "${grub}" { if [ -n "${2}" ]; then insmod "${2}" fi set od=$default set default=0 export default if [ -z "$frugal_timeout" ]; then frugal_timeout=60; fi eval timeout=$frugal_timeout export timeout configfile "${4}" set prefix="$boot_prefix" set root="$boot_root" eval "timeout=60" set default=$od unset od } done done done if [ "${found}" != "true" ]; then secure_boot_warning menuentry --hotkey=q --class=found.none $"No Frugal menu found." {main_menu} else echo "... "$"finished" echo -n $"Press »Enter« to continue"" " read key unset key back_to_main_menu fi unset d unset n unset H unset P unset dir unset grub } function secure_boot_warning { if ! secure_boot; then return; fi menuentry --class=secure.boot_warning " *** "$"Secure Boot Restrictions"" ***" {true} } function uefi_fw_setup { if [ "$grub_platform" != "efi" ] ; then return ; fi menuentry " "$"Reboot into BIOS/UEFI Setup" --class=efi_fw_setup {fwsetup} } #---------------------------------------------------------------------- # not used #---------------------------------------------------------------------- # function find_bootisos { # submenu " "$"ISO-Boot menus" --class=isoboot.menu --id 'find_isos' { # #iso_menus # #} # #} # # #function iso_menus { # set last_chosen="$chosen"; # unset chosen # found="false" # set found_one="" # echo "" # echo $"searching for Boot-ISO's"" ..." # d="0 1 2 3 4 5 6 7 8 9 10 11" # p="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" # for H in $d; do # for P in $p; do # D="hd$H,$P" # if ! test -d ($D); then continue; fi # for iso in ($D)/bootisos/*.iso ($D)/snapshot/*.iso # do # if [ "$iso" == "($D)/bootisos/*.iso" ]; then continue; fi # if [ "$iso" == "($D)/snapshot/*.iso" ]; then continue; fi # iso_device="$D" # # found=true # if [ -z "$found_one" ]; then # set found_one="y" # menuentry " ===> "$"ISO-Boot Menus"" <===" {true} # fi # # unset iso_label # probe -s iso_label -l ($iso_device) # if [ -z "$iso_label" ] ; then set iso_label="[No Label]"; fi # regexp -s iso_found '^(.........)' "(${iso_device}) " # if secure_boot; then # iso_found="(${iso_device})" # iso_label="" # fi # regexp -s iso_path '(/bootisos/.*.iso)' "${iso}" # regexp -s iso_name '/bootisos/(.*.iso)' "${iso_path}" # # echo $"found iso menu on"" ${iso_found}: ${iso_label}" # unset fs_type # probe -s fs_type -f "($iso_device)" # # menuentry --class=found.iso " "$"iso menu"" @ ${iso_found} ${iso_path}" "${fs_type}" "${iso_device}" "${iso_prefix}" "${iso_path}" "$kopts" { # # if [ -n "${2}" ]; then # insmod "${2}" # fi # set root="${3}" # iso_path="${5}" # iso_kopts="${6}" # export iso_path # loopback loop1 $iso_path # if [ -s (loop1)/boot/grub/loopback.cfg ]; then # unset theme # terminal_output console # terminal_output gfxterm # background_image # # set root=(loop1) # set prefix=($root)/boot/grub # configfile $prefix/loopback.cfg # elif [ -s (loop1)/antiX/vmlinuz -a -s (loop1)/antiX/initrd.gz ]; then # probe -s iso_buuid -u ($root) # linux (loop1)/antiX/vmlinuz buuid=${iso_buuid} fromiso=${iso_path} quiet splasht nosplash disable=lxF $iso_kopts # initrd (loop1)/antiX/initrd.gz # fi # # set prefix="$boot_prefix" # set root="$boot_root" # main_menu # } # done # done # done # if [ "${found}" != "true" ]; then # secure_boot_warning # menuentry --hotkey=q --class=found.none $"No ISO found." {main_menu} # else # echo "... "$"finished" # echo -n $"Press »Enter« to continue"" " # read key # unset key # back_to_main_menu # fi # unset d # unset n # unset H # unset P # unset iso # } # } #---------------------------------------------------------------------- function check_loopback { if [ "$root" = "loop" -o "$root" = "loop1" ]; then have_defaults= have_grubenv= have_options= theme_loaded= fi } function boot_rescue_menus { submenu " "$"Boot Rescue Menus" --class=grub_rescue --hotkey=B --id 'boot_rescue_menus' "$VERSION" { set version="$2" set show_version="" if [ -n "$version" ]; then set show_version="("$"version"" $version)" fi set last_chosen="$chosen" menu_color_normal="$default_color_normal" menu_color_highlight="$default_color_highlight" menuentry " ===> "$"Boot Rescue Menus"" <=== ${show_version}" {true} secure_boot_warning find_efi_bootloader if ! secure_boot; then find_grub_bootloader fi find_grub_menus find_frugal_menus find_windows_bootloader #find_bootisos menuentry " "$"Reboot" --hotkey=R --class=reboot {reboot} menuentry " "$"Power Off" --hotkey=P --class=halt {halt} uefi_fw_setup back_to_main_menu } }