"include" directive for ipxe scripts? - Printable Version +- iPXE discussion forum (https://forum.ipxe.org) +-- Forum: iPXE user forums (/forumdisplay.php?fid=1) +--- Forum: General (/forumdisplay.php?fid=2) +--- Thread: "include" directive for ipxe scripts? (/showthread.php?tid=11336) |
"include" directive for ipxe scripts? - korekhov - 2018-05-31 19:35 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! RE: "include" directive for ipxe scripts? - NiKiZe - 2018-05-31 19:49 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. RE: "include" directive for ipxe scripts? - korekhov - 2018-05-31 20:21 (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. 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? RE: "include" directive for ipxe scripts? - NiKiZe - 2018-05-31 20:25 I'm assuming http server yes. PHP is one method havinging myscript.php Code: <?php header("Content-Type: text/plain"); ?> 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 |