Skip to content

Instantly share code, notes, and snippets.

@ngobach
Last active July 29, 2018 08:18
Show Gist options
  • Save ngobach/72d779677e14172af707f963438d53b4 to your computer and use it in GitHub Desktop.
Save ngobach/72d779677e14172af707f963438d53b4 to your computer and use it in GitHub Desktop.
set gfxpayload=text
set ISODIR=/LINUX
set PARAMS=splash
probe -u $LINUX --set=PARTUUID
export ISODIR PARAMS PARTUUID gfxpayload
insmod regexp
for f in ($LINUX)$ISODIR/*.iso; do
regexp -s "1:basename" "$ISODIR/(.*)\$" $f
type="os"
if regexp archlinux $basename; then type=arch
elif regexp deepin $basename; then type=deepin
elif regexp elementary $basename; then type=elementary
elif regexp kali $basename; then type=kali
elif regexp linuxmint $basename; then type=linuxmint
elif regexp manjaro $basename; then type=manjaro
elif regexp Parrot $basename; then type=parrot
elif regexp ubuntu $basename; then type=ubuntu
fi
menuentry --class icon-$type --class icon-os "-> $basename" "$ISODIR/$basename" $type {
file=$2; type=$3; cmdline=""; kernel=""; initrd=""
loopback loop ($LINUX)$file
if [ $? -ne 0 ]; then
echo "Failed to Mount loopback device!"
return 1
fi
for x in \
/casper/vmlinuz.efi \
/casper/vmlinuz \
/live/vmlinuz.efi \
/live/vmlinuz \
/arch/boot/x86_64/vmlinuz \
/isolinux/vmlinuz \
/boot/vmlinuz-x86_64 \
; do
if [ -f "(loop)$x" ]; then
kernel="(loop)$x"
break
fi
done
for x in \
/casper/initrd.lz \
/live/initrd.lz \
/live/initrd.img \
/arch/boot/x86_64/archiso.img \
/isolinux/initrd.img \
/boot/initramfs-x86_64.img \
; do
if [ -f "(loop)$x" ]; then
initrd="(loop)$x"
break
fi
done
# Boot parameter here
if regexp "(ubuntu|elementary|linuxmint)" $type; then
cmdline="boot=casper"
else
cmdline="boot=live"
fi
cmdline="$cmdline union=overlay livecd-installer iso-scan/ask_second_pass=true file=/cdrom/preseed/ubuntu.seed username=root hostname=bachnx earlymodules=loop rd.live.image noeject noprompt overlay=nonfree nonfree=yes"
cmdline="$cmdline img_dev=/dev/disk/by-uuid/$PARTUUID iso-scan/filename=$file findiso=$file img_loop=$file"
cmdline="$cmdline $PARAMS"
if keystatus --shift; then
echo "Shift pressed. Safe-boot mode."
cmdline="$cmdline config memtest noapic noapm nodma nomce nolapic nomodeset nosplash vga=normal"
sleep 3
fi
echo "-> ISO : $file"
echo "-> Type : $type"
echo "-> kernel : $kernel"
echo "-> initrd : $initrd"
echo "-> cmdline: $cmdline"
if [ -z "$kernel" -o -z "$initrd" ]; then
echo "Kernel or Initrd not found!"
wait 10
else
echo "Booting ..."
linux $kernel $cmdline
initrd $initrd
fi
}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment