run/load/ipxe: spawn lighttpd on demand

An installed lighttpd HTTP server can now optionally be started to serve
the boot image with the follow run options.

--load-ipxe-lighttpd             run lighttpd automatically (default: off)
--load-ipxe-lighttpd-port <port> TCP port to run lighttpd on (default: 8080)
This commit is contained in:
Christian Helmuth 2022-09-07 08:02:09 +02:00
parent afa0bed5fc
commit 57f510d67f

View File

@ -1,8 +1,10 @@
##
# Load files needed by the scenario via iPXE/HTTP
#
# \param --load-ipxe-base-dir base directory of iPXE/HTTP server
# \param --load-ipxe-boot-dir boot directory relative to HTTP base
# \param --load-ipxe-base-dir base directory of iPXE/HTTP server
# \param --load-ipxe-boot-dir boot directory relative to HTTP base
# \param --load-ipxe-lighttpd run lighttpd automatically
# \param --load-ipxe-lighttpd-port TCP port to run lighttpd on
#
source [genode_dir]/tool/run/load.inc
@ -25,6 +27,12 @@ proc load_ipxe_base_dir { } { return [get_cmd_arg --load-ipxe-base-dir ""] }
proc load_ipxe_boot_dir { } { return [get_cmd_arg --load-ipxe-boot-dir ""] }
proc load_ipxe_lighttpd { } { return [get_cmd_switch --load-ipxe-lighttpd] }
proc load_ipxe_lighttpd_port { } { return [get_cmd_arg --load-ipxe-lighttpd-port 8080] }
proc image_extension { } {
if {[have_include "image/iso"]} {
return "iso"
@ -76,4 +84,30 @@ proc create_ipxe_config { } {
puts $fh "shell"
puts $fh "boot"
close $fh
if {![load_ipxe_lighttpd]} { return }
set conf_file [file normalize [run_dir]/lighttpd.conf]
set fh [open "$conf_file" "WRONLY CREAT TRUNC"]
puts $fh "server.port = [load_ipxe_lighttpd_port]"
puts $fh "server.document-root = \"[file normalize [run_dir]]\""
puts $fh "server.errorlog = \"/dev/null\""
close $fh
global lighttpd_spawn_id
spawn lighttpd -f $conf_file -D
set lighttpd_spawn_id $spawn_id
}
# Override the exit procedure
rename exit load_ipxe_real_exit
proc exit {{status 0}} {
if {[load_ipxe_lighttpd]} {
global lighttpd_spawn_id
kill_spawned $lighttpd_spawn_id
}
load_ipxe_real_exit $status
}