Skip to content

Instantly share code, notes, and snippets.

@robinsmidsrod
Created April 7, 2016 10:46
Show Gist options
  • Save robinsmidsrod/bbbd31b4af8a673dbbaf2f2f75fa224b to your computer and use it in GitHub Desktop.
Save robinsmidsrod/bbbd31b4af8a673dbbaf2f2f75fa224b to your computer and use it in GitHub Desktop.
iPXE embedded menu that tries to boot each network adapter in turn
#!ipxe
set timeout 1000
: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
isset ${net${i}/mac} && item --key ${i} net${i} net(${i}): ${net${i}/mac} - ${net${i}/bustype} ${net${i}/busloc:busdevfn} ${pci/${net${i}/busloc}.0.2}:${pci/${net${i}/busloc}.2.2} ${net${i}/chip} ||
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
choose --timeout ${timeout} selected && goto select || goto default
goto menu
:select
isset ${${selected}/mac} && goto nic || goto label
: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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment