Skip to content

Commit

Permalink
netboot.xyz it
Browse files Browse the repository at this point in the history
  • Loading branch information
nshalman committed Mar 20, 2024
1 parent 369a60d commit ba3e1c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
2 changes: 1 addition & 1 deletion binary/script/build_and_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function build_iPXE() {
# build iPXE
echo "Building iPXE"
top_level_dir="$(git rev-parse --show-toplevel)"
if ! (cd "${top_level_dir}"; nix-shell "${top_level_dir}/binary/script/shell.nix" --run 'make binary'); then
if ! (cd "${top_level_dir}"; nix-shell "${top_level_dir}/binary/script/shell.nix" --run 'make VERSION=2.0+ binary'); then
echo "Failed to build iPXE" 1>&2
exit 1
fi
Expand Down
42 changes: 6 additions & 36 deletions binary/script/embed.ipxe
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
#!ipxe

set user-class Tinkerbell
echo Welcome to Neverland!
echo Welcome to the workaround iPXE

# Allow the operator to drop to a shell
prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && shell ||
dhcp

# Random string to enable binary patching
#a8b7e61f1075c37a793f2f92cee89f7bba00c4a8d7842ce3d40b5889032d8881
#ddd16a4fc4926ecefdfb6941e33c44ed3647133638f5e84021ea44d3152e7f97

# This is possible because the DHCP options from the original vendor PXE DHCP request
# are available to chainloaded iPXE binaries. See https://github.com/ipxe/ipxe/issues/188
set vlan-id ${43.116:string}
isset ${vlan-id} && goto boot-with-vlan ||

:iterate-interfaces
set idx:int32 0
:interfaces-loop
isset ${net${idx}/ip} && goto interfaces-loop-done || iseq ${idx} 50 && goto autoboot || inc idx && goto interfaces-loop

:interfaces-loop-done
echo Booting from net${idx}...
autoboot net${idx}

:autoboot
autoboot

:boot-with-vlan
set idx:int32 0
# Find the interface that is configured with an IP, this will be the iPXE auto created vlan interface.
:loop isset ${net${idx}-${vlan-id}/ip} && goto loop_done ||
iseq ${idx} 50 && goto error ||
inc idx && goto loop

:loop_done
echo Booting from net${idx}-${vlan-id}...
autoboot net${idx}-${vlan-id}

:error
echo Failed to find the vlan interface
set conn_type https
chain --autofree https://boot.netboot.xyz/menu.ipxe || echo HTTPS failed... attempting HTTP...
set conn_type http
chain --autofree http://boot.netboot.xyz/menu.ipxe || echo HTTP failed, dropping to a shell...
shell

0 comments on commit ba3e1c3

Please sign in to comment.