diff --git a/samples/grubfm.cfg b/samples/grubfm.cfg
index 64fb962a..49fb80fa 100644
--- a/samples/grubfm.cfg
+++ b/samples/grubfm.cfg
@@ -1,5 +1,5 @@
-# Grub2-FileManager
-# Copyright (C) 2016,2017,2018 A1ive.
+# Simple GRUB2-FileManager
+# Copyright (C) 2016,2017,2018,2019 A1ive.
#
# Grub2-FileManager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,199 +14,327 @@
# You should have received a copy of the GNU General Public License
# along with Grub2-FileManager. If not, see .
-function grubfm_init {
- insmod loopback;
- insmod probe;
- insmod progress;
- insmod regexp;
- set debug= ;
- set enable_progress_indicator=0;
- set grub_exe="/boot/grub/grub.exe";
- set grub_fm="/boot/grub/grubfm.cfg";
- set grub_ipxe="/boot/grub/ipxe.lkrn";
- set grub_memdisk="/boot/grub/memdisk";
- set grub_wimboot="/boot/grub/wimboot";
- set pager=0;
+function grubfm_init
+{
+ echo " _____ _ ______ __ __ ";
+ echo " / ____| | | | ____|| \/ |";
+ echo "| | __ _ __ _ _ | |__ | |__ | \ / |";
+ echo "| | |_ || '__|| | | || '_ \ | __| | |\/| |";
+ echo "| |__| || | | |_| || |_) || | | | | |";
+ echo " \_____||_| \__,_||_.__/ |_| |_| |_|";
+ echo "┌──────────────────────────────────────────┐";
+ echo "│ Copyright © 2016-2019 a1ive │";
+ echo "└──────────────────────────────────────────┘";
+ set modlist="blocklist expr getkey linux loopback probe progress regexp sleep vhd";
+ if [ "$grub_platform" = "efi" ]; then
+ set modlist="${modlist} efiload linuxefi sbpolicy";
+ if [ "$grub_cpu" = "x86_64" ]; then
+ set modlist="${modlist} map wimboot";
+ elif [ "$grub_cpu" = "i386" ]; then
+ set modlist="${modlist} wimboot";
+ else
+ echo "[ERR] Unsupported cpu: ${grub_cpu}";
+ echo "[INF] Press any key to reboot ...";
+ getkey;
+ reboot;
+ fi;
+ elif [ "$grub_platform" = "pc" ]; then
+ set modlist="${modlist} drivemap vboot";
+ else
+ echo "[ERR] Unsupported platform: ${grub_platform}";
+ echo "[INF] Press any key to reboot ...";
+ getkey;
+ reboot;
+ fi;
+ for module in $modlist; do
+ echo -n "[INF] Loading ${module}.mod ... ";
+ insmod $module;
+ echo "OK";
+ done;
+ echo "[INF] Setting up environment variables";
+ export debug= ;
+ export pager=0;
+ export enable_progress_indicator=0;
+ export grub_disable_esc=1;
+ export grub_exe="${prefix}/grub.exe";
+ export grub_vboot="${prefix}/vboot";
+ export grub_vbootcore="${prefix}/vbootcore.mod";
+ export grub_wimboot="${prefix}/wimboot";
+ export grub_bootmgr="${prefix}/bootmgr";
+ export grub_bootmgfw="${prefix}/bootmgfw.${grub_cpu}.efi";
+ export grub_bootsdi="${prefix}/boot.sdi";
+ export grub_biosbcd="${prefix}/bios_bcd";
+ export grub_uefibcd="${prefix}/uefi_bcd";
+ sleep 1;
+}
+
+function enum_device
+{
+ for device in (*); do
+ if test -d "${device}"; then
+ probe --set=fs -f -q "${device}";
+ probe --set=label -l -q "${device}";
+ if regexp 'loop' "${device}"; then
+ continue;
+ elif test "${device}" = "(memdisk)" -o "${device}" = "(proc)"; then
+ continue;
+ fi;
+ menuentry "${device} [$fs] $label" "${device}" {
+ grubfm_main "${2}";
+ }
+ unset label;
+ unset fs;
+ fi;
+ done;
+}
+
+function enum_file
+{
+ for item in ${grub_path}/*; do
+ regexp --set=1:name '.*/(.*)$' "${item}";
+ if test -d "${item}"; then
+ echo "[DBG] ADD DIR ${name}";
+ menuentry "[${name}]" "${item}" {
+ grubfm_main "${2}";
+ }
+ fi;
+ done;
+ for item in ${grub_path}/*; do
+ regexp --set=1:name '.*/(.*)$' "${item}";
+ if test -f "${item}"; then
+ echo "[DBG] ADD FILE ${name}";
+ menuentry "${name}" "${item}" {
+ grubfm_open "${2}";
+ }
+ fi;
+ done;
}
# grubfm_main PATH
-function grubfm_main {
- if test -z "${1}"; then
- for device in (*); do
- if test -d "${device}"; then
- probe --set=fs -f "${device}";
- probe --set=label -l "${device}";
- if regexp 'loop' "${device}"; then
- continue;
- elif test "$fs" = "udf" -o "$fs" = "iso9660"; then
- icon="iso";
- elif test "${device}" = "(memdisk)" -o "${device}" = "(proc)"; then
- continue;
- else
- icon="hdd";
- fi;
- menuentry "${device} [$fs] $label" "${device}" --class $icon{
- set grub_path="$2";
- set grub_load="";
- export grub_path;
- configfile ${grub_fm};
- }
- unset label;
- unset fs;
- fi;
- done;
- else
- set grub_path="${1}";
- set default=1;
- menuentry ".." --class go-previous{
- if ! regexp --set=1:grub_path '(^.*)/.*$' "${grub_path}"; then
- set grub_path="";
- fi
- set grub_load="";
- export grub_path;
- configfile ${grub_fm};
- }
- for item in ${grub_path}/*; do
- regexp --set=1:name '.*/(.*)$' "${item}";
- if test -d "${item}"; then
- menuentry "[${name}]" "${item}" --class dir{
- set grub_path="$2";
- set grub_load="";
- export grub_path;
- configfile ${grub_fm};
- }
- elif test -f "${item}"; then
- menuentry "${name}" "${item}" --class file{
- set grub_file="$2";
- set grub_load="grubfm_open";
- export grub_file;
- export grub_path;
- export grub_load;
- configfile ${grub_fm};
- }
- else
- continue;
- fi;
- done;
- fi;
+function grubfm_main
+{
+ echo "[DBG] grubfm_main ${1}";
+ clear_menu;
+ if [ -z "${1}" ]; then
+ enum_device;
+ else
+ export grub_path="${1}";
+ set default=1;
+ menuentry ".." {
+ if ! regexp --set=1:grub_path '(^.*)/.*$' "${grub_path}"; then
+ export grub_path="";
+ fi
+ export grub_path;
+ grubfm_main "${grub_path}";
+ }
+ enum_file;
+ fi;
}
+
+# file menu
+function menu_cfg
+{
+ regexp --set=1:root '^\(([0-9a-zA-Z,]+)\).*$' "${grub_file}";
+ configfile "${grub_file}";
+}
+
+function menu_efi_chain
+{
+ set enable_progress_indicator=1;
+ chainloader -b -t "${grub_file}";
+ set enable_progress_indicator=0;
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_efi_load
+{
+ efiload "${grub_file}";
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_img_bios_fd
+{
+ set enable_progress_indicator=1;
+ echo "[INF] Loading, please wait ...";
+ set cmd="map --mem (rd)+1 (fd0);map --hook;rootnoverify (fd0);chainloader +1"
+ linux16 ${grub_exe} --config-file=$cmd;
+ initrd16 "${grub_file}";
+}
+
+function menu_img_bios_hd
+{
+ set enable_progress_indicator=1;
+ echo "[INF] Loading, please wait ...";
+ set cmd="map --mem (rd)+1 (hd-1);map --hook;rootnoverify (hd-1);chainloader +1";
+ linux16 ${grub_exe} --config-file=$cmd;
+ initrd16 "${grub_file}";
+}
+
+function menu_img_uefi_map
+{
+ map "${grub_file}";
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_img_uefi_mapmem
+{
+ map --mem "${grub_file}";
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_iso_loop
+{
+ regexp --set=1:iso_path '(/.*)$' "${grub_file}";
+ regexp --set=1:iso_device '^(\([0-9a-zA-Z,]+\))/.*' "${grub_file}";
+ probe --set=rootuuid -u "${iso_device}";
+ echo "[DBG] UUID: ${rootuuid} PATH: ${iso_path}";
+ export iso_path;
+ export rootuuid;
+ set root=loop;
+ configfile /boot/grub/loopback.cfg
+}
+
+function menu_iso_bios_map
+{
+ set enable_progress_indicator=1;
+ echo "[INF] Loading, please wait ...";
+ set cmd="map --mem (rd)+1 (0xff);map --hook;chainloader (0xff)";
+ linux16 ${grub_exe} --config-file=$cmd;
+ initrd16 "${grub_file}";
+}
+
+function menu_iso_uefi_map
+{
+ map --type=CD "${grub_file}";
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_vhd_bios_vboot
+{
+ regexp --set=1:vhd_path '(/.*)$' "${grub_file}";
+ regexp --set=1:vhd_device '^(\([0-9a-zA-Z,]+\))/.*' "${grub_file}";
+ probe --set=dev_uuid -u "${vhd_device}";
+ echo "[DBG] UUID: ${dev_uuid} PATH: ${vhd_path}";
+ set vbootloader=${grub_vboot};
+ vbootinsmod ${grub_vbootcore};
+ vboot harddisk=(UUID=${dev_uuid})${vhd_path};
+}
+
+function menu_vhd_uefi_map
+{
+ vhd -d vhd0;
+ vhd -p vhd0 "${grub_file}";
+ map --mem --type=HD --disk vhd0;
+ echo "[INF] Press any key to continue ...";
+ getkey;
+}
+
+function menu_wim
+{
+ if [ "$grub_platform" = "pc" ]; then
+ set enable_progress_indicator=1;
+ echo "[INF] Loading, please wait ...";
+ linux16 ${grub_wimboot} gui;
+ initrd16 newc:bootmgr:${grub_bootmgr} \
+ newc:bcd:${grub_biosbcd} \
+ newc:boot.sdi:${grub_bootsdi} \
+ newc:boot.wim:"${grub_file}";
+ elif [ "$grub_platform" = "efi" ]; then
+ set enable_progress_indicator=1;
+ wimboot @:bootmgfw.efi:${grub_bootmgfw} \
+ @:bcd:${grub_uefibcd} \
+ @:boot.sdi:${grub_bootsdi} \
+ @:boot.wim:"${grub_file}";
+ fi;
+}
+
+function add_back_menu
+{
+ set default=1;
+ menuentry "返回" {
+ grubfm_main "${grub_path}";
+ }
+}
+
# grubfm_open FILE
-function grubfm_open {
- unset name;
- unset name_ext;
- set grub_file="${1}";
- set grub_load="";
- regexp --set=1:name '.*/(.*)$' "${grub_file}";
- regexp --set=1:name_ext '^.*\.(.*$)' "${grub_file}";
- set default=1;
- menuentry "返回" --class go-previous{
- set grub_load="";
- export grub_path;
- configfile ${grub_fm};
- }
- # cfg efi ima/img iso wim ipxe
- if regexp '^[cC][fF][gG]$' "${name_ext}"; then
- menuentry "加载GRUB2菜单" --class cfg{
- regexp --set=1:root '^\(([0-9a-zA-Z,]+)\).*$' "${grub_file}";
- configfile ${grub_file};
- }
- elif regexp '^[eE][fF][iI]$' "${name_ext}"; then
- if [ "$grub_platform" = "efi" ]; then
- menuentry "运行EFI程序" --class uefi{
- set enable_progress_indicator=1;
- regexp --set=1:root '^\(([0-9a-zA-Z,]+)\).*$' "${grub_file}";
- chainloader ${grub_file};
- }
- fi;
- elif regexp '^[iI][mM][aAgG]$' "${name_ext}"; then
- if [ "$grub_platform" = "pc" ]; then
- menuentry "仿真启动软盘镜像 (grub.exe)" --class img{
- set enable_progress_indicator=1;
- set g4d_cmd="map --mem (rd)+1 (fd0);map --hook;rootnoverify (fd0);chainloader +1"
- linux16 ${grub_exe} --config-file=$g4d_cmd;
- initrd16 ${grub_file};
- }
- menuentry "仿真启动软盘镜像 (memdisk)" --class img{
- set enable_progress_indicator=1;
- linux16 ${grub_memdisk} floppy raw;
- initrd16 ${grub_file};
- }
- menuentry "仿真启动硬盘镜像 (grub.exe)" --class img{
- set enable_progress_indicator=1;
- set g4d_cmd="map --mem (rd)+1 (hd-1);map --hook;rootnoverify (hd-1);chainloader +1"
- linux16 ${grub_exe} --config-file=$g4d_cmd;
- initrd16 ${grub_file};
- }
- menuentry "仿真启动硬盘镜像 (memdisk)" --class img{
- set enable_progress_indicator=1;
- linux16 ${grub_memdisk} harddisk raw;
- initrd16 ${grub_file};
- }
- fi;
- elif regexp '^[iI][sS][oO]$' "${name_ext}"; then
- loopback loop ${grub_file};
- if test -f (loop)/boot/grub/loopback.cfg; then
- menuentry "加载ISO Loopback菜单" --class gnu-linux{
- regexp --set=1:iso_path '(/.*)$' "${grub_file}";
- regexp --set=1:iso_device '^(\([0-9a-zA-Z,]+\))/.*' "${grub_file}";
- probe --set=rootuuid -u "${iso_device}";
- export iso_path;
- export rootuuid;
- set root=loop;
- configfile /boot/grub/loopback.cfg
- }
- fi;
- if [ "$grub_platform" = "pc" ]; then
- menuentry "仿真启动光盘镜像 (grub.exe)" --class iso{
- set enable_progress_indicator=1;
- set g4d_cmd="map --mem (rd)+1 (0xff);map --hook;chainloader (0xff)"
- linux16 ${grub_exe} --config-file=$g4d_cmd;
- initrd16 ${grub_file};
- }
- menuentry "仿真启动光盘镜像 (memdisk)" --class iso{
- set enable_progress_indicator=1;
- linux16 ${grub_memdisk} iso raw;
- initrd16 ${grub_file};
- }
- fi;
- elif regexp '^[wW][iI][mM]$' "${name_ext}"; then
- if [ "$grub_platform" = "pc" ]; then
- menuentry "启动 NT6 WIM" --class wim{
- set enable_progress_indicator=1;
- loopback wimboot ${grub_wimboot};
- linux16 (wimboot)/wimboot gui;
- initrd16 newc:bootmgr:(wimboot)/bootmgr \
- newc:bcd:(wimboot)/bcd \
- newc:boot.sdi:(wimboot)/boot.sdi \
- newc:boot.wim:${grub_file};
- }
- fi;
- elif regexp '^[iI][pP][xX][eE]$' "${name_ext}"; then
- if [ "$grub_platform" = "pc" ]; then
- menuentry "加载iPXE菜单" --class net{
- set enable_progress_indicator=1;
- linux16 ${grub_ipxe};
- initrd16 ${grub_file};
- }
- fi;
- elif file --is-x86-multiboot "${grub_file}"; then
- menuentry "启动Multiboot内核" --class exe{
- multiboot "${grub_file}";
- }
- elif file --is-x86-multiboot2 "${grub_file}"; then
- menuentry "启动Multiboot2内核" --class exe{
- multiboot2 "${grub_file}";
- }
- elif file --is-x86-linux "${grub_file}"; then
- menuentry "启动Linux内核" --class exe{
- linux "${grub_file}";
- }
- fi;
+function grubfm_open
+{
+ echo "[DBG] grubfm_open ${1}";
+ unset name;
+ unset name_ext;
+ export grub_file="${1}";
+ regexp --set=1:name '.*/(.*)$' "${grub_file}";
+ regexp --set=1:name_ext '^.*\.(.*$)' "${grub_file}";
+# File type
+ # cfg
+ if regexp '^[cC][fF][gG]$' "${name_ext}"; then
+ menu_cfg;
+ # efi
+ elif regexp '^[eE][fF][iI]$' "${name_ext}"; then
+ if [ "$grub_platform" = "efi" ]; then
+ clear_menu;
+ add_back_menu;
+ menuentry "运行 EFI 应用程序" {
+ menu_efi_chain;
+ }
+ menuentry "加载 EFI 驱动程序" {
+ menu_efi_load;
+ }
+ fi;
+ # ima img
+ elif regexp '^[iI][mM][aAgG]$' "${name_ext}"; then
+ if [ "$grub_platform" = "pc" ]; then
+ clear_menu;
+ add_back_menu;
+ menuentry "仿真启动软盘镜像 (grub.exe)" {
+ menu_img_bios_fd;
+ }
+ menuentry "仿真启动硬盘镜像 (grub.exe)" {
+ menu_img_bios_hd;
+ }
+ elif [ "$grub_platform" = "efi" ]; then
+ if [ "$grub_cpu" = "x86_64" ]; then
+ clear_menu;
+ add_back_menu;
+ menuentry "仿真启动硬盘镜像" {
+ menu_img_uefi_map;
+ }
+ menuentry "仿真启动硬盘镜像 (加载到内存)" {
+ menu_img_uefi_mapmem;
+ }
+ fi;
+ fi;
+ # iso
+ elif regexp '^[iI][sS][oO]$' "${name_ext}"; then
+ loopback loop ${grub_file};
+ if test -f (loop)/boot/grub/loopback.cfg; then
+ menu_iso_loop;
+ elif [ "$grub_platform" = "pc" ]; then
+ menu_iso_bios_map;
+ elif [ "$grub_platform" = "efi" ]; then
+ if [ "$grub_cpu" = "x86_64" ]; then
+ menu_iso_uefi_map;
+ fi;
+ fi;
+ # vhd
+ elif regexp '^[vV][hH][dD]$' "${name_ext}"; then
+ if [ "$grub_platform" = "pc" ]; then
+ menu_vhd_bios_vboot;
+ elif [ "$grub_platform" = "efi" ]; then
+ if [ "$grub_cpu" = "x86_64" ]; then
+ menu_vhd_uefi_map;
+ fi;
+ fi;
+ # wim
+ elif regexp '^[wW][iI][mM]$' "${name_ext}"; then
+ menu_wim;
+ fi;
}
grubfm_init;
-if [ "${grub_load}" = "grubfm_open" ]; then
- grubfm_open "${grub_file}";
-else
- grubfm_main "${grub_path}";
-fi;
+grubfm_main "${grub_path}";
diff --git a/samples/grubfm_offical.cfg b/samples/grubfm_offical.cfg
new file mode 100644
index 00000000..64fb962a
--- /dev/null
+++ b/samples/grubfm_offical.cfg
@@ -0,0 +1,212 @@
+# Grub2-FileManager
+# Copyright (C) 2016,2017,2018 A1ive.
+#
+# Grub2-FileManager is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Grub2-FileManager is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Grub2-FileManager. If not, see .
+
+function grubfm_init {
+ insmod loopback;
+ insmod probe;
+ insmod progress;
+ insmod regexp;
+ set debug= ;
+ set enable_progress_indicator=0;
+ set grub_exe="/boot/grub/grub.exe";
+ set grub_fm="/boot/grub/grubfm.cfg";
+ set grub_ipxe="/boot/grub/ipxe.lkrn";
+ set grub_memdisk="/boot/grub/memdisk";
+ set grub_wimboot="/boot/grub/wimboot";
+ set pager=0;
+}
+
+# grubfm_main PATH
+function grubfm_main {
+ if test -z "${1}"; then
+ for device in (*); do
+ if test -d "${device}"; then
+ probe --set=fs -f "${device}";
+ probe --set=label -l "${device}";
+ if regexp 'loop' "${device}"; then
+ continue;
+ elif test "$fs" = "udf" -o "$fs" = "iso9660"; then
+ icon="iso";
+ elif test "${device}" = "(memdisk)" -o "${device}" = "(proc)"; then
+ continue;
+ else
+ icon="hdd";
+ fi;
+ menuentry "${device} [$fs] $label" "${device}" --class $icon{
+ set grub_path="$2";
+ set grub_load="";
+ export grub_path;
+ configfile ${grub_fm};
+ }
+ unset label;
+ unset fs;
+ fi;
+ done;
+ else
+ set grub_path="${1}";
+ set default=1;
+ menuentry ".." --class go-previous{
+ if ! regexp --set=1:grub_path '(^.*)/.*$' "${grub_path}"; then
+ set grub_path="";
+ fi
+ set grub_load="";
+ export grub_path;
+ configfile ${grub_fm};
+ }
+ for item in ${grub_path}/*; do
+ regexp --set=1:name '.*/(.*)$' "${item}";
+ if test -d "${item}"; then
+ menuentry "[${name}]" "${item}" --class dir{
+ set grub_path="$2";
+ set grub_load="";
+ export grub_path;
+ configfile ${grub_fm};
+ }
+ elif test -f "${item}"; then
+ menuentry "${name}" "${item}" --class file{
+ set grub_file="$2";
+ set grub_load="grubfm_open";
+ export grub_file;
+ export grub_path;
+ export grub_load;
+ configfile ${grub_fm};
+ }
+ else
+ continue;
+ fi;
+ done;
+ fi;
+}
+# grubfm_open FILE
+function grubfm_open {
+ unset name;
+ unset name_ext;
+ set grub_file="${1}";
+ set grub_load="";
+ regexp --set=1:name '.*/(.*)$' "${grub_file}";
+ regexp --set=1:name_ext '^.*\.(.*$)' "${grub_file}";
+ set default=1;
+ menuentry "返回" --class go-previous{
+ set grub_load="";
+ export grub_path;
+ configfile ${grub_fm};
+ }
+ # cfg efi ima/img iso wim ipxe
+ if regexp '^[cC][fF][gG]$' "${name_ext}"; then
+ menuentry "加载GRUB2菜单" --class cfg{
+ regexp --set=1:root '^\(([0-9a-zA-Z,]+)\).*$' "${grub_file}";
+ configfile ${grub_file};
+ }
+ elif regexp '^[eE][fF][iI]$' "${name_ext}"; then
+ if [ "$grub_platform" = "efi" ]; then
+ menuentry "运行EFI程序" --class uefi{
+ set enable_progress_indicator=1;
+ regexp --set=1:root '^\(([0-9a-zA-Z,]+)\).*$' "${grub_file}";
+ chainloader ${grub_file};
+ }
+ fi;
+ elif regexp '^[iI][mM][aAgG]$' "${name_ext}"; then
+ if [ "$grub_platform" = "pc" ]; then
+ menuentry "仿真启动软盘镜像 (grub.exe)" --class img{
+ set enable_progress_indicator=1;
+ set g4d_cmd="map --mem (rd)+1 (fd0);map --hook;rootnoverify (fd0);chainloader +1"
+ linux16 ${grub_exe} --config-file=$g4d_cmd;
+ initrd16 ${grub_file};
+ }
+ menuentry "仿真启动软盘镜像 (memdisk)" --class img{
+ set enable_progress_indicator=1;
+ linux16 ${grub_memdisk} floppy raw;
+ initrd16 ${grub_file};
+ }
+ menuentry "仿真启动硬盘镜像 (grub.exe)" --class img{
+ set enable_progress_indicator=1;
+ set g4d_cmd="map --mem (rd)+1 (hd-1);map --hook;rootnoverify (hd-1);chainloader +1"
+ linux16 ${grub_exe} --config-file=$g4d_cmd;
+ initrd16 ${grub_file};
+ }
+ menuentry "仿真启动硬盘镜像 (memdisk)" --class img{
+ set enable_progress_indicator=1;
+ linux16 ${grub_memdisk} harddisk raw;
+ initrd16 ${grub_file};
+ }
+ fi;
+ elif regexp '^[iI][sS][oO]$' "${name_ext}"; then
+ loopback loop ${grub_file};
+ if test -f (loop)/boot/grub/loopback.cfg; then
+ menuentry "加载ISO Loopback菜单" --class gnu-linux{
+ regexp --set=1:iso_path '(/.*)$' "${grub_file}";
+ regexp --set=1:iso_device '^(\([0-9a-zA-Z,]+\))/.*' "${grub_file}";
+ probe --set=rootuuid -u "${iso_device}";
+ export iso_path;
+ export rootuuid;
+ set root=loop;
+ configfile /boot/grub/loopback.cfg
+ }
+ fi;
+ if [ "$grub_platform" = "pc" ]; then
+ menuentry "仿真启动光盘镜像 (grub.exe)" --class iso{
+ set enable_progress_indicator=1;
+ set g4d_cmd="map --mem (rd)+1 (0xff);map --hook;chainloader (0xff)"
+ linux16 ${grub_exe} --config-file=$g4d_cmd;
+ initrd16 ${grub_file};
+ }
+ menuentry "仿真启动光盘镜像 (memdisk)" --class iso{
+ set enable_progress_indicator=1;
+ linux16 ${grub_memdisk} iso raw;
+ initrd16 ${grub_file};
+ }
+ fi;
+ elif regexp '^[wW][iI][mM]$' "${name_ext}"; then
+ if [ "$grub_platform" = "pc" ]; then
+ menuentry "启动 NT6 WIM" --class wim{
+ set enable_progress_indicator=1;
+ loopback wimboot ${grub_wimboot};
+ linux16 (wimboot)/wimboot gui;
+ initrd16 newc:bootmgr:(wimboot)/bootmgr \
+ newc:bcd:(wimboot)/bcd \
+ newc:boot.sdi:(wimboot)/boot.sdi \
+ newc:boot.wim:${grub_file};
+ }
+ fi;
+ elif regexp '^[iI][pP][xX][eE]$' "${name_ext}"; then
+ if [ "$grub_platform" = "pc" ]; then
+ menuentry "加载iPXE菜单" --class net{
+ set enable_progress_indicator=1;
+ linux16 ${grub_ipxe};
+ initrd16 ${grub_file};
+ }
+ fi;
+ elif file --is-x86-multiboot "${grub_file}"; then
+ menuentry "启动Multiboot内核" --class exe{
+ multiboot "${grub_file}";
+ }
+ elif file --is-x86-multiboot2 "${grub_file}"; then
+ menuentry "启动Multiboot2内核" --class exe{
+ multiboot2 "${grub_file}";
+ }
+ elif file --is-x86-linux "${grub_file}"; then
+ menuentry "启动Linux内核" --class exe{
+ linux "${grub_file}";
+ }
+ fi;
+}
+
+grubfm_init;
+if [ "${grub_load}" = "grubfm_open" ]; then
+ grubfm_open "${grub_file}";
+else
+ grubfm_main "${grub_path}";
+fi;