From 3328fb053c26b586d8fbffb66403e5ec754a4a95 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 11 Nov 2025 02:20:23 +0100 Subject: [PATCH] PXE boot over http --- config.yaml | 3 ++- templates/boot.ipxe | 1 - templates/dnsmasq.conf | 2 +- tools/{tftpd => server} | 29 +++++++++++++++++++++++++++-- tools/vm | 2 +- 5 files changed, 31 insertions(+), 6 deletions(-) rename tools/{tftpd => server} (70%) diff --git a/config.yaml b/config.yaml index e781eef..183615e 100644 --- a/config.yaml +++ b/config.yaml @@ -1,2 +1,3 @@ -dhcp: +server: tftpIp: 10.0.0.3 + httpUrl: http://10.0.0.3:8000 diff --git a/templates/boot.ipxe b/templates/boot.ipxe index 2997bf2..d0da639 100644 --- a/templates/boot.ipxe +++ b/templates/boot.ipxe @@ -1,5 +1,4 @@ #!ipxe - dhcp echo Starting ${serial} diff --git a/templates/dnsmasq.conf b/templates/dnsmasq.conf index ab71584..0f39dc0 100644 --- a/templates/dnsmasq.conf +++ b/templates/dnsmasq.conf @@ -1,4 +1,4 @@ -{% set tftpIp = config.dhcp.tftpIp -%} +{% set tftpIp = config.server.tftpIp -%} enable-tftp tftp-root=/tftproot diff --git a/tools/tftpd b/tools/server similarity index 70% rename from tools/tftpd rename to tools/server index 4b092e5..fd7159d 100755 --- a/tools/tftpd +++ b/tools/server @@ -6,6 +6,7 @@ IPXE_VERSION=b41bda4413bf286d7b7a449bc05e1531da1eec2e IPXE_BIN=(bin/ipxe.pxe bin-x86_64-efi/ipxe.efi) IPXE_DIR=${ROOT}/.ipxe/ipxe-${IPXE_VERSION} +HTTP_URL=$(cat ${ROOT}/config.yaml | yq .server.httpUrl) function download_ipxe() { base_dir=$(dirname ${IPXE_DIR}) @@ -25,7 +26,8 @@ function patch_ipxe() { #!ipxe dhcp -chain boot.ipxe || shell +chain ${HTTP_URL}/boot.ipxe || shell +# chain boot.ipxe || shell EOF cd - > /dev/null @@ -44,6 +46,7 @@ function build_ipxe() { function render() { ${ROOT}/tools/render + ${ROOT}/rendered/generate_configs.sh } function host_tftp() { @@ -64,8 +67,30 @@ function host_tftp() { sudo in.tftpd --verbosity 100 --permissive -L --secure ${TFTP_DIR} } +function host_http() { + HTTP_DIR=$(mktemp --tmpdir -d http.XXX) + chmod 755 ${HTTP_DIR} + function cleanup() { + rm -rf ${HTTP_DIR} + } + trap cleanup EXIT + + ln -s ${ROOT}/rendered/boot.ipxe ${HTTP_DIR} + for bin in "${IPXE_BIN[@]}"; do + path=${IPXE_DIR}/src/${bin} + ln -s ${path} ${HTTP_DIR} + done + + ln -s ${ROOT}/configs ${HTTP_DIR} + + echo "Starting http" + cd ${HTTP_DIR} + python -m http.server 8000 + cd - +} + download_ipxe patch_ipxe build_ipxe render -host_tftp +host_http diff --git a/tools/vm b/tools/vm index 2b46a77..b604cc1 100755 --- a/tools/vm +++ b/tools/vm @@ -21,7 +21,7 @@ function define_network() { - +