iPXE discussion forum
[solved] Variable in boot menu - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: [solved] Variable in boot menu (/showthread.php?tid=20148)



[solved] Variable in boot menu - fred - 2019-10-11 21:37

Hello,

This is what I have and compil from rom-o-matic and work:
Code:
#!ipxe
dhcp
chain http://192.168.10.118/menu.ipxe
exit

But I want to passing variable in this menu something like:

Code:
#!ipxe
dhcp
chain ${menu-url}
exit

I see the complet menu of robinsmidsrod, and I tried:
Code:
#!ipxe
dhcp
# Global variables used by all other iPXE scripts
chain --autofree boot.ipxe.cfg ||


# Boot <boot-url>/menu.ipxe script if all other options have been exhausted
chain --replace --autofree ${menu-url} ||

And in boot.ipxe.cfg:
Code:
set boot-url http://192.168.10.118/

set menu-url ${boot-url}menu.ipxe

It's not working. Only when I compil this full IP.

I don't understand where is my error? Can you show me the way to work?
Thanks


RE: Variable in boot menu - NiKiZe - 2019-10-13 02:26

variables are set by http://ipxe.org/cmd/set and are kept between scripts
--autofree and --replace are only about how the script file itself is handled.

if you have chain boot.ipxe.cfg in your embedded script, after dhcp, it would try to use the default tftp path.
If your http server is on the same server (ip) as your original tftp server than you could use something like:
chain http://${netX/next-server}/boot.ipxe.cfg

You might want to use the config command from the iPXE shell to see what is set


RE: Variable in boot menu - fred - 2019-10-14 20:49

Hello,
Thanks for your answer.

I'm very very sorry, but I simply don't underdstand. Sorry...

Yes, my TFTP server is on the same IP.

I try this on rom-o-matic:
Code:
#!ipxe
dhcp

chain http://${net0/next-server}/boot.ipxe.cfg

chain --replace --autofree ${menu-url}

and in my boot.ipxe.cfg

Code:
set boot-url http://192.168.10.118/

set menu-url ${boot-url}menu.ipxe

