for isofile in $isopath/debian-live-8*-i386-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Live (586)" {
        bootoptions="findiso=$iso_path boot=live components quiet splash"
        linux (loop)/live/vmlinuz1 $bootoptions
        initrd (loop)/live/initrd1.img
      }
      menuentry "Live (586 failsafe)" {
        bootoptions="findiso=$iso_path boot=live components memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal"
        linux (loop)/live/vmlinuz1 $bootoptions
        initrd (loop)/live/initrd1.img
      }
      menuentry "Live (686-pae)" {
        bootoptions="findiso=$iso_path boot=live components quiet splash"
        linux (loop)/live/vmlinuz2 $bootoptions
        initrd (loop)/live/initrd2.img
      }
      menuentry "Live (686-pae failsafe)" {
        bootoptions="findiso=$iso_path boot=live components memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal"
        linux (loop)/live/vmlinuz2 $bootoptions
        initrd (loop)/live/initrd2.img
      }
    }
  fi
done
