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