iPXE discussion forum

Full Version: Embedding a variable upon compile
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm just curious if it's possible to embed a variable when compiling undionly.kpxe

We have a situation where we need multiple serial baud rates - we have the ability specify which version of undionly.kpxe to use for that specific baud rate/machine that netboots, but we need a way to pass through the baud rate to the next installer.

Currently we have the ability to alter the version setting (http://ipxe.org/cfg/version) during compile, but we'd rather not use that method. I'm curious if there are any other settings/variables that we can alter the contents of.

Thanks!
(2015-07-29 16:07)nappington Wrote: [ -> ]I'm just curious if it's possible to embed a variable when compiling undionly.kpxe

We have a situation where we need multiple serial baud rates - we have the ability specify which version of undionly.kpxe to use for that specific baud rate/machine that netboots, but we need a way to pass through the baud rate to the next installer.

You could use an embedded script such as
Code:
#!ipxe
prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && shell ||
set serialspeed 19200
autoboot

it will set serialspeed variable and continue to boot.
or you can have this in the script based on mac or other options.
True that - however, that does require me to have a completely separate script for each serial speed variable and keep each of them up to date if I want to make any changes.

I would like to use a single embedded script so I'm wondering if there's any way to set it hardcoded into the binary itself, similar to how I can make changes to the 'version' setting on compilation.
You can create an setting that returns a separate value that you set on compile time.
But I don't see how that is easier than creating a build script..

Code:
#!/bin/bash
echo #!ipxe > embed.ipxe
echo set serialspeed $1 >> embed.ipxe
cat commonscript.ipxe >> embed.ipxe
make $2 EMBED=embed.ipxe

This will combine a variable and the base script when this buildscript is run.
So you will only have one script and the rest is still automatic.

adding an embeded script - is the same as setting it in the binary itself - just much easier then any alternative.
Thanks for the answer - I wonder if there's an easier way to do it and if there's a way simply pull the baud rate directly from an iPXE shell? e.g. it's already in a variable somewhere that I can echo.
Reference URL's