]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/grub/grub.cfg
update for new 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 echo "press Enter to continue ......"
21 read vtTmpPause
22 }
23
24 function ventoy_debug_pause {
25 if [ -n "${vtdebug_flag}" ]; then
26 echo "press Enter to continue ......"
27 read vtTmpPause
28 fi
29 }
30
31 function ventoy_cli_console {
32 if [ -z "$vtoy_display_mode" ]; then
33 terminal_output console
34 elif [ "$vtoy_display_mode" = "GUI" ]; then
35 terminal_output console
36 fi
37 }
38
39 function ventoy_gui_console {
40 if [ -z "$vtoy_display_mode" ]; then
41 terminal_output gfxterm
42 elif [ "$vtoy_display_mode" = "GUI" ]; then
43 terminal_output gfxterm
44 fi
45 }
46
47 function ventoy_power {
48 configfile $prefix/power.cfg
49 }
50
51 function ventoy_diagnosis {
52 configfile $prefix/debug.cfg
53 }
54
55 function ventoy_localboot {
56 configfile $prefix/localboot.cfg
57 }
58
59 function ventoy_ext_menu {
60 if [ -e $vt_plugin_path/ventoy/ventoy_grub.cfg ]; then
61 set ventoy_new_context=1
62 configfile $vt_plugin_path/ventoy/ventoy_grub.cfg
63 unset ventoy_new_context
64 else
65 echo "ventoy_grub.cfg NOT exist."
66 echo -e "\npress ENTER to exit ..."
67 read vtInputKey
68 fi
69 }
70
71 function get_os_type {
72 set vtoy_os=Linux
73
74 for file in "efi/microsoft/boot/bcd" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" ; do
75 if vt_file_exist_nocase (loop)/$file; then
76 set vtoy_os=Windows
77 break
78 fi
79 done
80
81 if [ "$vtoy_os" = "Linux" ]; then
82 if vt_strstr "$vt_system_id" "FreeBSD"; then
83 set vtoy_os=Unix
84 set vt_unix_type=FreeBSD
85 elif [ -e (loop)/bin/freebsd-version ]; then
86 set vtoy_os=Unix
87 set vt_unix_type=FreeBSD
88
89
90 elif [ -e (loop)/boot/kernel/kernel ]; then
91 if file --is-x86-kfreebsd (loop)/boot/kernel/kernel; then
92 set vtoy_os=Unix
93 set vt_unix_type=FreeBSD
94 elif file --is-x86-knetbsd (loop)/boot/kernel/kernel; then
95 set vtoy_os=Unix
96 set vt_unix_type=NetBSD
97 fi
98 fi
99 fi
100
101 if [ -n "${vtdebug_flag}" ]; then
102 echo ISO is $vtoy_os
103 fi
104 }
105
106 function vt_check_compatible_pe {
107 #Check for PE without external tools
108 if [ -f $1/HBCD_PE.ini ]; then
109 set ventoy_compatible=YES
110 fi
111 }
112
113 function locate_initrd {
114 vt_linux_locate_initrd
115
116 if [ -n "${vtdebug_flag}" ]; then
117 vt_linux_dump_initrd
118 ventoy_debug_pause
119 fi
120 }
121
122 function locate_wim {
123 vt_windows_locate_wim_patch (loop)
124
125 if [ -n "${vtdebug_flag}" ]; then
126 echo '###############################################'
127 vt_dump_wim_patch
128 echo '###############################################'
129 ventoy_debug_pause
130 fi
131 }
132
133 function distro_specify_wim_patch {
134 if [ -d (loop)/h3pe ]; then
135 vt_windows_collect_wim_patch wim /BOOT/H3_10PE.WIM
136 vt_windows_collect_wim_patch wim /BOOT/H3_7PE.WIM
137 vt_windows_collect_wim_patch wim /BOOT/H3_8PE.WIM
138 vt_windows_collect_wim_patch wim /BOOT/H3_81PE.WIM
139 fi
140 }
141
142 function distro_specify_wim_patch_phase2 {
143 if [ -f (loop)/boot/boot.wim ]; then
144 vt_windows_collect_wim_patch wim /boot/boot.wim
145 fi
146 }
147
148
149 function distro_specify_initrd_file {
150 if [ -e (loop)/boot/all.rdz ]; then
151 vt_linux_specify_initrd_file /boot/all.rdz
152 elif [ -e (loop)/boot/xen.gz ]; then
153 if [ -e (loop)/install.img ]; then
154 vt_linux_specify_initrd_file /install.img
155 fi
156 elif [ -d (loop)/casper ]; then
157 if [ -e (loop)/casper/initrd ]; then
158 vt_linux_specify_initrd_file /casper/initrd
159 fi
160 if [ -e (loop)/casper/initrd.gz ]; then
161 vt_linux_specify_initrd_file /casper/initrd.gz
162 fi
163 if [ -e (loop)/casper/initrd-oem ]; then
164 vt_linux_specify_initrd_file /casper/initrd-oem
165 fi
166 elif [ -e (loop)/boot/grub/initrd.xz ]; then
167 vt_linux_specify_initrd_file /boot/grub/initrd.xz
168 elif [ -e (loop)/initrd.gz ]; then
169 vt_linux_specify_initrd_file /initrd.gz
170 elif [ -e (loop)/slax/boot/initrfs.img ]; then
171 vt_linux_specify_initrd_file /slax/boot/initrfs.img
172 elif [ -e (loop)/pmagic/initrd.img ]; then
173 vt_linux_specify_initrd_file /pmagic/initrd.img
174 elif [ -e (loop)/boot/initrd.xz ]; then
175 vt_linux_specify_initrd_file /boot/initrd.xz
176 elif [ -e (loop)/boot/initrd.gz ]; then
177 vt_linux_specify_initrd_file /boot/initrd.gz
178 elif [ -f (loop)/boot/initrd ]; then
179 vt_linux_specify_initrd_file /boot/initrd
180 elif [ -f (loop)/boot/x86_64/loader/initrd ]; then
181 vt_linux_specify_initrd_file /boot/x86_64/loader/initrd
182 elif [ -f (loop)/boot/initramfs-x86_64.img ]; then
183 vt_linux_specify_initrd_file /boot/initramfs-x86_64.img
184 elif [ -f (loop)/boot/isolinux/initramfs_data64.cpio.gz ]; then
185 vt_linux_specify_initrd_file /boot/isolinux/initramfs_data64.cpio.gz
186
187
188 fi
189
190 if [ -f (loop)/isolinux/initrd.gz ]; then
191 vt_linux_specify_initrd_file /isolinux/initrd.gz
192 fi
193
194 if [ "$vt_chosen_size" = "1133375488" ]; then
195 if [ -d (loop)/boot/grub/x86_64-efi ]; then
196 vt_cpio_busybox64
197 fi
198 fi
199 }
200
201
202 function distro_specify_initrd_file_phase2 {
203 if [ -f (loop)/boot/initrd.img ]; then
204 vt_linux_specify_initrd_file /boot/initrd.img
205 elif [ -f (loop)/Setup/initrd.gz ]; then
206 vt_linux_specify_initrd_file /Setup/initrd.gz
207 elif [ -f (loop)/isolinux/initramfs ]; then
208 vt_linux_specify_initrd_file /isolinux/initramfs
209 elif [ -f (loop)/boot/iniramfs.igz ]; then
210 vt_linux_specify_initrd_file /boot/iniramfs.igz
211 elif [ -f (loop)/initrd-x86_64 ]; then
212 vt_linux_specify_initrd_file /initrd-x86_64
213 elif [ -f (loop)/live/initrd.img ]; then
214 vt_linux_specify_initrd_file /live/initrd.img
215 elif [ -f (loop)/initrd.img ]; then
216 vt_linux_specify_initrd_file /initrd.img
217 elif [ -f (loop)/sysresccd/boot/x86_64/sysresccd.img ]; then
218 vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
219 elif [ -f (loop)/CDlinux/initrd ]; then
220 vt_linux_specify_initrd_file /CDlinux/initrd
221 elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
222 vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
223 if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
224 vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
225 fi
226 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
227 vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
228 if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
229 vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
230 fi
231 elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
232 #Qubes
233 vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
234 if [ "$grub_platform" != "pc" ]; then
235 vt_add_replace_file 0 "initrd.img"
236 fi
237 elif [ -f (loop)/initrd ]; then
238 vt_linux_specify_initrd_file /initrd
239 elif [ -f (loop)/live/initrd1 ]; then
240 vt_linux_specify_initrd_file /live/initrd1
241 elif [ -f (loop)/isolinux/initrd.img ]; then
242 vt_linux_specify_initrd_file /isolinux/initrd.img
243 elif [ -f (loop)/isolinux/initrd.gz ]; then
244 vt_linux_specify_initrd_file /isolinux/initrd.gz
245 elif [ -f (loop)/syslinux/kernel/initramfs.gz ]; then
246 vt_linux_specify_initrd_file /syslinux/kernel/initramfs.gz
247 elif vt_strstr $vt_volume_id "Daphile"; then
248 vt_linux_parse_initrd_isolinux (loop)/isolinux/
249 elif [ -f (loop)/boot/rootfs.xz ]; then
250 vt_linux_specify_initrd_file /boot/rootfs.xz
251 if [ "$grub_platform" != "pc" ]; then
252 vt_add_replace_file 0 "minimal\\x86_64\\rootfs.xz"
253 fi
254
255 fi
256 }
257
258 function ventoy_get_ghostbsd_ver {
259
260 # vt_parse_iso_create_date $1/${chosen_path} vt_create_date
261 # if regexp "^202005" "$vt_create_date"; then
262 # set vt_freebsd_ver=12.x
263 # fi
264
265 set vt_freebsd_ver=12.x
266 }
267
268 function ventoy_get_furybsd_ver {
269 if regexp "13\.[0-9]" "$2"; then
270 set vt_freebsd_ver=13.x
271 else
272 set vt_freebsd_ver=12.x
273 fi
274 }
275
276 function ventoy_get_freenas_ver {
277 set vt_freebsd_ver=11.x
278
279 if [ -e (loop)/FreeNAS-MANIFEST ]; then
280 vt_parse_freenas_ver (loop)/FreeNAS-MANIFEST vt_freenas_ver
281 if regexp "^13\.[0-9]" "$vt_freenas_ver"; then
282 set vt_freebsd_ver=13.x
283 elif regexp "^12\.[0-9]" "$vt_freenas_ver"; then
284 set vt_freebsd_ver=12.x
285 elif regexp "^11\.[0-9]" "$vt_freenas_ver"; then
286 set vt_freebsd_ver=11.x
287 fi
288 fi
289 }
290
291 function ventoy_get_midnightbsd_ver {
292 set vt_freebsd_ver=11.x
293 }
294
295 function ventoy_freebsd_proc {
296 set vtFreeBsdDistro=FreeBSD
297
298 if vt_strstr "$vt_volume_id" "GHOSTBSD"; then
299 ventoy_get_ghostbsd_ver $1 ${chosen_path}
300 elif vt_strstr "$vt_volume_id" "FREENAS"; then
301 ventoy_get_freenas_ver $1 ${chosen_path}
302 elif vt_strstr "$vt_volume_id" "FURYBSD"; then
303 ventoy_get_furybsd_ver $1 ${chosen_path}
304 elif regexp "^13_[0-9]" "$vt_volume_id"; then
305 set vt_freebsd_ver=13.x
306 elif regexp "^12_[0-9]" "$vt_volume_id"; then
307 set vt_freebsd_ver=12.x
308 elif regexp "^11_[0-9]" "$vt_volume_id"; then
309 set vt_freebsd_ver=11.x
310 elif regexp "^10_[0-9]" "$vt_volume_id"; then
311 set vt_freebsd_ver=10.x
312 elif regexp "^9_[0-9]" "$vt_volume_id"; then
313 set vt_freebsd_ver=9.x
314 elif [ -d (loop)/usr/midnightbsd-dist ]; then
315 ventoy_get_midnightbsd_ver $1 ${chosen_path}
316 set vtFreeBsdDistro=MidnightBSD
317 elif [ -e (loop)/bin/freebsd-version ]; then
318 vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
319 if regexp "\"13\.[0-9]-" "$vt_userland_ver"; then
320 set vt_freebsd_ver=13.x
321 elif regexp "\"12\.[0-9]-" "$vt_userland_ver"; then
322 set vt_freebsd_ver=12.x
323 elif regexp "\"11\.[0-9]-" "$vt_userland_ver"; then
324 set vt_freebsd_ver=11.x
325 elif regexp "\"10\.[0-9]-" "$vt_userland_ver"; then
326 set vt_freebsd_ver=10.x
327 elif regexp "\"9\.[0-9]-" "$vt_userland_ver"; then
328 set vt_freebsd_ver=9.x
329 fi
330 elif [ -e (loop)/README.TXT ]; then
331 vt_1st_line (loop)/README.TXT vt_freebsd_line1
332 if regexp "FreeBSD 13\.[0-9]-" "$vt_freebsd_line1"; then
333 set vt_freebsd_ver=13.x
334 elif regexp "FreeBSD 12\.[0-9]-" "$vt_freebsd_line1"; then
335 set vt_freebsd_ver=12.x
336 elif regexp "FreeBSD 11\.[0-9]-" "$vt_freebsd_line1"; then
337 set vt_freebsd_ver=11.x
338 elif regexp "FreeBSD 10\.[0-9]-" "$vt_freebsd_line1"; then
339 set vt_freebsd_ver=10.x
340 elif regexp "FreeBSD 9\.[0-9]-" "$vt_freebsd_line1"; then
341 set vt_freebsd_ver=9.x
342 fi
343 elif vt_strstr "${chosen_path}" "MidnightBSD"; then
344 set vt_freebsd_ver=9.x
345 else
346 set vt_freebsd_ver=12.x
347 fi
348
349 set vt_freebsd_bit=64
350 for file in "/boot/kernel/kernel" "/boot/kernel/kernel.gz"; do
351 if [ -e (loop)/$file ]; then
352 if file --is-i386-kfreebsd (loop)/$file; then
353 set vt_freebsd_bit=32
354 fi
355 break
356 fi
357 done
358
359 if [ -n "${vtdebug_flag}" ]; then
360 echo "This is FreeBSD $vt_freebsd_ver ${vt_freebsd_bit}bit"
361 fi
362
363 unset vt_unix_mod_path
364 for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version" "/etc/fstab"; do
365 if [ -e (loop)${file} ]; then
366 set vt_unix_mod_path=${file}
367 break
368 fi
369 done
370
371 if [ -e (loop)/usr/freebsd-dist/cloninst.sh ]; then
372 set vtFreeBsdDistro=ClonOS
373 fi
374
375 vt_unix_replace_ko $vt_unix_mod_path (vtunix)/ventoy_unix/$vtFreeBsdDistro/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
376 vt_unix_replace_conf FreeBSD ${1}${chosen_path}
377 }
378
379 function ventoy_unix_comm_proc {
380 vt_unix_reset
381
382 if [ "$ventoy_compatible" = "NO" ]; then
383 loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
384
385 if [ "$vt_unix_type" = "FreeBSD" ]; then
386 ventoy_freebsd_proc $1 ${chosen_path}
387 elif [ "$vt_unix_type" = "NetBSD" ]; then
388 echo "NetBSD not supported"
389
390
391
392 else
393 if [ -n "${vtdebug_flag}" ]; then
394 echo "Unknown unix type"
395 fi
396 fi
397 fi
398
399 vt_unix_chain_data ${1}${chosen_path}
400 ventoy_debug_pause
401 }
402
403
404 function uefi_windows_menu_func {
405 vt_windows_reset
406
407 if [ "$ventoy_compatible" = "NO" ]; then
408
409 if [ "$ventoy_fs_probe" = "iso9660" ]; then
410 loopback -d loop
411 vt_iso9660_nojoliet 1
412 loopback loop $1$2
413 fi
414
415 for file in "efi/microsoft/boot/bcd"; do
416 vt_windows_collect_wim_patch bcd (loop)/$file
417 done
418
419 vt_windows_count_wim_patch vt_wim_cnt
420 if [ $vt_wim_cnt -eq 0 ]; then
421 distro_specify_wim_patch_phase2
422 fi
423
424 ventoy_debug_pause
425 locate_wim
426 fi
427
428 vt_windows_chain_data ${1}${chosen_path}
429 ventoy_debug_pause
430
431 if [ -n "$vtoy_chain_mem_addr" ]; then
432 ventoy_cli_console
433 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
434 boot
435 else
436 echo "chain empty failed"
437 ventoy_pause
438 fi
439 }
440
441 function uefi_linux_menu_func {
442 if [ "$ventoy_compatible" = "NO" ]; then
443
444 if [ "$ventoy_fs_probe" = "udf" ]; then
445 loopback -d loop
446 set ventoy_fs_probe=iso9660
447 loopback loop $1$2
448 fi
449
450 vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
451
452 vt_linux_clear_initrd
453
454 if [ -d (loop)/pmagic ]; then
455 vt_linux_specify_initrd_file /pmagic/initrd.img
456 else
457 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
458 if [ -e (loop)/$file ]; then
459 vt_linux_parse_initrd_grub file (loop)/$file
460 fi
461 done
462 fi
463
464 # special process for special distros
465 if [ -d (loop)/loader/entries ]; then
466 vt_linux_parse_initrd_grub dir (loop)/loader/entries/
467 elif [ -d (loop)/boot/grub ]; then
468 vt_linux_parse_initrd_grub dir (loop)/boot/grub/
469 fi
470
471 distro_specify_initrd_file
472
473 vt_linux_initrd_count vtcount
474 if [ $vtcount -eq 0 ]; then
475 distro_specify_initrd_file_phase2
476
477 if [ "$vt_efi_dir" = "NO" ]; then
478 if [ -f (loop)/efi.img ]; then
479 vt_add_replace_file 0 "initrd"
480 fi
481 fi
482 fi
483
484 locate_initrd
485
486 if [ -d (loop)/loader/entries ]; then
487 vt_linux_get_main_initrd_index vtindex
488
489 if [ -d (loop)/arch ]; then
490 if [ -f (loop)/arch/boot/x86_64/archiso.img ]; then
491 vt_add_replace_file $vtindex "EFI\\archiso\\archiso.img"
492 elif [ -f (loop)/boot/initramfs_x86_64.img ]; then
493 vt_add_replace_file $vtindex "boot\\initramfs_x86_64.img"
494 fi
495 elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
496 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
497 elif [ -f (loop)/loader/entries/thinstation.conf ]; then
498 vt_add_replace_file $vtindex "boot\\initrd"
499 elif [ -f (loop)/loader/entries/pisi-efi-x86_64.conf ]; then
500 vt_add_replace_file $vtindex "EFI\\pisi\\initrd.img"
501 fi
502 elif [ -d (loop)/EFI/boot/entries ]; then
503 if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
504 vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
505 elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
506 vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
507 fi
508 elif [ -e (loop)/syslinux/alt0/full.cz ]; then
509 vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
510 set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
511
512
513 fi
514
515 fi
516
517 vt_linux_chain_data ${1}${chosen_path}
518
519 if [ -n "$vtoy_chain_mem_addr" ]; then
520 ventoy_cli_console
521 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}
522 boot
523 else
524 echo "chain empty failed"
525 ventoy_pause
526 fi
527 }
528
529 function uefi_unix_menu_func {
530 ventoy_unix_comm_proc $1 ${chosen_path}
531
532 if [ -n "$vtoy_chain_mem_addr" ]; then
533 ventoy_cli_console
534 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}
535 boot
536 else
537 echo "chain empty failed"
538 ventoy_pause
539 fi
540 }
541
542 function uefi_iso_menu_func {
543
544 if [ -d (loop)/ ]; then
545 loopback -d loop
546 fi
547
548 if [ -n "$vtisouefi" ]; then
549 set LoadIsoEfiDriver=on
550 unset vtisouefi
551 elif vt_check_mode 2; then
552 set LoadIsoEfiDriver=on
553 else
554 unset LoadIsoEfiDriver
555 fi
556
557 set chosen_path=$2
558 vt_select_auto_install ${chosen_path}
559 vt_select_persistence ${chosen_path}
560
561 if vt_is_udf ${1}${chosen_path}; then
562 set ventoy_fs_probe=udf
563 else
564 set ventoy_fs_probe=iso9660
565 vt_iso9660_nojoliet 0
566 fi
567
568 loopback loop ${1}${chosen_path}
569 get_os_type (loop)
570
571 if [ -d (loop)/EFI ]; then
572 set vt_efi_dir=YES
573 elif [ -d (loop)/efi ]; then
574 set vt_efi_dir=YES
575 else
576 set vt_efi_dir=NO
577 fi
578
579 if [ -n "$vtcompat" ]; then
580 set ventoy_compatible=YES
581 unset vtcompat
582 elif vt_check_mode 1; then
583 set ventoy_compatible=YES
584 else
585 vt_check_compatible (loop)
586 fi
587
588 vt_img_sector ${1}${chosen_path}
589
590 if [ "$vtoy_os" = "Windows" ]; then
591 vt_check_compatible_pe (loop)
592 uefi_windows_menu_func $1 ${chosen_path}
593 elif [ "$vtoy_os" = "Unix" ]; then
594 uefi_unix_menu_func $1 ${chosen_path}
595 else
596 uefi_linux_menu_func $1 ${chosen_path}
597 fi
598
599 ventoy_gui_console
600 }
601
602 function uefi_iso_memdisk {
603 echo 'Loading ISO file to memory ...'
604 vt_load_img_memdisk ${1}${2} vtoy_iso_buf
605
606 ventoy_cli_console
607 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}
608 boot
609
610 ventoy_gui_console
611 }
612
613
614 function legacy_windows_menu_func {
615 vt_windows_reset
616
617 if [ "$ventoy_compatible" = "NO" ]; then
618
619 if [ "$ventoy_fs_probe" = "iso9660" ]; then
620 loopback -d loop
621 vt_iso9660_nojoliet 1
622 loopback loop $1$2
623 fi
624
625 for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do
626 vt_windows_collect_wim_patch bcd (loop)/$file
627 done
628
629 distro_specify_wim_patch
630
631 vt_windows_count_wim_patch vt_wim_cnt
632 if [ $vt_wim_cnt -eq 0 ]; then
633 distro_specify_wim_patch_phase2
634 fi
635
636 ventoy_debug_pause
637 locate_wim
638 fi
639
640 vt_windows_chain_data ${1}${chosen_path}
641 ventoy_debug_pause
642
643 if [ -n "$vtoy_chain_mem_addr" ]; then
644 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
645 boot
646 else
647 echo "chain empty failed"
648 ventoy_pause
649 fi
650 }
651
652 function legacy_linux_menu_func {
653 if [ "$ventoy_compatible" = "NO" ]; then
654
655 if [ "$ventoy_fs_probe" = "udf" ]; then
656 loopback -d loop
657 set ventoy_fs_probe=iso9660
658 loopback loop $1$2
659 fi
660
661 vt_load_cpio $vtoy_path/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
662
663 vt_linux_clear_initrd
664
665 if [ -d (loop)/pmagic ]; then
666 vt_linux_specify_initrd_file /pmagic/initrd.img
667 else
668 for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do
669 if [ -d (loop)/$dir ]; then
670 vt_linux_parse_initrd_isolinux (loop)/$dir/
671 fi
672 done
673 fi
674
675 # special process for special distros
676 #archlinux
677 if [ -d (loop)/arch/boot/syslinux ]; then
678 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/
679 vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/
680
681 #manjaro
682 elif [ -d (loop)/manjaro ]; then
683 if [ -e (loop)/boot/grub/kernels.cfg ]; then
684 vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg
685 fi
686 elif [ -e (loop)/boot/grub/grub.cfg ]; then
687 vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg
688 fi
689
690 distro_specify_initrd_file
691
692 vt_linux_initrd_count vtcount
693 if [ $vtcount -eq 0 ]; then
694 if [ -d (loop)/rancheros ]; then
695 vt_linux_parse_initrd_isolinux (loop)/boot/ /boot/isolinux/
696 fi
697
698 distro_specify_initrd_file_phase2
699 fi
700
701 locate_initrd
702 fi
703
704 vt_linux_chain_data ${1}${chosen_path}
705 ventoy_debug_pause
706
707 if [ -n "$vtoy_chain_mem_addr" ]; then
708 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
709 boot
710 else
711 echo "chain empty failed"
712 ventoy_pause
713 fi
714 }
715
716
717 function legacy_unix_menu_func {
718 ventoy_unix_comm_proc $1 ${chosen_path}
719
720 if [ -n "$vtoy_chain_mem_addr" ]; then
721 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
722 boot
723 else
724 echo "chain empty failed"
725 ventoy_pause
726 fi
727 }
728
729
730 function legacy_iso_menu_func {
731
732 if [ -d (loop)/ ]; then
733 loopback -d loop
734 fi
735
736 set chosen_path=$2
737 vt_select_auto_install ${chosen_path}
738 vt_select_persistence ${chosen_path}
739
740 if vt_is_udf ${1}${chosen_path}; then
741 set ventoy_fs_probe=udf
742 else
743 set ventoy_fs_probe=iso9660
744 vt_iso9660_nojoliet 0
745 fi
746
747 loopback loop ${1}${chosen_path}
748
749 get_os_type (loop)
750
751 if [ -n "$vtcompat" ]; then
752 set ventoy_compatible=YES
753 unset vtcompat
754 elif vt_check_mode 1; then
755 set ventoy_compatible=YES
756 else
757 vt_check_compatible (loop)
758 fi
759
760 vt_img_sector ${1}${chosen_path}
761
762 if [ "$vtoy_os" = "Windows" ]; then
763 vt_check_compatible_pe (loop)
764 legacy_windows_menu_func $1 ${chosen_path}
765 elif [ "$vtoy_os" = "Unix" ]; then
766 legacy_unix_menu_func $1 ${chosen_path}
767 else
768 legacy_linux_menu_func $1 ${chosen_path}
769 fi
770 }
771
772 function legacy_iso_memdisk {
773
774 linux16 $vtoy_path/memdisk iso raw
775 echo "Loading ISO file to memory ..."
776 initrd16 ${1}${2}
777 boot
778 }
779
780
781 function iso_endless_os_proc {
782 if [ -d (loop)/ ]; then
783 loopback -d loop
784 fi
785
786 loopback loop ${1}${2}
787 vt_img_sector ${1}${2}
788
789 vt_load_cpio $vtoy_path/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
790 vt_trailer_cpio $1 $2 noinit
791
792 ventoy_debug_pause
793
794 vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
795
796 set eosimage=loop
797 set ventoy_bls_bootdev=/boot
798 set ventoy_loading_tip="Loading files ......"
799
800 export eosimage
801 configfile (loop)/endless/grub/grub.cfg
802
803 unset eosimage
804 unset ventoy_bls_bootdev
805 unset ventoy_loading_tip
806
807 vt_unset_boot_opt
808 }
809
810
811 function ventoy_iso_busybox_ver {
812 set ventoy_busybox_ver=32
813
814 #special process for deepin-live iso
815 if [ "$vt_chosen_size" = "403701760" ]; then
816 if vt_str_begin $vt_chosen_path "/deepin-live"; then
817 set ventoy_busybox_ver=64
818 fi
819 elif vt_str_begin $vt_volume_id "PHOTON_"; then
820 set ventoy_busybox_ver=64
821 elif vt_str_begin $vt_volume_id "smgl-test-quinq-x86_64"; then
822 set ventoy_busybox_ver=64
823
824 fi
825 }
826
827 function iso_common_menuentry {
828 unset vt_system_id
829 unset vt_volume_id
830
831 vt_chosen_img_path vt_chosen_path vt_chosen_size
832 vt_parse_iso_volume ${vtoy_iso_part}${vt_chosen_path} vt_system_id vt_volume_id
833
834 ventoy_iso_busybox_ver
835
836 #special process for Endless OS
837 if vt_str_begin $vt_volume_id "Endless-OS"; then
838 iso_endless_os_proc $vtoy_iso_part $vt_chosen_path
839 elif vt_str_begin $vt_volume_id "TENS-Public"; then
840 set vtcompat=1
841 fi
842
843 if [ "$grub_platform" = "pc" ]; then
844 if vt_check_mode 0; then
845 legacy_iso_memdisk $vtoy_iso_part $vt_chosen_path
846 else
847 legacy_iso_menu_func $vtoy_iso_part $vt_chosen_path
848 fi
849 else
850 if vt_check_mode 0; then
851 uefi_iso_memdisk $vtoy_iso_part $vt_chosen_path
852 else
853 uefi_iso_menu_func $vtoy_iso_part $vt_chosen_path
854 fi
855 fi
856 }
857
858 function common_unsupport_menuentry {
859 echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
860 echo -e " 文件名中不能有中文或空格 \n"
861 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
862 read vtInputKey
863 }
864
865 function iso_unsupport_menuentry {
866 common_unsupport_menuentry
867 }
868
869 function wim_common_menuentry {
870 vt_chosen_img_path vt_chosen_path vt_chosen_size
871 vt_wim_chain_data ${vtoy_iso_part}${vt_chosen_path}
872
873 ventoy_debug_pause
874
875 if [ -n "$vtoy_chain_mem_addr" ]; then
876 if [ "$grub_platform" = "pc" ]; then
877 linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
878 else
879 ventoy_cli_console
880 chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
881 ventoy_gui_console
882 fi
883 boot
884 else
885 echo "chain empty failed"
886 ventoy_pause
887 fi
888 }
889
890 function wim_unsupport_menuentry {
891 common_unsupport_menuentry
892 }
893
894 function efi_common_menuentry {
895 vt_chosen_img_path vt_chosen_path vt_chosen_size
896
897 vt_concat_efi_iso ${vtoy_iso_part}${vt_chosen_path} vtoy_iso_buf
898
899 ventoy_debug_pause
900
901 ventoy_cli_console
902
903 unset vtoy_dotefi_retry
904 chainloader ${vtoy_path}/ventoy_x64.efi memdisk env_param=${env_param} dotefi isoefi=on ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
905 boot
906
907 if [ -n "$vtoy_dotefi_retry" ]; then
908 unset vtoy_dotefi_retry
909 chainloader ${vtoy_iso_part}${vt_chosen_path}
910 boot
911 fi
912
913 ventoy_gui_console
914 }
915
916 function efi_unsupport_menuentry {
917 common_unsupport_menuentry
918 }
919
920 #
921 #============================================================#
922 # IMG file boot process #
923 #============================================================#
924 #
925
926
927 function ventoy_img_easyos {
928 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
929 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
930
931 loopback easysfs (vtimghd,1)/easy.sfs
932 vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
933
934 if [ -n "$vt_module_ver" ]; then
935 for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
936 vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
937 done
938 fi
939
940 ventoy_debug_pause
941
942 #boot image file
943 vt_set_boot_opt rdinit=/vtoy/vtoy
944 vt_img_hook_root
945
946 syslinux_configfile (vtimghd,1)/syslinux.cfg
947
948 vt_img_unhook_root
949 vt_unset_boot_opt
950 loopback -d easysfs
951 }
952
953 function ventoy_img_volumio {
954 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
955 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
956
957 ventoy_debug_pause
958
959 #boot image file
960 vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
961 vt_img_hook_root
962
963 syslinux_configfile (vtimghd,1)/syslinux.cfg
964
965 vt_img_unhook_root
966 vt_unset_boot_opt
967 }
968
969 function ventoy_img_openelec {
970 elec_ver=$1
971
972 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
973 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
974
975 loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
976 vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz
977
978 ventoy_debug_pause
979
980 #boot image file
981 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=$elec_ver
982 vt_img_hook_root
983
984 set root=(vtimghd,1)
985 syslinux_configfile (vtimghd,1)/syslinux.cfg
986
987 vt_img_unhook_root
988 vt_unset_boot_opt
989 loopback -d vtloopex
990 }
991
992
993 function ventoy_img_freedombox {
994 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
995 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
996
997 vt_get_lib_module_ver (vtimghd,1) /lib/modules/ vt_module_ver
998 if [ -n "$vt_module_ver" ]; then
999 vt_img_extra_initrd_append (vtimghd,1)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko
1000 fi
1001
1002 ventoy_debug_pause
1003
1004 #boot image file
1005 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=freedombox
1006 vt_img_hook_root
1007
1008 configfile (vtimghd,1)/boot/grub/grub.cfg
1009
1010 vt_img_unhook_root
1011 vt_unset_boot_opt
1012 }
1013
1014 function ventoy_img_paldo {
1015 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1016 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
1017
1018 ventoy_debug_pause
1019
1020 #boot image file
1021 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=paldo
1022 vt_img_hook_root
1023
1024 vt_fs_enum_1st_file (vtimghd,1) /loader/entries/ vt_paldo_entry_conf
1025 vt_file_basename $vt_paldo_entry_conf vtPaldoVer
1026
1027 echo loading file...
1028 linux (vtimghd,1)/linux-${vtPaldoVer} root=/dev/ventoy1 rootfstype=vfat
1029 initrd (vtimghd,1)/initramfs-${vtPaldoVer}
1030 boot
1031
1032 vt_img_unhook_root
1033 vt_unset_boot_opt
1034 }
1035
1036 function ventoy_img_ubos {
1037 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1038 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
1039
1040 vt_get_lib_module_ver (vtimghd,3) /lib/modules/ vt_module_ver
1041 if [ -n "$vt_module_ver" ]; then
1042 vt_img_extra_initrd_append (vtimghd,3)/lib/modules/$vt_module_ver/kernel/drivers/md/dm-mod.ko.xz
1043 fi
1044
1045 ventoy_debug_pause
1046
1047 #boot image file
1048 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=ubos
1049 vt_img_hook_root
1050
1051 echo loading file...
1052 linux (vtimghd,2)/vmlinuz-linux root=/dev/ventoy3 rw
1053 initrd (vtimghd,2)/initramfs-linux.img
1054 boot
1055
1056 vt_img_unhook_root
1057 vt_unset_boot_opt
1058 }
1059
1060 function ventoy_img_recalbox {
1061 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1062 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
1063
1064 ventoy_debug_pause
1065
1066 #boot image file
1067 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=recalbox
1068 vt_img_hook_root
1069
1070 set root=(vtimghd,1)
1071 configfile (vtimghd,1)/boot/grub/grub.cfg
1072
1073 vt_img_unhook_root
1074 vt_unset_boot_opt
1075 }
1076
1077 function ventoy_img_batocera {
1078 vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
1079 vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
1080
1081 ventoy_debug_pause
1082
1083 #boot image file
1084 vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=batocera
1085 vt_img_hook_root
1086
1087 set root=(vtimghd,1)
1088 syslinux_configfile (vtimghd,1)/boot/syslinux/syslinux.cfg
1089
1090 vt_img_unhook_root
1091 vt_unset_boot_opt
1092 }
1093
1094 function ventoy_img_memtest86 {
1095 chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
1096 boot
1097 }
1098
1099 function img_unsupport_tip {
1100 echo -e "\n This IMG file is NOT supported now. \n"
1101 echo -e " 当前不支持启动此 IMG 文件 \n"
1102 echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
1103 read vtInputKey
1104 }
1105
1106 function img_common_menuentry {
1107 set ventoy_compatible=YES
1108 set ventoy_busybox_ver=32
1109
1110 vt_chosen_img_path vt_chosen_path vt_chosen_size
1111
1112 if [ -d (vtimghd)/ ]; then
1113 loopback -d vtimghd
1114 fi
1115
1116 loopback vtimghd ${vtoy_iso_part}${vt_chosen_path}
1117 vt_img_sector ${vtoy_iso_part}${vt_chosen_path}
1118
1119 vt_img_part_info (vtimghd)
1120
1121 set vtback_root=$root
1122 ventoy_cli_console
1123 vt_push_last_entry
1124
1125 vt_img_extra_initrd_reset
1126
1127 vt_get_fs_label (vtimghd,1) vtImgHd1Label
1128 if [ -d (vtimghd,2)/lib ]; then
1129 vt_get_fs_label (vtimghd,2) vtImgHd2Label
1130 fi
1131
1132 if [ -e (vtimghd,1)/etc/hostname ]; then
1133 vt_1st_line (vtimghd,1)/etc/hostname vtImgHostname
1134 fi
1135
1136 if [ -e (vtimghd,1)/easy.sfs ]; then
1137 ventoy_img_easyos
1138 elif [ -e (vtimghd,1)/volumio.initrd ]; then
1139 ventoy_img_volumio
1140 elif vt_str_begin $vtImgHd1Label "LAKKA"; then
1141 ventoy_img_openelec lakka
1142 elif vt_str_begin $vtImgHd1Label "LIBREELEC"; then
1143 ventoy_img_openelec LibreELEC
1144 elif vt_str_begin $vtImgHd1Label "paldo-live"; then
1145 ventoy_img_paldo
1146 elif vt_str_begin $vtImgHostname "freedombox"; then
1147 ventoy_img_freedombox
1148 elif vt_str_begin $vtImgHd1Label "BATOCERA"; then
1149 ventoy_img_batocera
1150 elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
1151 ventoy_img_recalbox
1152 elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
1153 ventoy_img_ubos
1154 elif [ -f (vtimghd,1)/efi/boot/mt86.png ]; then
1155 if [ "$grub_platform" = "pc" ]; then
1156 img_unsupport_tip
1157 else
1158 ventoy_img_memtest86
1159 fi
1160 else
1161 if [ "$grub_platform" = "pc" ]; then
1162 img_unsupport_tip
1163 else
1164 vt_linux_chain_data ${vtoy_iso_part}${vt_chosen_path}
1165 chainloader ${vtoy_path}/ventoy_x64.efi sector512 env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
1166 boot
1167 fi
1168 fi
1169
1170 set root=$vtback_root
1171 vt_pop_last_entry
1172 ventoy_gui_console
1173 set ventoy_compatible=NO
1174 }
1175
1176 function img_unsupport_menuentry {
1177 common_unsupport_menuentry
1178 }
1179
1180 #############################################################
1181 #############################################################
1182 #############################################################
1183 ####### Main Process ###########
1184 #############################################################
1185 #############################################################
1186 #############################################################
1187
1188 set VENTOY_VERSION="1.0.20"
1189
1190 # Default menu display mode, you can change it as you want.
1191 # 0: List mode
1192 # 1: TreeView mode
1193 set VTOY_DEFAULT_MENU_MODE=0
1194
1195 set VTOY_MEM_DISK_STR="[Memdisk]"
1196 set VTOY_ISO_RAW_STR="Compatible Mode"
1197 set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
1198
1199 set VTOY_F2_CMD="ventoy_power"
1200 set VTOY_F4_CMD="ventoy_localboot"
1201 set VTOY_F5_CMD="ventoy_diagnosis"
1202 set VTOY_F6_CMD="ventoy_ext_menu"
1203
1204 if [ "$grub_platform" = "pc" ]; then
1205 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
1206 else
1207 set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
1208 fi
1209
1210 vt_device $root vtoy_dev
1211
1212 if [ "$vtoy_dev" = "tftp" ]; then
1213 set vtoy_path=($root)
1214 for vtid in 0 1 2 3; do
1215 if [ -d (hd$vtid,2)/ventoy ]; then
1216 set vtoy_iso_part=(hd$vtid,1)
1217 set vtoy_efi_part=(hd$vtid,2)
1218 break
1219 fi
1220 done
1221 loadfont ascii
1222
1223 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
1224 set vt_plugin_path=$vtoy_iso_part
1225 else
1226 set vt_plugin_path=$prefix
1227 vt_load_plugin $vt_plugin_path
1228 fi
1229 else
1230 if [ "$prefix" = "(ventoydisk)/grub" ]; then
1231 set vtoy_path=(ventoydisk)/ventoy
1232 else
1233 set vtoy_path=($root)/ventoy
1234 fi
1235
1236 set vtoy_iso_part=($vtoy_dev,1)
1237 set vtoy_efi_part=($vtoy_dev,2)
1238 loadfont unicode
1239 set vt_plugin_path=$vtoy_iso_part
1240 fi
1241
1242
1243 #Load Plugin
1244 if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then
1245 vt_load_plugin $vtoy_iso_part
1246 fi
1247
1248 if [ -n "$VTOY_MENU_TIMEOUT" ]; then
1249 set timeout=$VTOY_MENU_TIMEOUT
1250 else
1251 unset timeout
1252 fi
1253
1254 if [ -f $vtoy_iso_part/ventoy/ventoy_wimboot.img ]; then
1255 vt_load_wimboot $vtoy_iso_part/ventoy/ventoy_wimboot.img
1256 elif [ -f $vtoy_efi_part/ventoy/ventoy_wimboot.img ]; then
1257 vt_load_wimboot $vtoy_efi_part/ventoy/ventoy_wimboot.img
1258 fi
1259
1260
1261 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
1262 set VTOY_F3_CMD="vt_dynamic_menu 1 1"
1263 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Debug F6:ExMenu"
1264 else
1265 set VTOY_F3_CMD="vt_dynamic_menu 1 0"
1266 set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Debug F6:ExMenu"
1267 fi
1268
1269
1270 if [ -n "$vtoy_gfxmode" ]; then
1271 set gfxmode=$vtoy_gfxmode
1272 else
1273 set gfxmode=1920x1080,1366x768,1024x768
1274 fi
1275
1276 if [ "$vtoy_display_mode" = "CLI" ]; then
1277 terminal_output console
1278 elif [ "$vtoy_display_mode" = "serial" ]; then
1279 if [ -n "$vtoy_serial_param" ]; then
1280 serial $vtoy_serial_param
1281 fi
1282 terminal_input serial
1283 terminal_output serial
1284 elif [ "$vtoy_display_mode" = "serial_console" ]; then
1285 if [ -n "$vtoy_serial_param" ]; then
1286 serial $vtoy_serial_param
1287 fi
1288 terminal_input serial console
1289 terminal_output serial console
1290 else
1291 if [ -n "$vtoy_theme" ]; then
1292 set theme=$vtoy_theme
1293 else
1294 set theme=$prefix/themes/ventoy/theme.txt
1295 fi
1296 terminal_output gfxterm
1297 fi
1298
1299 #export necessary variable
1300 export theme
1301 export gfxmode
1302 export vtoy_dev
1303 export vtoy_iso_part
1304 export vtoy_efi_part
1305 export VENTOY_VERSION
1306
1307
1308
1309
1310 #colect all image files (iso files)
1311 set ventoy_img_count=0
1312 vt_list_img $vtoy_iso_part ventoy_img_count
1313
1314 #Main menu
1315 if [ $ventoy_img_count -gt 0 ]; then
1316 if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
1317 vt_dynamic_menu 0 0
1318 else
1319 vt_dynamic_menu 0 1
1320 fi
1321 else
1322 if [ -n "$VTOY_NO_ISO_TIP" ]; then
1323 NO_ISO_MENU="No ISO files found, $VTOY_NO_ISO_TIP"
1324 elif [ -n "$VTOY_DEFAULT_SEARCH_ROOT" ]; then
1325 NO_ISO_MENU="No ISO files found, please check VTOY_DEFAULT_SEARCH_ROOT"
1326 else
1327 NO_ISO_MENU="No ISO files found"
1328 fi
1329 menuentry "$NO_ISO_MENU (Press enter to reboot ...)" {
1330 echo -e "\n Rebooting ... "
1331 reboot
1332 }
1333 fi