for isofile in $isopath/Sabayon_Linux_*_amd64_*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Start Sabayon" {
        bootoptions="isoboot=$iso_path overlayfs cdroot splash quiet --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Text Install" {
        bootoptions="isoboot=$iso_path overlayfs cdroot splash quiet systemd.unit=multi-user.target installer-text --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Safe Mode" {
        bootoptions="isoboot=$iso_path overlayfs cdroot noproprietary nomodeset pci=routeirq irqpoll nokvm modprobe.blacklist=nvidia modprobe.blacklist=nouveau modprobe.blacklist=nv xdriver=vesa --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Console mode" {
        bootoptions="isoboot=$iso_path overlayfs cdroot splash gentoo=nox systemd.unit=multi-user.target quiet --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Console mode (no splash)" {
        bootoptions="isoboot=$iso_path overlayfs cdroot gentoo=nox systemd.unit=multi-user.target quiet --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Check disc for defects" {
        bootoptions="isoboot=$iso_path overlayfs cdroot splash quiet checkdisc --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Debug mode" {
        bootoptions="isoboot=$iso_path overlayfs cdroot debug --"
        linux (loop)/boot/sabayon $bootoptions
        initrd (loop)/boot/sabayon.igz
      }
      menuentry "Memory test" {
        bootoptions="-"
        linux16 (loop)/boot/memtest $bootoptions
      }
    }
  fi
done
