Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"include" directive for ipxe scripts?
2018-05-31, 19:35
Post: #1
"include" directive for ipxe scripts?
Hello there!

I can't seem to find a way to "include <path>/<file>" in ipxe scripts for easier sharing of the same piece of code instead of replicating that in each of scripts.

For example, we have a rather large portion of each of the iPXE files consumed by the part that deals with setting a proper console device depending on the manufacturer or model, etc.

<snip>
#
set space:string %20
#
# by default use ttyS0
set console:string ttyS0,115200n8
#
# overrides
iseq ${manufacturer:uristring} Dell && set console:string ttyS1,115200n8 ||
iseq ${manufacturer:uristring} Dell${space}Inc. && set console:string ttyS1,11
5200n8 ||
iseq ${manufacturer:uristring} Dell${space}${space}${space}${space} && set console:string ttyS1,115200n8 ||
iseq ${product:uristring} PowerEdge${space}R630 && set console:string ttyS0,115200n8 ||
iseq ${product:uristring} PowerEdge${space}R730xd && set console:string ttyS0,115200n8 ||
<snip>
and so on and so forth.

This part is obviously very repetitive and requires unnecessary maintenance to keep all iPXE scripts sync'ed up on updates.

It would've been much easier if I could separate that piece of code into a file that could be then sourced/included from each of iPXE scripts allowing very easy management as now I'd only need to update a single file (in git, example) and that's it as actual iPXE scripts would just include that file when they are read.

Is there such capability?
Thanks!
Find all posts by this user
Quote this message in a reply
2018-05-31, 19:49
Post: #2
RE: "include" directive for ipxe scripts?
you can just chain a different script, it will then execute and then return to the caller, but remember that this will require several roundtrips to the server to fetch the next part.
Instead I would recommend that you do server-side includes instead.

Use GitHub Discussions
VRAM bin
Visit this user's website Find all posts by this user
Quote this message in a reply
2018-05-31, 20:21
Post: #3
RE: "include" directive for ipxe scripts?
(2018-05-31 19:49)NiKiZe Wrote:  you can just chain a different script, it will then execute and then return to the caller, but remember that this will require several roundtrips to the server to fetch the next part.
Instead I would recommend that you do server-side includes instead.

Sure, I guess I try "chain <URL>" - thanks!

Not very clear on server-side includes though - are you talking about building ipxe script for a client dynamically on some http server with boot.php?
Find all posts by this user
Quote this message in a reply
2018-05-31, 20:25
Post: #4
RE: "include" directive for ipxe scripts?
I'm assuming http server yes.
PHP is one method
havinging myscript.php
Code:
<?php header("Content-Type: text/plain"); ?>
#!ipxe
some scripting here .....
<?php include("other_file.ipxe"); ?>
more script

Note that this is just psuedo, is not tested, and should not be taken as an actual working example, just as example of the basic steps involved

Use GitHub Discussions
VRAM bin
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)