And my root TFTP is:
Code:
|-- boot.ipxe.cfg
|-- iso
|   |-- win10
|   `-- winpe_amd64
|-- menu.ipxe
|-- snponly.efi

When I boot, I have error No boot device, no such file or directory and It's loop reboot.

Thanks


RE: Variable in boot menu - NiKiZe - 2019-10-14 23:20

I strongly suggest to use netX not net0

Could you please post the full error message that you are seeing? Including the ipxe.org url in the message?


RE: Variable in boot menu - fred - 2019-10-15 08:03

Hello,
I tried with netX, nothing better. Sorry.

screenshot

http://ipxe.org/err/2d03e1

???

Thanks


RE: Variable in boot menu - cckp - 2019-10-15 11:38

try add some sleep and echo in your script to ensure it's actually running


RE: Variable in boot menu - fred - 2019-10-15 12:27

I add:

sleep 5 between each step and add echo http://${netX/next-server}/boot.ipxe.cfg

Nothing sleep and nothing echo.

Sorry don't know...


RE: Variable in boot menu - MultimediaMan - 2019-10-16 23:42

Let's try with some debugging code inserted and also some troubleshooting options:

Code:
#!ipxe

dhcp

set menu-url http://${next-server}/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

The above script should give you a pretty clear idea of what if going on without having to do too many gymnastics with the keyboard.

I suspect the issue is a missing URI descriptor (tftp:// http://)...

Let us know the output.

Best,

M^3


RE: Variable in boot menu - fred - 2019-10-17 07:56

It's little bit better!
Something new!

With your script Mr MultimediaMan I have something like this:
Code:
http://192.168.10.1/menu.ipxe... No such file or directory (http://ipxe.org/2d0c618e)
Failure!

My PXE server ip is 192.168.10.118

192.168.10.1 is my router.

I also tried with:
Code:
set menu-url http://${netX/next-server}/menu.ipxe

Same IP display.

Near of solution?
Thanks to help me! Very cool!
Hope to read yours answers


RE: Variable in boot menu - MultimediaMan - 2019-10-17 08:12

OK, I have an idea of the problem...


Code:
#!ipxe

dhcp ||

echo ${3}
echo ${next-server}
sleep 5

set menu-url http://${next-server}/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

Please try that and post the output.

Best,

M^3


RE: Variable in boot menu - fred - 2019-10-17 08:19

The same:
Code:
192.168.10.1
192.168.10.1
initrd http://192.168.10.1/menu.ipxe
http://192.168.10.1/menu.ipxe no such file or directory No such file or directory (http://ipxe.org/2d0c618e)
Failure!
http://192.168.10.1/menu.ipxe no such file or directory No such file or directory (http://ipxe.org/2d0c618e)



RE: Variable in boot menu - MultimediaMan - 2019-10-17 18:40

OK, this problem is easy to fix. But the real problem is your DHCP server configuration. If you have configured an iPXE class in the DHCP Server, please check your settings there.

Can you post up your /etc/dhcp/dhcp.conf for the Subnet for PXE/iPXE and any global settings?

The Issue Is DHCP Option 66 ${next-server} is set to 192.168.10.1 but it should be set to 192.168.10.118

There are a couple of different ways to address this...

1: Use DHCP Option 17 ${root-path} (Best way IMHO) instead of relying on DHCP option 66 ${next-server}. ${root-path} is a string variable and can be anything up to 255 characters.

2: Fix your DHCP Option 66/ iPXE class.

3: Ghetto method (not using any DHCP-passed variables, using values burned into iPXE):

Code:
#!ipxe

dhcp

set menu-url http://192.168.10.118/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell



RE: Variable in boot menu - fred - 2019-10-18 10:00

I'm using DNSMASQ with proxy relay to my router.

This what I tried:

dnsmasq.conf
Code:
#===============================================================
# Configuration file for dnsmasq
#===============================================================
# Disable DNS Server (DNS already provide by the router)
port=0

# Enable DHCP logging
log-dhcp

# Respond to PXE requests for the specified network;
# run as DHCP proxy
dhcp-range=192.168.10.0, proxy

dhcp-option=17,/srv/tftp

#Detect the client architecture
dhcp-match=set:x86PC, option:client-arch, 0 #BIOS
dhcp-match=set:UEFI32, option:client-arch, 6 #UEFI32
dhcp-match=set:UEFI64, option:client-arch, 7 #UEFI64
dhcp-match=set:UEFI64, option:client-arch, 9 #EBC ->use the same bootloader as UEFI64

# Load different PXE boot image depending on client architecture (when runing not as a proxy DHCP)
#dhcp-boot=tag:x86PC, lpxelinux.0
#dhcp-boot=tag:UEFI32, snponly.efi
#dhcp-boot=tag:UEFI64, snponly.efi
dhcp-boot=tag:UEFI64, snponly.efi

# Load different PXE boot image depending on client architecture (when runing as a proxy DHCP)
#pxe-service=tag:x86PC, X86PC, "BIOS Network Boot", lpxelinux.0
#pxe-service=tag:UEFI32, BC_EFI, "UEFI32 Network Boot", snponly.efi
pxe-service=tag:UEFI64, X86-64_EFI, "UEFI64 Network Boot", snponly.efi

## Activate TFTP and set the root directory
enable-tftp
tftp-no-blocksize
tftp-root=/srv/tftp


And new boot efi:
Code:
#!ipxe

dhcp ||

echo ${3}
echo ${root-path}
sleep 5

set menu-url ${root-path}/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

But no more.

echo ${root-path} show me 192.168.10.1

And echo ${root-path}/menu.ipxe show me /menu.ipxe ... no such file or directory

Thanks


RE: Variable in boot menu - MultimediaMan - 2019-10-18 10:31

OK, add these lines in your DNSMASQ:

Replace Line 14 with the following and restart DNSMASQ:

Code:
dhcp-option=17,http://192.168.10.118/
dhcp-option=66,192.168.10.1

Here is your new embedded script:

Code:
#!ipxe

dhcp ||

echo ${3}
echo ${17}
sleep 5

set menu-url ${17}/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

Best,

M^3


RE: Variable in boot menu - fred - 2019-10-18 11:06

Sorry, same result.
Error
echo ${3} show me 192.168.10.1
echo ${17} is empty

initrd http:///menu.ipxe

Failure! (ipxe.org/err/3e11618e)

And that what I tried now:

My snponly.efi built with:
Code:
#!ipxe

dhcp ||

echo ${3}
echo ${17}
echo ${66}
sleep 5

set menu-url http://${66}/menu.ipxe

#debugging lines below
echo initrd ${menu-url}
initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 5
goto command

:failure
echo Failure!
sleep 5

:command
#Actual Command...
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

because show 66 return me the right IP of my pxe-server.

And It's works.

echo ${3} show me 192.168.10.1
echo ${17} empty
echo ${66} show me 192.168.10.118

But I'm not feel good with this solution. But maybe you can explain me. This morning (for me) I don't know dhcp-option before you show me.
Why option 66 show me the right IP instead of 192.168.10.1 like in dnsmasq.conf?!
Does I need to change something to have a "right classical" configuration?

Thanks and sorry for distrub, I would like to have good config.


RE: Variable in boot menu - MultimediaMan - 2019-10-18 11:39

What you have will work.

DNSMASQ will assume to use the DNSMASQ Server IP for all standard DHCP options unless you tell it otherwise.

IMHO, you are good right now with what you have... there are "better" ways to do it (Using DNS names and more generic Variables), but you are on the right path for now at least.

Best,

M^3


RE: Variable in boot menu - fred - 2019-10-18 12:36

Thanks,
I will continue and post when I have finish.


RE: Variable in boot menu - fred - 2019-10-20 15:07

My final snponly.efi generate by rom-o-matic that work:

UEFI + dnsmasq

Code:
#!ipxe

dhcp ||

echo IP pxe server: ${66}
sleep 2

set menu-url http://${66}/menu.ipxe

initrd ${menu-url} && goto success || goto failure

:success
echo Success!
sleep 2
goto command

:failure
echo Failure!
sleep 2

:command
chain ${menu-url} ||

#For Troubleshooting after Failure...
shell

Hop can help.
Many thanks for your help!