summaryrefslogtreecommitdiffstats
path: root/src/image/script.c
Commit message (Collapse)AuthorAgeFilesLines
* [script] Allow scripts to be replacedMichael Brown2011-03-091-2/+6
| | | | | | | | | A script that downloads a new image using imgdownload() with the action register_and_replace_image() can now be freed immediately before the replacement image is executed. This functionality is not yet exposed via an iPXE command. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Generalise "currently-running script" to "currently-running image"Michael Brown2011-03-091-22/+12Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [prefix] Allow iPXE's own command line to be executed as a scriptMichael Brown2011-03-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Some prefixes (e.g. .lkrn) allow a command line to be passed in to iPXE. At present, this command line is ignored. If a command line is provided, treat it as an embedded script (without an explicit "#!ipxe" magic marker). This allows for patterns of invocation such as title iPXE kernel /boot/ipxe.lkrn dhcp && \ sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage Here GRUB is instructed to load ipxe.lkrn with an embedded script equivalent to #!ipxe dhcp sanboot iscsi:10.0.4.1::::iqn.2010-04.org.ipxe.dolphin:storage This can be used to effectively vary the embedded script without having to rebuild ipxe.lkrn. Originally-implemented-by: Dave Hansen <dave@sr71.net> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Add "prompt" commandMichael Brown2011-03-071-0/+67
| | | | | | | | | | | | | The "prompt" command exposes the prompt() function, allowing a script to prompt the user for a keypress and take action depending on the result. For example #!ipxe prompt -k 0x197e -t 2000 Press F12 to boot from network... || exit autoboot Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Add an iPXE error URI to the "not in a script" messageMichael Brown2011-03-071-2/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Simplify image managementMichael Brown2011-03-071-12/+3Star
| | | | | | | | | | | Refactor the {load,exec} image operations as {probe,exec}. This makes the probe mechanism cleaner, eliminates some forward declarations, avoids holding magic state in image->priv, eliminates the possibility of screwing up between the "load" and "exec" stages, and makes the documentation simpler since the concept of "loading" (as distinct from "executing") no longer needs to be explained. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [parseopt] Refer to online documentation for command helpMichael Brown2011-03-041-2/+1Star
| | | | | | | | | | The online documentation (e.g. http://ipxe.org/cmd/ifopen), though not yet complete, is far more comprehensive than could be provided within the iPXE binary. Save around 200 bytes (compressed) by removing the command descriptions from the interactive help, and instead referring users directly to the web page describing the relevant command. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Remove "Aborting on <line>" messageMichael Brown2010-11-291-3/+1Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Match user expectations for &&, ||, goto, and exitMichael Brown2010-11-291-7/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The && and || operators should be left-associative, since that is how they are treated in most other languages (including C and Unix shell). For example, in the command: dhcp net0 && goto dhcp_ok || echo No DHCP on net0 if the "dhcp net0" fails then the "echo" should be executed. After an "exit" or a successful "goto", further commands on the same line should never be executed. For example: goto somewhere && echo This should never be printed exit 0 && echo This should never be printed exit 1 && echo This should never be printed An "exit" should cause the current shell or script to terminate and return the specified exit status to its caller. For example: chain test.ipxe && echo Success || echo Failure [in test.ipxe] #!ipxe exit 0 should echo "Success". Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow "exit" to exit a scriptMichael Brown2010-11-221-14/+21
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Implement "goto" in iPXE scriptsMichael Brown2010-11-221-25/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow script labels to be defined using the syntax :<labelname> (nothing else allowed on the line, including whitespace). Labels are ignored during script execution, but can be used as the target of the "goto" command. For example: #!ipxe goto machine_${net0/ip} || goto machine_default # Linux kernel boot :machine_10.0.0.101 :machine_10.0.0.102 set filename http://my.boot.server/vmlinuz goto done # Default configuration :machine_default set filename pxelinux.0 goto done # Boot selected configuration :done chain ${filename} Originally-implemented-by: Shao Miller <shao.miller@yrdsb.edu.on.ca> Originally-implemented-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Accept "#!gpxe" as well as "#!ipxe" as a script magic markerMichael Brown2010-05-221-4/+9
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-3/+3
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow for DOS-style line endings in scriptsMichael Brown2009-06-031-3/+5
| | | | | | | | | | | | | | | Windows text editors such as Notepad tend to use CRLF line endings, which breaks gPXE's signature detection for script images. Since scripts are usually very small, they end up falling back to being detected as valid PXE executable images (since there are no signature checks for PXE executables). Executing text files as x86 machine code tends not to work well. Fix by allowing for any isspace() character to terminate the "#!gpxe" signature, and by ensuring that CR characters get stripped during command line parsing. Suggested-by: Shao Miller <Shao.Miller@yrdsb.edu.on.ca>
* [legal] Add a selection of FILE_LICENCE declarationsMichael Brown2009-05-181-0/+2
| | | | | Add FILE_LICENCE declarations to almost all files that make up the various standard builds of gPXE.
* [comboot] Allow for tail recursion of COMBOOT imagesMichael Brown2009-02-171-4/+1Star
| | | | | | | | | | | | Multi-level menus via COMBOOT rely on the COMBOOT program being able to exit and invoke a new COMBOOT program (the next menu). This works, but rapidly (within about five iterations) runs out of space in gPXE's internal stack, since each new image is executed in a new function context. Fix by allowing tail recursion between images; an image can now specify a replacement image for itself, and image_exec() will perform the necessary tail recursion.
* [image] Avoid claiming zero-length images as validMichael Brown2009-02-161-0/+6
| | | | | Both the script and PXE images types will claim a zero-length image. Inhibit this to avoid end-user surprises.
* [script] Remove arbitrary limit on script line lengthsMichael Brown2008-06-181-28/+19Star
|
* Various warnings fixups for OpenBSD with gcc-3.3.5.Michael Brown2007-12-071-1/+1
|
* Set current working URI to be that of the executable image whenMichael Brown2007-08-071-9/+1Star
| | | | | executing any image, not just a script. (This will enable pxelinux to use relative URIs, should it wish to.)
* Set current working URI equal to script URI during script execution.Michael Brown2007-08-021-1/+9
|
* Cope with non-newline-terminated scripts.Michael Brown2007-08-021-2/+3
| | | | Print error status using strerror().
* Scripts temporarily deregister themselves while executing. ThisMichael Brown2007-06-091-3/+16
| | | | | allows us to avoid execution loops without having to hack around the image registration order.
* Make DEBUG=script echo the commands as they are executedMichael Brown2007-01-121-0/+1
|
* Use systematic names for XXX_IMAGE.Michael Brown2007-01-121-0/+113
Add scripts as an image format (since it's trivial to do).