iPXE discussion forum
iPXE menu checkbox feature possible? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: iPXE menu checkbox feature possible? (/showthread.php?tid=7786)



iPXE menu checkbox feature possible? - glenc2004 - 2015-08-07 04:24

Hello all. I wanted to ask everyone using ipxe if it's even possible to create checkbox type input for the user. So say you had several options for a server build you didn't necessarily want to create separate config files for. But just select able options during the install process and pass those menu options to the backend scripts.

I read someone you can do this with compiled menus but I can't seem to find that site again. If this is possible, can it be done dynamically?

Oh yes. If anyone has any samples or URL's that would be great too!

Thanks so much!

Glen


RE: menu.c32 options? - robinsmidsrod - 2016-03-17 12:36

It should be quite possible. You can make a dynamic menu where each menu item is a toogle variable, and you select the variable item to toggle it and finally use the "continue" menu item to start the process. Possibly something like this (untested):

Code:
#!ipxe
# Assign defaults
set var1 1
set var2 0
:render_menu
menu
iseq ${var1} 1 && item disable_var1 [x] Disable variable 1 ||
iseq ${var1} 0 && item  enable_var1 [ ] Enable variable 1 ||
iseq ${var2} 1 && item disable_var2 [x] Disable variable 2 ||
ideq ${var2} 0 && item  enable_var2 [ ] Enable variable 2 ||
item
item abort Abort process
item start Start process
choose selected && goto ${selected} || goto abort

:abort
exit

:enable_var1
set var1 1
goto render_menu

:disable_var1
set var1 0
goto render_menu

:enable_var2
set var2 1
goto render_menu

:disable_var2
set var2 0
goto render_menu

:start
echo Variable 1: ${var1}
echo Variable 2: ${var2}
chain http://myserver/myscript.php?var1=${var1}&var2=${var2}