for isofile in $isopath/Porteus-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Graphics mode" {
        bootoptions="from=$iso_path changes=/porteus"
        linux (loop)/boot/syslinux/vmlinuz $bootoptions
        initrd (loop)/boot/syslinux/initrd.xz
      }
      menuentry "Always Fresh" {
        bootoptions="from=$iso_path nomagic base_only norootcopy"
        linux (loop)/boot/syslinux/vmlinuz $bootoptions
        initrd (loop)/boot/syslinux/initrd.xz
      }
      menuentry "Copy To RAM" {
        bootoptions="from=$iso_path copy2ram"
        linux (loop)/boot/syslinux/vmlinuz $bootoptions
        initrd (loop)/boot/syslinux/initrd.xz
      }
      menuentry "Text mode" {
        bootoptions="from=$iso_path 3"
        linux (loop)/boot/syslinux/vmlinuz $bootoptions
        initrd (loop)/boot/syslinux/initrd.xz
      }
      menuentry "Porteus as PXE server" {
        bootoptions="from=$iso_path pxe"
        linux (loop)/boot/syslinux/vmlinuz $bootoptions
        initrd (loop)/boot/syslinux/initrd.xz
      }
      menuentry "PLoP BootManager" {
        bootoptions=""
        linux16 (loop)/boot/syslinux/plpbt $bootoptions
      }
    }
  fi
done
