iPXE discussion forum

Full Version: How to detect available download protocols or build options inside an iPXE script?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible, within an iPXE script, to base a conditional statement (or variable value) on whether or not a download protocol is available in the iPXE instance that is running?

IE: Use HTTP if available, if not, use a TFTP url for network booting, something like:

dhcp
isset ${19:integer} || goto noHttp
set url http://...
goto gotProto
:noHttp
set url tftp://....
:gotProto
echo Booting using ${url}
boot ${url}

Since DHCP option 19 is the feature indicator option for ipxe.http, but this doesn't seem to work, perhaps because the option is only set when iPXE is sending the DHCP request, but in this example it's testing the server response (?)

I know I could first try the HTTP and then fall back on the TFTP statement if it fails, but the output of this is messy.

Rob
(2016-02-05 01:08)robzr Wrote: [ -> ]Is it possible, within an iPXE script, to base a conditional statement (or variable value) on whether or not a download protocol is available in the iPXE instance that is running?
...
I know I could first try the HTTP and then fall back on the TFTP statement if it fails, but the output of this is messy.

Sorry; there's no way to do this in the scripting language. The DHCP server can test on the basis of the feature flags exposed via option 175 in the DHCPDISCOVER/DHCPREQUEST, but those same flags aren't visible to a script. As you guessed, testing options via e.g. ${175.19} won't work because it will be looking for that option in the server response rather than in the client request.

Michael
Thanks Michael. I ended up doing exactly that, reading the option with dhcpd, setting the url and passing it in option 130. Works great! Nice work on iPXE, I had a GRUB based PXE selector for a few kickstart and rescue images, I migrated it over to iPXE, and find it more flexible and intuitive, and it's been more reliable for me as well. Great stuff!

Rob
Reference URL's