for isofile in $isopath/ubuntu-*mini-i386.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Install" {
        bootoptions="vga=788 --- quiet"
        linux (loop)/linux $bootoptions
        initrd (loop)/initrd.gz
      }
      menuentry "Command-line install" {
        bootoptions="tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=788 --- quiet"
        linux (loop)/linux $bootoptions
        initrd (loop)/initrd.gz
      }
      submenu "Advanced options ->" {
        menuentry "Expert install" {
          bootoptions="priority=low vga=788 ---"
          linux (loop)/linux $bootoptions
          initrd (loop)/initrd.gz
        }
        menuentry "Command-line expert instal" {
          bootoptions="tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false priority=low vga=788 ---"
          linux (loop)/linux $bootoptions
          initrd (loop)/initrd.gz
        }
        menuentry "Rescue mode" {
          bootoptions="vga=788 rescue/enable=true --- quiet"
          linux (loop)/linux $bootoptions
          initrd (loop)/initrd.gz
        }
      }
    }
  fi
done
