iPXE discussion forum
Embedding a variable upon compile - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: Embedding a variable upon compile (/showthread.php?tid=7785)



Embedding a variable upon compile - nappington - 2015-07-29 16:07

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!


RE: Embedding a variable upon compile - NiKiZe - 2015-07-29 18:25

(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.


RE: Embedding a variable upon compile - nappington - 2015-07-30 02:29

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.


RE: Embedding a variable upon compile - NiKiZe - 2015-08-01 08:00

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.


RE: Embedding a variable upon compile - nappington - 2015-08-02 20:05

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.