iPXE discussion forum
How to detect available download protocols or build options inside an iPXE script? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: How to detect available download protocols or build options inside an iPXE script? (/showthread.php?tid=7949)



How to detect available download protocols or build options inside an iPXE script? - robzr - 2016-02-05 01:08

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


RE: How to detect available download protocols or build options inside an iPXE script? - mcb30 - 2016-02-06 12:48

(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


RE: How to detect available download protocols or build options inside an iPXE script? - robzr - 2016-02-06 23:37

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