for isofile in $isopath/OpenMandrivaLx.*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      boot_locale="locale.lang=en_US"
      boot_default="rootfstype=auto ro rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.live.image acpi_osi=Linux acpi_osi='!Windows 2012' acpi_backlight=vendor audit=0 logo.nologo"
      iso_path="$2"
      loopback loop "$iso_path"
      probe --label --set=cd_label (loop)
      menuentry "Start OpenMandriva Lx Linux in live mode" {
        bootoptions="iso-scan/filename=$iso_path $boot_default root=live:LABEL=$cd_label $boot_locale quiet rhgb splash=silent"
        linux (loop)/boot/vmlinuz0 $bootoptions
        initrd (loop)/boot/liveinitrd.img
      }
      menuentry "Install OpenMandriva Lx Linux" {
        bootoptions="iso-scan/filename=$iso_path $boot_default root=live:LABEL=$cd_label $boot_locale quiet rhgb splash=silent systemd.unit=calamares.target"
        linux (loop)/boot/vmlinuz0 $bootoptions
        initrd (loop)/boot/liveinitrd.img
      }
      menuentry "Start OpenMandriva Lx Linux in live mode in basic graphics mode" {
        bootoptions="iso-scan/filename=$iso_path $boot_default root=live:LABEL=$cd_label $boot_locale xdriver=vesa nomodeset plymouth.enable=0 vga=792 failsafe"
        linux (loop)/boot/vmlinuz0 $bootoptions
        initrd (loop)/boot/liveinitrd.img
      }
      menuentry "Install OpenMandriva Lx Linux in basic graphics mode" {
        bootoptions="iso-scan/filename=$iso_path $boot_default root=live:LABEL=$cd_label $boot_locale xdriver=vesa nomodeset plymouth.enable=0 vga=792 systemd.unit=calamares.target"
        linux (loop)/boot/vmlinuz0 $bootoptions
        initrd (loop)/boot/liveinitrd.img
      }
      menuentry "Test memory with Memtest86+" {
        bootoptions=""
        linux16 (loop)/boot/grub/memtest $bootoptions
      }
    }
  fi
done

