for isofile in $isopath/gparted-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "GParted Live (Default settings)" {
        bootoptions="findiso=$iso_path boot=live union=overlay username=user config components quiet noswap  ip= net.ifnames=0  nosplash"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "GParted Live (Default settings, KMS)" {
        bootoptions="findiso=$iso_path boot=live union=overlay username=user config components quiet noswap vga=791 ip= net.ifnames=0  nosplash"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "GParted Live (To RAM. Boot media can be removed later)" {
        bootoptions="findiso=$iso_path boot=live union=overlay username=user config components quiet noswap  toram=filesystem.squashfs ip= net.ifnames=0  nosplash"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "GParted Live (Safe graphic settings)" {
        bootoptions="findiso=$iso_path boot=live union=overlay username=user config components quiet noswap ip= net.ifnames=0 nomodeset vga=normal nosplash"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "GParted Live (Failsafe mode)" {
        bootoptions="findiso=$iso_path boot=live union=overlay username=user config components quiet noswap acpi=off irqpoll noapic noapm nodma nomce nolapic nosmpip= net.ifnames=0 nomodeset vga=normal nosplash"
        linux (loop)/live/vmlinuz $bootoptions
        initrd (loop)/live/initrd.img
      }
      menuentry "Memory test using Memtest86+" {
        bootoptions=""
        linux16 (loop)/live/memtest $bootoptions
      }
    }
  fi
done
