for isofile in $isopath/nst-*.iso; do
  if [ -e "$isofile" ]; then
    regexp --set=isoname "$isopath/(.*)" "$isofile"
    submenu "$isoname ->" "$isofile" {
      iso_path="$2"
      loopback loop "$iso_path"
      probe --label --set=cd_label (loop)
      menuentry "Console" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force audit=0 systemd.unit=multi-user.target nstrelocate=false"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
      menuentry "Graphical Desktop" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force audit=0 rhgb systemd.unit=graphical.target nstrelocate=false"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
      menuentry "Server (Serial ttyS0 at 57600)" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force rd.dm=0 audit=0 console=tty0 console=ttyS0,57600n8 systemd.unit=multi-user.target nstrelocate=false"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
      menuentry "Rescue Mode" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force rd.dm=0 audit=0 systemd.unit=rescue.target nstrelocate=false"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
      menuentry "Reset Persistance Overlay & Reboot" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force rd.dm=0 audit=0 reset_overlay nstreboot systemd.unit=multi-user.target nstrelocate=false"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
      menuentry "Verify And Boot" {
        bootoptions="iso-scan/filename=$iso_path root=live:LABEL=$cd_label ro rd.live.image quiet acpi=force audit=0 rhgb rd.live.check"
        linux (loop)/isolinux/vmlinuz0 $bootoptions
        initrd (loop)/isolinux/initrd0.img
      }
    }
  fi
done

