for isofile in $isopath/slax-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Run Slax" {
        bootoptions="from=$iso_path vga=normal load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags="
        linux (loop)/slax/boot/vmlinuz $bootoptions
        initrd (loop)/slax/boot/initrfs.img
      }
      menuentry "Run Slax - Graphical desktop" {
        bootoptions="from=$iso_path vga=normal load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=xmode"
        linux (loop)/slax/boot/vmlinuz $bootoptions
        initrd (loop)/slax/boot/initrfs.img
      }
      menuentry "Run Slax - Copy to RAM" {
        bootoptions="from=$iso_path vga=normal load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=toram"
        linux (loop)/slax/boot/vmlinuz $bootoptions
        initrd (loop)/slax/boot/initrfs.img
      }
      menuentry "Run Slax - Act as PXE server" {
        bootoptions="from=$iso_path vga=normal load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 slax.flags=pxe"
        linux (loop)/slax/boot/vmlinuz $bootoptions
        initrd (loop)/slax/boot/initrfs.img
      }
    }
  fi
done
