summaryrefslogtreecommitdiffstats
path: root/src/image/script.c
Commit message (Collapse)AuthorAgeFilesLines
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-1/+5
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Generate command option help text automaticallyMichael Brown2013-11-071-1/+1
| | | | | | | Generate the command option help text automatically from the list of defined options. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [parseopt] Add parse_timeout()Michael Brown2013-11-011-2/+2
| | | | | | | | Parsing a timeout value (specified in milliseconds) into an internal timeout value measured in timer ticks is a common operation. Provide a parse_timeout() value to carry out this conversion automatically. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow commands following a script labelMichael Brown2013-07-251-43/+53
| | | | | | | | | | | | | | | | Allow commands to be placed on the same line as a label. This allows for improved legibility of loop constructions by incorporating the loop check condition into the same line as the loop label. For example, to iterate over network devices using the forthcoming "inc" command: set idx:int16 0 :loop isset ${net${idx}/mac} || goto loop_done echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac} inc idx && goto loop :loop_done Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow initial whitespace on lines containing labelsMichael Brown2013-07-251-4/+29
| | | | | | | | | Initial whitespace is already accepted on lines containing commands, since it gets ignored by the system() call. Minimise surprise and allow for neater indentation of scripts by also allowing whitespace on lines containing labels. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Avoid trying to read final character of a zero-length stringMichael Brown2013-07-151-2/+2
| | | | | | Detected using Valgrind. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow for backslash continuation of script linesMichael Brown2013-07-151-13/+41
| | | | | | | | | | | Allow long script lines to be broken up using backslash continuation. For example: choose --default linux --timeout 3000 os \ && goto boot_${os} || goto cancelled Requested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-201-1/+2
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Avoid using stack-allocated memory in process_line()Michael Brown2012-04-231-14/+15
| | | | | | | Script lines can be arbitrarily long; allocate on the heap rather than on the stack. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [parseopt] Allow "prompt" command to accept character literals for --keyMichael Brown2012-03-291-1/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Accept labels on lines terminated with CRLFMichael Brown2011-08-081-1/+7
| | | | | | | | | | | | | | CRLF line terminators are allowed in scripts; the carriage return is simply interpreted as trailing whitespace and so is ignored. This fails on lines containing script labels, since the label-finding code checks for a line containing only the ":" marker and the label itself (without any trailing whitespace). Fix by allowing a label to be terminated by either a NUL or a whitespace character. Reported-by: Bovey Christian <Christian.Bovey@chuv.ch> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [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).