#!ipxe
# PXE Boot Menu with EFI/BIOS detection for 192.168.101.2 NFS
set menu-timeout 5000
set submenu-timeout 3000
set nfs-server 192.168.101.2
set nfs-base /f/iso
# CRITICAL FIX: Re-initialize the network device for iPXE commands
# The initial network config from PXE is often lost after chainloading.
dhcp || goto failed_dhcp
# -------------------

# Optional: detect firmware (0=Bios, 1=EFI)
iseq ${efi} 1 && echo Booting EFI client || echo Booting BIOS client

:start
menu PXE Boot Menu
item ubuntu24    Ubuntu 24.04 Server
item ubuntu25    Ubuntu 25 Desktop
item xubuntu24    Xubuntu 24.04 Desktop
item win10v1      Windows 10 20h2
item win10v2      Windows 10 22h2
item shell        iPXE Shell
choose target && goto ${target}
# -------------------
:ubuntu24
kernel http://${nfs-server}${nfs-base}/Ubuntu24Server/casper/vmlinuz boot=casper netboot=nfs nfsroot=${nfs-server}:${nfs-base}/Ubuntu24Server ip=dhcp
initrd http://${nfs-server}${nfs-base}/Ubuntu24Server/casper/initrd
boot

:ubuntu25
kernel http://${nfs-server}${nfs-base}/Ubuntu25Desktop/casper/vmlinuz boot=casper netboot=nfs nfsroot=${nfs-server}:${nfs-base}/Ubuntu25Desktop ip=dhcp
initrd http://${nfs-server}${nfs-base}/Ubuntu25Desktop/casper/initrd
boot

:xubuntu24
kernel http://${nfs-server}${nfs-base}/Xubuntu24Desktop/casper/vmlinuz boot=casper netboot=nfs nfsroot=${nfs-server}:${nfs-base}/Xubuntu24Desktop ip=dhcp
initrd http://${nfs-server}${nfs-base}/Xubuntu24Desktop/casper/initrd
boot

# -------------------
:win10v1
kernel nfs://${nfs-server}${nfs-base}/Win10v1/boot/wimboot
# *** CRITICAL CHANGE: Use HTTP for the large Windows files ***
initrd http://${nfs-server}/Win10v1/bootmgr bootmgr
initrd http://${nfs-server}/Win10v1/boot/bcd BCD
initrd http://${nfs-server}/Win10v1/boot/boot.sdi boot.sdi
initrd http://${nfs-server}/Win10v1/sources/boot.wim boot.wim
boot

:win10v2
kernel nfs://${nfs-server}${nfs-base}/Win10v2/boot/wimboot
# *** CRITICAL CHANGE: Use HTTP for the large Windows files ***
initrd http://${nfs-server}/Win10v2/bootmgr bootmgr
initrd http://${nfs-server}/Win10v2/boot/bcd BCD
initrd http://${nfs-server}/Win10v2/boot/boot.sdi boot.sdi
initrd http://${nfs-server}/Win10v2/sources/boot.wim boot.wim
boot
:failed_dhcp
echo DHCP failed. Check cables and server config.
shell
# -------------------
:shell
shell
