|
menuentry "[L]用Linux方式启动ISO" --hotkey="L" --class iso{
echo (正在查找ISO内的Linux启动文件,请等待。。即将菜单末尾列出启动文件)
set k="1"
GetHotkey
regexp -s 1:devstr -s 2:path '\((.*)\)(.*)' "$grub_file"
for cfg in /boot/grub/loopback.cfg /efi/boot/loopback.cfg /EFI/BOOT/loopback.cfg; do
if ! test -e (isoloop)$cfg; then continue; fi
cat -s cfgtext (isoloop)$cfg
if regexp '/grub/grub.cfg' "$cfgtext"; then
if ! test -e (isoloop)/grub/grub.cfg; then continue; fi
fi
if regexp '/casper/initrd.lz' "$cfgtext"; then
if ! test -e (isoloop)/casper/initrd.lz; then continue; fi
fi
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$devstr" "$cfg" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
probe -u -s rootuuid $4
export rootuuid
set iso_path="$3"
export iso_path
loopback isoloop "$2"
set root=isoloop
configfile $5
loopback -d isoloop
}
unset cfgtext
loopback -d isoloop
return 0
done
for cfg in /boot/grub/grub.cfg /EFI/BOOT/grub.cfg /EFI/boot/grub.cfg /boot/grub2/grub.cfg \
/efi/boot/grub.cfg /isolinux/live.cfg /boot/isolinux/isolinux.cfg /slax/boot/syslinux.cfg /isolinux/txt.cfg; do
if ! test -e (isoloop)$cfg; then continue; fi
cat -s cfgtext (isoloop)$cfg
if regexp 'iso_path' "$cfgtext"; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$devstr" "$cfg" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
probe -u -s rootuuid $4
export rootuuid
set iso_path="$3"
export iso_path
loopback isoloop "$2"
set root=isoloop
configfile $5
loopback -d isoloop
}
set loopok=1
elif regexp 'boot=casper' "$cfgtext"; then
if test -f (isoloop)/casper/filesystem.squashfs -a -f (isoloop)/casper/vmlinu* -a -f (isoloop)/casper/initr*; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
for preseed in (isoloop)/preseed/*; do
regexp -s preseed '\(isoloop\)(.*)' "$preseed"
preseed="file=/cdrom/${preseed}"
break
done
for vmlinuz in (isoloop)/casper/vmlinu*; do
linux $vmlinuz ${preseed} boot=casper locale=zh_CN locales=zh_CN.UTF-8 iso-scan/filename=${3} quiet splash ---
unset vmlinuz
break
done
for initrd in (isoloop)/casper/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
fi
elif regexp 'boot=live' "$cfgtext"; then
if test -f (isoloop)/live/filesystem.squashfs -a -f (isoloop)/live/vmlinu* -a -f (isoloop)/live/initr*; then
if regexp 'menuentry "Clonezilla' "$cfgtext"; then set params="union=overlay username=user config noswap edd=on nomodeset locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 ip= net.ifnames=0 nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1";
elif regexp 'menuentry "GParted' "$cfgtext"; then set params="union=overlay username=user config noswap ip= net.ifnames=0 nosplash";
else set params="splash"; fi
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$params" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
for vmlinuz in (isoloop)/live/vmlinu*; do
linux $vmlinuz boot=live locale=zh_CN locales=zh_CN.UTF-8 findiso=${3} components quiet ${4}
unset vmlinuz
break
done
for initrd in (isoloop)/live/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
fi
elif regexp 'rd.live.image' "$cfgtext"; then
if test -d (isoloop)/LiveOS; then
set isodev="UUID"
if test -f (isoloop)/images/pxeboot/vmlinu* -a -f (isoloop)/images/pxeboot/initr*; then set bootpath="/images/pxeboot";
elif test -f (isoloop)/isolinux/vmlinu* -a -f (isoloop)/isolinux/initr*; then set bootpath="/isolinux";
elif test -f (isoloop)/boot/*/loader/linu* -a -f (isoloop)/boot/*/loader/initr*; then
for bootpath in /boot/*/loader; do
if test -d (isoloop)$bootpath; then set isodev="CDLABEL"; break; fi
done
fi
fi
if [ -n "$bootpath" ]; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$bootpath" "$isodev" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
if [ "$5" == "UUID" ]; then probe -u -s isouuid isoloop; else probe -l -s isouuid isoloop; fi
for vmlinuz in (isoloop)${4}/vmlinu* (isoloop)${4}/linu*; do
if ! test -e $vmlinuz; then continue; fi
linux $vmlinuz root=live:${5}=${isouuid} rd.live.image quiet iso-scan/filename=${3}
unset vmlinuz
unset isouuid
break
done
for initrd in (isoloop)${4}/initr*; do
if ! test -e $initrd; then continue; fi
initrd $initrd
unset initrd
break
done
}
unset isodev
unset bootpath
set loopok=1
fi
elif regexp 'inst.stage2=hd:' "$cfgtext"; then
if test -f (isoloop)/images/pxeboot/vmlinu* -a -f (isoloop)/images/pxeboot/initr* -a -d (isoloop)/LiveOS; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
probe -u -s isouuid isoloop
for vmlinuz in (isoloop)/images/pxeboot/vmlinu*; do
linux $vmlinuz inst.stage2=hd:UUID=${isouuid} rd.live.image quiet iso-scan/filename=${3}
unset vmlinuz
unset isouuid
break
done
for initrd in (isoloop)/images/pxeboot/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
fi
elif regexp "initrd=/boot/initrd.gz root=/dev/ram0 vga=normal" "$cfgtext"; then
if test -f (isoloop)/boot/initrd.gz -a -f (isoloop)/boot/bzImage; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/boot/bzImage root=/dev/ram0 vga=normal
initrd (isoloop)/boot/initrd.gz
}
set loopok=1
fi
elif regexp "tinycore.gz" "$cfgtext"; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$cfg" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
set root=isoloop
if regexp 'isolinux.cfg' "$3"; then syslinux_configfile $3; else configfile $3; fi
}
set loopok=1
fi
unset cfgtext
if [ -n "$loopok" ]; then loopback -d isoloop; unset loopok; return 0; fi
done
if test -f (isoloop)/casper/filesystem.squashfs -a -f (isoloop)/casper/vmlinu* -a -f (isoloop)/casper/initr*; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
for preseed in (isoloop)/preseed/*; do
regexp -s preseed '\(isoloop\)(.*)' "$preseed"
preseed="file=/cdrom/${preseed}"
break
done
for vmlinuz in (isoloop)/casper/vmlinu*; do
linux $vmlinuz ${preseed} boot=casper iso-scan/filename=${3} quiet splash ---
unset vmlinuz
break
done
for initrd in (isoloop)/casper/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
elif test -f (isoloop)/live/filesystem.squashfs -a -f (isoloop)/live/vmlinu* -a -f (isoloop)/live/initr*; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
for vmlinuz in (isoloop)/live/vmlinu*; do
linux $vmlinuz boot=live findiso=${3} components quiet splash
unset vmlinuz
break
done
for initrd in (isoloop)/live/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
elif test -f (isoloop)/arch/boot/intel_ucode.img -a -f (isoloop)/arch/boot/*/archiso.img -a -f (isoloop)/arch/boot/*/vmlinuz; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$devstr" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
probe -u -s devuuid $4
for vmlinuz in (isoloop)/arch/boot/*/vmlinuz; do
linux $vmlinuz img_loop=${3} img_dev=/dev/disk/by-uuid/$devuuid earlymodules=loop
unset vmlinuz
unset devuuid
break
done
for initrd in (isoloop)/arch/boot/*/archiso.img; do
initrd (isoloop)/arch/boot/intel_ucode.img $initrd
unset initrd
break
done
}
set loopok=1
elif test -f (isoloop)/antiX/vmlinu* -a -f (isoloop)/antiX/initr*; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
for vmlinuz in (isoloop)/antiX/vmlinu*; do
linux $vmlinuz quiet fromiso=${3} from=usb,cd,hd
unset vmlinuz
break
done
for initrd in (isoloop)/antiX/initr*; do
initrd $initrd
unset initrd
break
done
}
set loopok=1
elif test -e (isoloop)/rescue/livecd.squashfs -a -e (isoloop)/boot/kernel.x86_64-efi -a -e (isoloop)/boot/initfs.x86_64-efi \
-a -e (isoloop)/boot/kernel.i386-pc -a -e (isoloop)/boot/initfs.i386-pc; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
if cpuid -l; then set arch="x86_64-efi"; else set arch="i386-pc"; fi
linux (isoloop)/boot/kernel.${arch} root=/dev/ram0 real_root=/dev/loop0 loop=/rescue/livecd.squashfs cdroot_marker=/rescue/livecd.squashfs initrd udev cdroot scandelay=10 quiet splash isoboot=${3} lang=en
initrd (isoloop)/boot/initfs.${arch}
}
set loopok=1
elif test -e (isoloop)/pmagic/m64.img -a -e (isoloop)/pmagic/m32.img -a -e (isoloop)/pmagic/bzImage64 -a -e (isoloop)/pmagic/bzImage \
-a -e (isoloop)/pmagic/fu.img -a -e (isoloop)/pmagic/initrd.img; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
if cpuid -l; then set bz="bzImage64"; set m="m64.img"; else set bz="bzImage"; set m="m32.img"; fi
linux (isoloop)/pmagic/${bz} edd=on vga=normal iso_filename=${3}
initrd (isoloop)/pmagic/initrd.img (isoloop)/pmagic/fu.img (isoloop)/pmagic/${m}
}
set loopok=1
elif test -e (isoloop)/image.squashfs -a -e (isoloop)/livecd -a -e (isoloop)/isolinux/gentoo -a -e (isoloop)/isolinux/gentoo.igz; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/isolinux/gentoo root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot vga=791 isoboot=${3}
initrd (isoloop)/isolinux/gentoo.igz
}
set loopok=1
elif test -e (isoloop)/image.squashfs -a -e (isoloop)/livecd -a -e (isoloop)/isolinux/gentoo -a -e (isoloop)/isolinux/gentoo.xz; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/isolinux/gentoo root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot console=tty1 isoboot=${3}
initrd (isoloop)/isolinux/gentoo.xz
}
set loopok=1
elif test -e (isoloop)/slax/boot/vmlinuz -a -e (isoloop)/slax/boot/initrfs.img; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/slax/boot/vmlinuz vga=normal load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=automount from=$3
initrd (isoloop)/slax/boot/initrfs.img
}
set loopok=1
elif test -e (isoloop)/liveslak -a -e (isoloop)/boot/generic -a -e (isoloop)/boot/initrd.img; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$devstr" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
probe -u -s deviceuuid $4
linux (isoloop)/boot/generic load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 kbd=us tz=localtime locale=us_EN.utf8 livemedia=/dev/disk/by-uuid/${deviceuuid}:$3
initrd (isoloop)/boot/initrd.img
}
set loopok=1
elif test -e (isoloop)/wifislax64 -a -e (isoloop)/boot/vmlinuz -a -e (isoloop)/boot/initrd.xz; then
menuentry "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$devstr" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
probe -u -s deviceuuid $4
linux (isoloop)/boot/vmlinuz kbd=us tz=US/Pacific locale=en_US.utf8 xkb= rw livemedia=/dev/disk/by-uuid/${deviceuuid}:$3
initrd (isoloop)/boot/initrd.xz
}
set loopok=1
elif test -e (isoloop)/wifislax -a -e (isoloop)/boot/vmlinuz -a -e (isoloop)/boot/initrd.xz; then
menuentry "[${k}] ${2} (Wifislax With KDE Desktop)" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/boot/vmlinuz noload=000-SMP\;006-Xfce load=English from=${3}
initrd (isoloop)/boot/initrd.xz
}
GetHotkey
menuentry "[${k}] ${2} (Wifislax With Xfce Desktop)" "$grub_file" "$path" --hotkey="${k}" --class ArrowR {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux (isoloop)/boot/vmlinuz noload=000-SMP\;005-Kde load=English from=${3}
initrd (isoloop)/boot/initrd.xz
}
set loopok=1
elif test -e (isoloop)/suse -a -e (isoloop)/boot/*/loader/initrd -a -e (isoloop)/boot/*/loader/linux; then
for vmlinuz in (isoloop)/boot/*/loader/linux; do
if ! test -e $vmlinuz; then continue; fi
break
done
for initrd in (isoloop)/boot/*/loader/initrd; do
if ! test -e $initrd; then continue; fi
break
done
submenu "[${k}] ${2}立即启动$grub_file" "$grub_file" "$path" "$vmlinuz" "$initrd" --hotkey="${k}" --class ArrowR {
menuentry "[1] Installation" "$2" "$3" "$4" "$5" --hotkey=1 {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux ${4} splash=silent install=hd:${3}
initrd ${5}
}
menuentry "[2] Upgrade" "$grub_file" "$path" "$4" "$5" --hotkey=2 {
echo (正在后台加载文件,请等待。。)
loopback isoloop "$2"
linux ${4} splash=silent upgrade=1 install=hd:${3}
initrd ${5}
}
}
unset vmlinuz
unset initrd
set loopok=1
fi
if [ -n "$loopok" ]; then loopback -d isoloop; unset loopok; return 0; fi
loopback -d isoloop
} |
|