]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/grub/grub.cfg
Add new iso support
[Ventoy.git] / INSTALL / grub / grub.cfg
1 #************************************************************************************
2 # Copyright (c) 2020, longpanda <admin@ventoy.net>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, see <http://www.gnu.org/licenses/>.
16 #
17 #************************************************************************************
18
19 function ventoy_pause {
20 if [ -n "${vtdebug_flag}" ]; then
21 echo "press Enter to continue ......"
22 read vtTmpPause
23 fi
24 }
25
26 function ventoy_debug_pause {
27 if [ -n "${vtdebug_flag}" ]; then
28 echo "press Enter to continue ......"
29 read vtTmpPause
30 fi
31 }
32
33 function ventoy_cli_console {
34 if [ "$grub_platform" = "pc" ]; then
35 #terminal_output vga_text
36 terminal_output console
37 else
38 if [ "$vtoy_display_mode" != "CLI" ]; then
39 terminal_output console
40 fi
41 fi
42 }
43
44 function ventoy_gui_console {
45 if [ "$grub_platform" = "pc" ]; then
46 if [ "$vtoy_display_mode" = "CLI" ]; then
47 terminal_output console
48 else
49 terminal_output gfxterm
50 fi
51 else
52 if [ "$vtoy_display_mode" != "CLI" ]; then
53 terminal_output gfxterm
54 fi
55 fi
56 }
57
58 function ventoy_power {
59 configfile $prefix/power.cfg
60 }
61
62 function ventoy_diagnosis {
63 configfile $prefix/debug.cfg
64 }
65
66 function ventoy_localboot {
67 configfile $prefix/localboot.cfg
68 }
69
70 function get_os_type {
71 set vtoy_os=Linux
72
73 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
74 if vt_file_exist_nocase (loop)/$file; then
75 set vtoy_os=Windows
76 break
77 fi
78 done
79
80 if [ -n "${vtdebug_flag}" ]; then
81 echo ISO is $vtoy_os
82 fi
83 }
84
85 function vt_check_compatible_pe {
86 #Check for PE without external tools
87 if [ -f $1/HBCD_PE.ini ]; then
88 set ventoy_compatible=YES
89 fi
90 }
91
92 function locate_initrd {
93 vt_linux_locate_initrd
94
95 if [ -n "${vtdebug_flag}" ]; then
96 vt_linux_dump_initrd
97 ventoy_debug_pause
98 fi
99 }
100
101 function locate_wim {
102 vt_windows_locate_wim_patch (loop)
103
104 if [ -n "${vtdebug_flag}" ]; then
105 echo '###############################################'
106 vt_dump_wim_patch
107 echo '###############################################'
108 ventoy_debug_pause
109 fi
110 }
111
112 function distro_specify_wim_patch {
113 if [ -d (loop)/h3pe ]; then
114 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
115 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
116 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
117 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
118 fi
119 }
120
121 function distro_specify_wim_patch_phase2 {
122 if [ -f (loop)/boot/boot.wim ]; then
123 vt_windows_collect_wim_patch wim /boot/boot.wim
124 fi
125 }
126
127
128 function distro_specify_initrd_file {
129 if [ -e (loop)/boot/all.rdz ]; then
130 vt_linux_specify_initrd_file /boot/all.rdz
131 elif [ -e (loop)/boot/xen.gz ]; then
132 if [ -e (loop)/install.img ]; then
133 vt_linux_specify_initrd_file /install.img
134 fi
135 elif [ -d (loop)/casper ]; then
136 if [ -e (loop)/casper/initrd ]; then
137 vt_linux_specify_initrd_file /casper/initrd
138 fi
139 if [ -e (loop)/casper/initrd-oem ]; then
140 vt_linux_specify_initrd_file /casper/initrd-oem
141 fi
142 elif [ -e (loop)/boot/grub/initrd.xz ]; then
143 vt_linux_specify_initrd_file /boot/grub/initrd.xz
144 elif [ -e (loop)/initrd.gz ]; then
145 vt_linux_specify_initrd_file /initrd.gz
146 elif [ -e (loop)/slax/boot/initrfs.img ]; then
147 vt_linux_specify_initrd_file /slax/boot/initrfs.img
148 elif [ -e (loop)/pmagic/initrd.img ]; then
149 vt_linux_specify_initrd_file /pmagic/initrd.img
150 elif [ -e (loop)/boot/initrd.xz ]; then
151 vt_linux_specify_initrd_file /boot/initrd.xz
152 elif [ -f (loop)/boot/initrd ]; then
153 vt_linux_specify_initrd_file /boot/initrd
154 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
155 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
156 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
157 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
158
159
160 fi
161 }
162
163
164 function distro_specify_initrd_file_phase2 {
165 if [ -f (loop)/boot/initrd.img ]; then
166 vt_linux_specify_initrd_file /boot/initrd.img
167 elif [ -f (loop)/Setup/initrd.gz ]; then
168 vt_linux_specify_initrd_file /Setup/initrd.gz
169 elif [ -f (loop)/isolinux/initramfs ]; then
170 vt_linux_specify_initrd_file /isolinux/initramfs
171 elif [ -f (loop)/boot/iniramfs.igz ]; then
172 vt_linux_specify_initrd_file /boot/iniramfs.igz
173 elif [ -f (loop)/initrd-x86_64 ]; then
174 vt_linux_specify_initrd_file /initrd-x86_64
175 elif [ -f (loop)/live/initrd.img ]; then
176 vt_linux_specify_initrd_file /live/initrd.img
177 elif [ -f (loop)/initrd.img ]; then
178 vt_linux_specify_initrd_file /initrd.img
179 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
180 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
181 elif [ -f (loop)/CDlinux/initrd ]; then
182 vt_linux_specify_initrd_file /CDlinux/initrd
183 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
184 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
185 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
186 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
187 fi
188 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
189 #Qubes
190 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
191 if [ "$grub_platform" != "pc" ]; then
192 vt_add_replace_file 0 "initrd.img"
193 fi
194 elif [ -f (loop)/initrd ]; then
195 vt_linux_specify_initrd_file /initrd
196 elif [ -f (loop)/live/initrd1 ]; then
197 vt_linux_specify_initrd_file /live/initrd1
198
199 fi
200 }
201
202 function uefi_windows_menu_func {
203 vt_windows_reset
204
205 if [ "$ventoy_compatible" = "NO" ]; then
206
207 if [ "$ventoy_fs_probe" = "iso9660" ]; then
208 loopback -d loop
209 vt_iso9660_nojoliet 1
210 loopback loop $1$2
211 fi
212
213 for file in "efi/microsoft/boot/bcd"; do
214 vt_windows_collect_wim_patch bcd (loop)/$file
215 done
216
217 vt_windows_count_wim_patch vt_wim_cnt
218 if [ $vt_wim_cnt -eq 0 ]; then
219 distro_specify_wim_patch_phase2
220 fi
221
222 ventoy_debug_pause
223 locate_wim
224 fi
225
226 vt_windows_chain_data ${1}${chosen_path}
227 ventoy_debug_pause
228
229 if [ -n "$vtoy_chain_mem_addr" ]; then
230 ventoy_cli_console
231 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
232 boot
233 else
234 echo "chain empty failed"
235 ventoy_pause
236 fi
237 }
238
239 function uefi_linux_menu_func {
240 if [ "$ventoy_compatible" = "NO" ]; then
241
242 if [ "$ventoy_fs_probe" = "udf" ]; then
243 loopback -d loop
244 set ventoy_fs_probe=iso9660
245 loopback loop $1$2
246 fi
247
248 vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1
249
250 vt_linux_clear_initrd
251
252 if [ -d (loop)/pmagic ]; then
253 vt_linux_specify_initrd_file /pmagic/initrd.img
254 else
255 for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf" "/grub/grub.cfg"; do
256 if [ -e (loop)/$file ]; then
257 vt_linux_parse_initrd_grub file (loop)/$file
258 fi
259 done
260 fi
261
262 # special process for special distros
263 if [ -d (loop)/loader/entries ]; then
264 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
265 elif [ -d (loop)/boot/grub ]; then
266 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
267 fi
268
269 distro_specify_initrd_file
270
271 vt_linux_initrd_count vtcount
272 if [ $vtcount -eq 0 ]; then
273 distro_specify_initrd_file_phase2
274
275 if [ "$vt_efi_dir" = "NO" ]; then
276 if [ -f (loop)/efi.img ]; then
277 vt_add_replace_file 0 "initrd"
278 fi
279 fi
280 fi
281
282 locate_initrd
283
284 if [ -d (loop)/loader/entries ]; then
285 vt_linux_get_main_initrd_index vtindex
286
287 if [ -d (loop)/arch ]; then
288 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
289 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
290 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
291 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
292 fi
293 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
294 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
295 fi
296 elif [ -d (loop)/EFI/boot/entries ]; then
297 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
298 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
299 fi
300 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
301 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
302 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
303 fi
304
305 fi
306
307 vt_linux_chain_data ${1}${chosen_path}
308
309 if [ -n "$vtoy_chain_mem_addr" ]; then
310 ventoy_cli_console
311 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
312 boot
313 else
314 echo "chain empty failed"
315 ventoy_pause
316 fi
317 }
318
319
320 function uefi_iso_menu_func {
321
322 if [ -d (loop)/ ]; then
323 loopback -d loop
324 fi
325
326 if [ -n "$vtisouefi" ]; then
327 set LoadIsoEfiDriver=on
328 unset vtisouefi
329 elif vt_check_mode 2; then
330 set LoadIsoEfiDriver=on
331 else
332 unset LoadIsoEfiDriver
333 fi
334
335 vt_chosen_img_path chosen_path
336 vt_select_auto_install ${chosen_path}
337 vt_select_persistence ${chosen_path}
338
339 if vt_is_udf ${1}${chosen_path}; then
340 set ventoy_fs_probe=udf
341 else
342 set ventoy_fs_probe=iso9660
343 vt_iso9660_nojoliet 0
344 fi
345
346 loopback loop ${1}${chosen_path}
347 get_os_type (loop)
348
349 if [ -d (loop)/EFI ]; then
350 set vt_efi_dir=YES
351 elif [ -d (loop)/efi ]; then
352 set vt_efi_dir=YES
353 else
354 set vt_efi_dir=NO
355 fi
356
357 if [ -n "$vtcompat" ]; then
358 set ventoy_compatible=YES
359 unset vtcompat
360 elif vt_check_mode 1; then
361 set ventoy_compatible=YES
362 else
363 vt_check_compatible (loop)
364 fi
365
366 vt_img_sector ${1}${chosen_path}
367
368 if [ "$vtoy_os" = "Windows" ]; then
369 vt_check_compatible_pe (loop)
370 uefi_windows_menu_func $1 ${chosen_path}
371 else
372 uefi_linux_menu_func $1 ${chosen_path}
373 fi
374
375 ventoy_gui_console
376 }
377
378 function uefi_iso_memdisk {
379 vt_chosen_img_path chosen_path
380
381 echo 'Loading ISO file to memory ...'
382 vt_load_iso_to_mem ${1}${chosen_path} vtoy_iso_buf
383
384 ventoy_cli_console
385 chainloader ${vtoy_path}/ventoy_x64.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
386 boot
387
388 ventoy_gui_console
389 }
390
391
392 function legacy_windows_menu_func {
393 vt_windows_reset
394
395 if [ "$ventoy_compatible" = "NO" ]; then
396
397 if [ "$ventoy_fs_probe" = "iso9660" ]; then
398 loopback -d loop
399 vt_iso9660_nojoliet 1
400 loopback loop $1$2
401 fi
402
403 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do
404 vt_windows_collect_wim_patch bcd (loop)/$file
405 done
406
407 distro_specify_wim_patch
408
409 vt_windows_count_wim_patch vt_wim_cnt
410 if [ $vt_wim_cnt -eq 0 ]; then
411 distro_specify_wim_patch_phase2
412 fi
413
414 ventoy_debug_pause
415 locate_wim
416 fi
417
418 vt_windows_chain_data ${1}${chosen_path}
419 ventoy_debug_pause
420
421 if [ -n "$vtoy_chain_mem_addr" ]; then
422 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
423 boot
424 else
425 echo "chain empty failed"
426 ventoy_pause
427 fi
428 }
429
430 function legacy_linux_menu_func {
431 if [ "$ventoy_compatible" = "NO" ]; then
432
433 if [ "$ventoy_fs_probe" = "udf" ]; then
434 loopback -d loop
435 set ventoy_fs_probe=iso9660
436 loopback loop $1$2
437 fi
438
439 vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
440
441 vt_linux_clear_initrd
442
443 if [ -d (loop)/pmagic ]; then
444 vt_linux_specify_initrd_file /pmagic/initrd.img
445 else
446 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
447 if [ -d (loop)/$dir ]; then
448 vt_linux_parse_initrd_isolinux (loop)/$dir/
449 fi
450 done
451 fi
452
453 # special process for special distros
454 #archlinux
455 if [ -d (loop)/arch/boot/syslinux ]; then
456 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
457 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
458
459 #manjaro
460 elif [ -d (loop)/manjaro ]; then
461 if [ -e (loop)/boot/grub/kernels.cfg ]; then
462 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
463 fi
464 elif [ -e (loop)/boot/grub/grub.cfg ]; then
465 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
466 fi
467
468 distro_specify_initrd_file
469
470 vt_linux_initrd_count vtcount
471 if [ $vtcount -eq 0 ]; then
472 distro_specify_initrd_file_phase2
473 fi
474
475 locate_initrd
476 fi
477
478 vt_linux_chain_data ${1}${chosen_path}
479 ventoy_debug_pause
480
481 if [ -n "$vtoy_chain_mem_addr" ]; then
482 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
483 boot
484 else
485 echo "chain empty failed"
486 ventoy_pause
487 fi
488 }
489
490 function legacy_iso_menu_func {
491
492 if [ -d (loop)/ ]; then
493 loopback -d loop
494 fi
495
496 vt_chosen_img_path chosen_path
497 vt_select_auto_install ${chosen_path}
498 vt_select_persistence ${chosen_path}
499
500 if vt_is_udf ${1}${chosen_path}; then
501 set ventoy_fs_probe=udf
502 else
503 set ventoy_fs_probe=iso9660
504 vt_iso9660_nojoliet 0
505 fi
506
507 loopback loop ${1}${chosen_path}
508 get_os_type (loop)
509
510 if [ -n "$vtcompat" ]; then
511 set ventoy_compatible=YES
512 unset vtcompat
513 elif vt_check_mode 1; then
514 set ventoy_compatible=YES
515 else
516 vt_check_compatible (loop)
517 fi
518
519 vt_img_sector ${1}${chosen_path}
520
521 if [ "$vtoy_os" = "Windows" ]; then
522 vt_check_compatible_pe (loop)
523 legacy_windows_menu_func $1 ${chosen_path}
524 else
525 legacy_linux_menu_func $1 ${chosen_path}
526 fi
527 }
528
529 function legacy_iso_memdisk {
530 vt_chosen_img_path chosen_path
531
532 linux16 $vtoy_path/memdisk iso raw
533 echo "Loading ISO file to memory ..."
534 initrd16 ${1}${chosen_path}
535 boot
536 }
537
538 function iso_common_menuentry {
539 if [ "$grub_platform" = "pc" ]; then
540 if vt_check_mode 0; then
541 legacy_iso_memdisk $iso_path
542 else
543 legacy_iso_menu_func $iso_path
544 fi
545 else
546 if vt_check_mode 0; then
547 uefi_iso_memdisk $iso_path
548 else
549 uefi_iso_menu_func $iso_path
550 fi
551 fi
552 }
553
554 function common_unsupport_menuentry {
555 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
556 echo -e " 文件名中不能有中文或空格 \n"
557 echo -e "\n Will return to main menu after 10 seconds ...\n"
558 sleep 10
559 }
560
561 function iso_unsupport_menuentry {
562 common_unsupport_menuentry
563 }
564
565 function wim_common_menuentry {
566 vt_chosen_img_path chosen_path
567 vt_wim_chain_data ${iso_path}${chosen_path}
568
569 ventoy_debug_pause
570
571 if [ -n "$vtoy_chain_mem_addr" ]; then
572 if [ "$grub_platform" = "pc" ]; then
573 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
574 else
575 ventoy_cli_console
576 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
577 ventoy_gui_console
578 fi
579 boot
580 else
581 echo "chain empty failed"
582 ventoy_pause
583 fi
584 }
585
586 function wim_unsupport_menuentry {
587 common_unsupport_menuentry
588 }
589
590 function efi_common_menuentry {
591 vt_chosen_img_path chosen_path
592
593 ventoy_cli_console
594 chainloader ${iso_path}${chosen_path}
595 boot
596 ventoy_gui_console
597 }
598
599 function efi_unsupport_menuentry {
600 common_unsupport_menuentry
601 }
602
603
604
605 #############################################################
606 #############################################################
607 #############################################################
608 ####### Main Process ###########
609 #############################################################
610 #############################################################
611 #############################################################
612
613 set VENTOY_VERSION="1.0.15"
614
615 # Default menu display mode, you can change it as you want.
616 # 0: List mode
617 # 1: TreeView mode
618 set VTOY_DEFAULT_MENU_MODE=0
619
620 set VTOY_MEM_DISK_STR="[Memdisk]"
621 set VTOY_ISO_RAW_STR="Compatible Mode"
622 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
623
624 set VTOY_F2_CMD="ventoy_power"
625 set VTOY_F4_CMD="ventoy_localboot"
626 set VTOY_F5_CMD="ventoy_diagnosis"
627
628 if [ "$grub_platform" = "pc" ]; then
629 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
630 else
631 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
632 fi
633
634 vt_device $root vtoy_dev
635
636 if [ "$vtoy_dev" = "tftp" ]; then
637 set vtoy_path=($root)
638 for vtid in 0 1 2 3; do
639 if [ -d (hd$vtid,2)/ventoy ]; then
640 set iso_path=(hd$vtid,1)
641 set vtoy_efi_part=(hd$vtid,2)
642 break
643 fi
644 done
645 loadfont ascii
646
647 if [ -f $iso_path/ventoy/ventoy.json ]; then
648 set vt_plugin_path=$iso_path
649 else
650 set vt_plugin_path=$prefix
651 vt_load_plugin $vt_plugin_path
652 fi
653 else
654 if [ "$prefix" = "(ventoydisk)/grub" ]; then
655 set vtoy_path=(ventoydisk)/ventoy
656 else
657 set vtoy_path=($root)/ventoy
658 fi
659
660 set iso_path=($vtoy_dev,1)
661 set vtoy_efi_part=($vtoy_dev,2)
662 loadfont unicode
663 set vt_plugin_path=$iso_path
664 fi
665
666
667 #Load Plugin
668 if [ -f $iso_path/ventoy/ventoy.json ]; then
669 vt_load_plugin $iso_path
670 fi
671
672 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
673 set timeout=$VTOY_MENU_TIMEOUT
674 else
675 unset timeout
676 fi
677
678 if [ -f $iso_path/ventoy/ventoy_wimboot.img ]; then
679 vt_load_wimboot $iso_path/ventoy/ventoy_wimboot.img
680 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
681 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
682 fi
683
684
685 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
686 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
687 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Debug"
688 else
689 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
690 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Debug"
691 fi
692
693
694 if [ -n "$vtoy_gfxmode" ]; then
695 set gfxmode=$vtoy_gfxmode
696 else
697 set gfxmode=1920x1080,1366x768,1024x768
698 fi
699
700 if [ "$vtoy_display_mode" = "CLI" ]; then
701 terminal_output console
702 else
703 if [ -n "$vtoy_theme" ]; then
704 set theme=$vtoy_theme
705 else
706 set theme=$prefix/themes/ventoy/theme.txt
707 fi
708 terminal_output gfxterm
709 fi
710
711 #colect all image files (iso files)
712 set ventoy_img_count=0
713 vt_list_img $iso_path ventoy_img_count
714
715 #Main menu
716 if [ $ventoy_img_count -gt 0 ]; then
717 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
718 vt_dynamic_menu 0 0
719 else
720 vt_dynamic_menu 0 1
721 fi
722 else
723 if [ -n "$VTOY_NO_ISO_TIP" ]; then
724 NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
725 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
726 NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
727 else
728 NO_ISO_MENU="No ISO files found"
729 fi
730 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
731 echo -e "\n Rebooting ... "
732 reboot
733 }
734 fi