for isofile in $isopath/smartos-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      set root='loop'
      menuentry "SmartOS" {
        bootoptions="-B smartos=true"
        multiboot /platform/i86pc/kernel/amd64/unix /platform/i86pc/kernel/amd64/unix $bootoptions
        module /platform/i86pc/amd64/boot_archive /platform/i86pc/amd64/boot_archive type=rootfs name=ramdisk
      }
      menuentry "SmartOS noinstall/recovery (login/pw: root/root)" {
        bootoptions="-B standalone=true,noimport=true"
        multiboot /platform/i86pc/kernel/amd64/unix /platform/i86pc/kernel/amd64/unix $bootoptions
        module /platform/i86pc/amd64/boot_archive /platform/i86pc/amd64/boot_archive type=rootfs name=ramdisk
      }
      menuentry "SmartOS +kmdb" {
        bootoptions="-kd -B smartos=true"
        multiboot /platform/i86pc/kernel/amd64/unix /platform/i86pc/kernel/amd64/unix $bootoptions
        module /platform/i86pc/amd64/boot_archive /platform/i86pc/amd64/boot_archive type=rootfs name=ramdisk
      }
    }
  fi
done
