iPXE discussion forum

Full Version: Advanced menu and advanced string parsing in iso image?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I'm wondering if it's possible to do any advanced menus putting a menu.pxe into the iso image prior to starting the chain load to my web server.

Here is what I'm interested in:

===== Install Menu =====

IP Address: <enter>
Hostname: <enter>
Netmask: <enter>
Gateway: <enter>

[ Build ] [ Shutdown ] [ Reboot ]

Be able to tab between all the options until the person is satisfied before pressing build?

Also I'd like to be able to rip apart the IP address and replace the last octet with a ".1" and use this as my default gateway. Easy/Hard/Impossible? I'm sure I could hack my way thru changing code but if it's possible to do it an easier way it would be nice to know.


By using http://ipxe.org/cmd/menu and http://ipxe.org/cmd/prompt you can do most of this.
also take a look at http://ipxe.org/cmd/config

string parsing is not supported in iPXE it's best to do that server side.

Also I would like to avoid possible future missunderstandings...
.pxe most often refer to a NBP PXE bootable binary.
If you have scripts for iPXE name them with the .ipxe extension instead.

So from that I'm assuming that "into the iso image" means by using: make bin/ipxe.iso EMBED=menu.ipxe
Thanks NiKiZe for the reply.

Completely understand about my second question. One of those nice to haves when you have to create something where the user may not have all the experience needed. Just trying to make it easier.

In regards to my 1st question...I probably didn't explain myself too well. Yes, I'm probably trying to use the embedded menu for too much. But what I'm looking to do is in that screen is display all at once then have the user to be able to enter values in those lines, tabbing between those lines until he/she is satisfied and then says go/enter/start/whatever. Something along what you would see in the config menu.

If the config menu was able to be configured to show only what I wanted that would work too. But it appears the config menu is what is it.
when you change a value that is set immediately, so to have save/cancel options you would have to have temporary variables, I see 2 alternatives here:
1. set temp vars, modify temp vars, when save is pressed copy the temp vars to the real values (and possibly cleanup to save memory)
2. set temp vars, modify real values, if canceled restore the real values from the temp vars. (and possibly cleanup to save memory)
I would go with 1. since that is the more safe approach.
You might be able to make use of the settings hierarchy that iPXE supports to do this in smart ways.

and it seems you might even be able to use the hierarchy to limit the configuration menu to what it should display values from (but it seems a bit buggy)

set myconfig/ip:ipv4 ${ip:ipv4}
set myconfig/netmask:ipv4 ${netmask:ipv4}
set myconfig/hostname ${hostname}
set myconfig/gateway:ipv4 ${gateway:ipv4}
config myconfig

there is also the login command which gives input fields as well.
I think what you want to do should be possible, but will need some specifications before being implemented, here is my take:
  • There needs to be a item --prompt to provide for editing settings
  • I also think there should be some kind of way of setting help text on items, or even settings, so at least something like item --helptext
  • You also wanted some kind of buttons, which will take a bit more work, but as a first step maybe it can be implemented like the ctrl-d and ctrl-x at the bottom of the screen. (further on maybe this can be extended to be buttons which you can switch between with left and right arrow keys)
Do you think that would cover your use-case?
(please don't misunderstand, I'm not going to be implement this so no promises on if/when or even how)

Just as a prof of concept you could try and use config, and even change the code in setting_ui.c to disable so it only shows the settings that you want it to show (that destroys the config command but might be ok as a test)

@mcb30 if you are reading this, it seems that config limits it scopes such as in builtin and smbios and netX/dhcp,
however in netX, or myconfig, for example unixtime shows up as well (but without any value) which makes those levels very long to go thru.
Reference URL's