for isofile in $isopath/gentoo-livedvd-x86-amd64-32ul-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Gentoo x86" {
        bootoptions="isoboot=$iso_path root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot console=tty1"
        linux (loop)/isolinux/gentoo $bootoptions
        initrd (loop)/isolinux/gentoo.xz
      }
      menuentry "Gentoo x86 nofb" {
        bootoptions="isoboot=$iso_path root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot nomodeset"
        linux (loop)/isolinux/gentoo $bootoptions
        initrd (loop)/isolinux/gentoo.xz
      }
      menuentry "Gentoo x86 amd64" {
        bootoptions="isoboot=$iso_path root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot console=tty1"
        linux (loop)/isolinux/gentoo64 $bootoptions
        initrd (loop)/isolinux/gentoo64.xz
      }
      menuentry "Gentoo x86 amd64 nofb" {
        bootoptions="isoboot=$iso_path root=/dev/ram0 init=/linuxrc dokeymap aufs looptype=squashfs loop=/image.squashfs cdroot nomodeset"
        linux (loop)/isolinux/gentoo64 $bootoptions
        initrd (loop)/isolinux/gentoo64.xz
      }
      menuentry "Memory testing utility - memtest86+" {
        bootoptions=""
        linux16 (loop)/boot/memtest86 $bootoptions
      }
    }
  fi
done
