#!ipxe

set timeout 10000

:menu
menu Network boot options for ${uuid}
item --key a default Try to boot (a)ll network adapters in turn
item
#item --gap -- --- Detected network adapters ---
#set i:int8 0
#:loop
#ifopen net${i} && item --key ${i} net${i} net(${i}): ${netX/mac} - ${netX/bustype} ${netX/busloc:busdevfn} ${pci/${netX/busloc}.0.2}:${pci/${netX/busloc}.2.2} ${netX/chip} ; ifclose
#inc i
#iseq ${i} 10 || goto loop
item
item --gap -- --- Alternatives ---
item --key c config Open (c)onfiguration
item --key r reboot (R)eboot computer
item --key s shell Drop to iPXE (s)hell
item --key x exit  E(x)it and continue BIOS boot order
item --key a angestoepselt (a)ngestoepselt Iso Boot
choose --timeout ${timeout} selected && goto select || goto default
goto menu

:select
isset ${${selected}/mac} && goto nic || goto label

:angestoepselt
imgfree
set mirror http://deb.debian.org
set dir debian/dists/bookworm/main/installer-amd64/current/images/netboot/debian-installer/amd64
set mirrorcfg mirror/suite=bookworm
set install_params auto=true priority=critical preseed/url=http://10.200.4.12:8000/preseed.cfg
echo kernel ${mirror}/${dir}/linux ${install_params} ${mirrorcfg} -- quiet ${params} initrd=initrd.magic ${cmdline}
kernel ${mirror}/${dir}/linux ${install_params} ${mirrorcfg} -- quiet ${params} initrd=initrd.magic ${cmdline} 
initrd ${mirror}/${dir}/initrd.gz
boot

:nic
autoboot ${selected} && goto exit ||
echo Booting '${selected}' failed, exiting iPXE...
goto exit

:label
goto ${selected} || 
echo The label '${selected}' could not be found, returning to menu...
sleep 2
goto restart

:default
autoboot && goto exit ||
echo Booting failed, exiting iPXE...
goto exit

:config
config
goto restart

:shell
shell
goto restart

:restart
set timeout 0
goto menu

:reboot
reboot

:exit
echo Continuing BIOS boot order...
sleep 1
exit

