for isofile in $isopath/Parrot-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    # Skip netboot ISOs
    if regexp "mini" "$isofile"; then continue; fi
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Live" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Text" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount systemd.unit=multi-user.target"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "RAM mode" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount toram"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Forensics mode" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount noswap noautomount"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Persistence" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount persistence"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Encrypted persistence" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount persistent=cryptsetup persistence-encryption=luks persistence"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Failsafe (nomodeset)" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount nomodeset"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Failsafe (disable nvdia/amd gpu)" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount nouveau.modeset=0 nvidia.modeset=0 radeon.modeset=0"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Failsafe (strong errors prevention)" {
        bootoptions="findiso=$iso_path boot=live hostname=parrot splash noautomount config memtest noapic noapm nodma nomce nolapic nomodeset nosplash vga=normal"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
    }
  fi
done
