====== Scripting ====== ===== Overview ===== You can create a script to automate a sequence of iPXE commands. Any command that can be typed at the iPXE [[:cmdline|command line]] can also be used in a script. You can find a full list of commands in the iPXE [[:cmd|command reference]]. An iPXE script is a plain text file starting with the magic line ''#!ipxe'' and containing a sequence of iPXE commands. For example, here is a simple script that acquires an IP address via DHCP and then boots the iPXE demonstration image: #!ipxe dhcp chain http://boot.ipxe.org/demo/boot.php Here is another simple script that creates a VLAN and then boots from it: #!ipxe vcreate --tag 24 net0 autoboot net0-24 Here is a slightly more sophisticated script that persistently retries DHCP until it succeeds in obtaining a boot filename: #!ipxe :retry_dhcp dhcp && isset ${filename} || goto retry_dhcp echo Booting from ${filename} chain ${filename} You can create an iPXE script using any text editor, such as [[http://www.gnu.org/software/emacs/|emacs]], or [[http://www.vim.org/|vi]], or even [[http://en.wikipedia.org/wiki/Notepad_%28software%29|Windows Notepad]]. An iPXE script does not need to have any particular file extension (such as ''.txt'' or ''.ipxe''); iPXE will recognise it as a script provided that it starts with the magic line ''#!ipxe''.((For the sake of backwards compatibility, iPXE will also recognise legacy gPXE scripts starting with the magic line ''#!gpxe''. However, gPXE is not capable of running iPXE scripts, since the iPXE script language is substantially more advanced than the gPXE script language.)) ===== Flow control ===== You can use the [[:cmd:goto]] command to jump to a predefined script label. You can define a label using {{ :clipart:flowchart.png?222x322|A flowchart}} :