for isofile in $isopath/KNOPPIX_*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      menuentry "Knoppix" {
        bootoptions="bootfrom=/mnt-iso/$iso_path lang=en apm=power-off nomce libata.force=noncq hpsa.hpsa_allow_any=1 loglevel=1"
        if cpuid -l; then # Check whether CPU is 64-bit
          linux (loop)/boot/isolinux/linux64 $bootoptions
        else
          linux (loop)/boot/isolinux/linux $bootoptions
        fi
        initrd (loop)/boot/isolinux/minirt.gz
      }
      menuentry "ADRIANE" {
        bootoptions="bootfrom=/mnt-iso/$iso_path lang=en apm=power-off video=640x480 nomce libata.force=noncq hpsa.hpsa_allow_any=1 loglevel=1 adriane"
        if cpuid -l; then # Check whether CPU is 64-bit
          linux (loop)/boot/isolinux/linux64 $bootoptions
        else
          linux (loop)/boot/isolinux/linux $bootoptions
        fi
        initrd (loop)/boot/isolinux/minirt.gz
      }
      menuentry "Knoppix debug mode" {
        bootoptions="bootfrom=/mnt-iso/$iso_path lang=en apm=power-off nomce hpsa.hpsa_allow_any=1 loglevel=1 debug"
        if cpuid -l; then # Check whether CPU is 64-bit
          linux (loop)/boot/isolinux/linux64 $bootoptions
        else
          linux (loop)/boot/isolinux/linux $bootoptions
        fi
        initrd (loop)/boot/isolinux/minirt.gz
      }
      menuentry "Failsafe" {
        bootoptions="bootfrom=/mnt-iso/$iso_path lang=en vga=normal atapicd nosound noapic nolapic noacpi pnpbios=off acpi=off nofstab noscsi nodma noapm nousb nopcmcia nofirewire noagp nomce hpsa.hpsa_allow_any=1 nonetwork nodhcp xmodule=vesa"
        if cpuid -l; then # Check whether CPU is 64-bit
          linux (loop)/boot/isolinux/linux64 $bootoptions
        else
          linux (loop)/boot/isolinux/linux $bootoptions
        fi
        initrd (loop)/boot/isolinux/minirt.gz
      }
      menuentry "Grub4DOS" {
        bootoptions="--config=;"
        linux16 (loop)/boot/isolinux/grub.exe $bootoptions
      }
      menuentry "RAM check" {
        bootoptions="foo"
        linux16 (loop)/boot/isolinux/memtest $bootoptions
      }
      menuentry "FreeDOS" {
        bootoptions=""
        linux16 (loop)/boot/isolinux/memdisk $bootoptions
        initrd16 (loop)/boot/isolinux/balder.img
      }
    }
  fi
done
