mirror of
https://github.com/netbootxyz/netboot.xyz.git
synced 2025-08-11 08:16:57 +02:00
The `filename` contains the full path to the file, usually the netboot assets are in `/` of a tftp server, so the check if its booted from the ipxe assets will always fail. Add an additional check prepended with `/` to allow the check to pass when booted from the root of a tftp server. Also add loading of MAC- ipxe scripts with hypens in addition to raw, i.e. `MAC-00-11-22-33-44-55.ipxe` or `MAC-001122334455.ipxe`. Fixes: #1097
152 lines
5.8 KiB
Django/Jinja
152 lines
5.8 KiB
Django/Jinja
#!ipxe
|
|
set esc:hex 1b
|
|
set bold ${esc:string}[1m
|
|
set boldoff ${esc:string}[22m
|
|
set fg_gre ${esc:string}[32m
|
|
set fg_cya ${esc:string}[36m
|
|
set fg_whi ${esc:string}[37m
|
|
set VARS_ERR Local vars file not found... attempting TFTP boot...
|
|
set TFTP_ERR Local TFTP failed... attempting remote HTTPS
|
|
set V6_ERR IPv6 appears to have failed... attempting IPv4...
|
|
set HTTPS_ERR HTTPS appears to have failed... attempting HTTP
|
|
set HTTP_ERR HTTP has failed, localbooting...
|
|
set site_name {{ site_name }}
|
|
set boot_domain {{ boot_domain }}
|
|
set ipxe_version ${version}
|
|
set version {{ boot_version }}
|
|
set conn_type https
|
|
set tftp-root-path /
|
|
|
|
:start
|
|
echo ${bold}${fg_gre}${site_name} - ${fg_whi}v${version}${boldoff}
|
|
iseq ${site_name} netboot.xyz || echo ${bold}${fg_whi}Powered by ${fg_gre}netboot.xyz${fg_whi}${boldoff}
|
|
prompt --key m --timeout 4000 Hit the ${bold}m${boldoff} key to open failsafe menu... && goto failsafe || goto dhcp
|
|
|
|
:dhcp
|
|
echo
|
|
dhcp || goto netconfig
|
|
isset ${next-server} && isset ${proxydhcp/next-server} && goto choose-tftp || set tftp-server ${next-server} && goto load-custom-ipxe
|
|
|
|
:choose-tftp
|
|
# Load "proxy settings" from root server
|
|
chain tftp://${next-server}/local-vars.ipxe || echo ${VARS_ERR}
|
|
# Check if the proxy-dhcp-vars script has made any usable command about how to progress with a next-server and a proxy-next-server being set
|
|
isset ${use_proxydhcp_settings} && iseq ${use_proxydhcp_settings} true && goto set-next-server ||
|
|
prompt --key p --timeout 4000 DHCP proxy detected, press ${bold}p${boldoff} to boot from ${proxydhcp/next-server}... && set use_proxydhcp_settings true || set use_proxydhcp_settings false
|
|
goto set-next-server
|
|
|
|
:set-next-server
|
|
iseq ${use_proxydhcp_settings} true && set tftp-server ${proxydhcp/next-server} || set tftp-server ${next-server}
|
|
goto load-custom-ipxe
|
|
|
|
:load-custom-ipxe
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}.kpxe && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-undionly.kpxe && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-snp.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-snponly.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} {{ bootloader_filename }}-arm64.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}.kpxe && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}-undionly.kpxe && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}-snp.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}-snponly.efi && goto tftpmenu ||
|
|
isset ${tftp-server} && iseq ${filename} ${tftp-root-path}{{ bootloader_filename }}-arm64.efi && goto tftpmenu ||
|
|
goto menu
|
|
|
|
:failsafe
|
|
menu ${boot_domain} Failsafe Menu
|
|
item localboot Boot to local drive
|
|
item netconfig Manual network configuration
|
|
item vlan Manual VLAN configuration
|
|
item retry Retry boot
|
|
item debug iPXE Debug Shell
|
|
item reboot Reboot System
|
|
choose failsafe_choice || exit
|
|
goto ${failsafe_choice}
|
|
|
|
:netconfig
|
|
echo Network Configuration:
|
|
echo Available interfaces...
|
|
ifstat
|
|
imgfree
|
|
echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
|
|
isset ${net} || set net 0
|
|
echo -n IP: && read net${net}/ip
|
|
echo -n Subnet mask: && read net${net}/netmask
|
|
echo -n Gateway: && read net${net}/gateway
|
|
echo -n DNS: && read dns
|
|
ifopen net${net}
|
|
echo Attempting chainload of ${boot_domain}...
|
|
goto menu || goto failsafe
|
|
|
|
:vlan
|
|
echo VLAN Configuration:
|
|
echo Available interfaces...
|
|
ifstat
|
|
imgfree
|
|
echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
|
|
isset ${net} || set net 0
|
|
echo -n Set VLAN 802.1Q tag [0 to 4094]: ${} && read vlan
|
|
vcreate --tag ${vlan} net${net}
|
|
ifconf --configurator dhcp net${net}-${vlan} || echo DHCP failed trying manual && goto netvlan
|
|
echo Attempting chainload of ${boot_domain}...
|
|
goto menu || goto failsafe
|
|
|
|
:netvlan
|
|
echo -n IP: && read net${net}-${vlan}/ip
|
|
echo -n Subnet mask: && read net${net}-${vlan}/netmask
|
|
echo -n Gateway: && read net${net}-${vlan}/gateway
|
|
echo -n DNS: && read dns
|
|
ifopen net${net}-${vlan}
|
|
echo Attempting chainload of ${boot_domain}...
|
|
goto menu || goto failsafe
|
|
|
|
:tftpmenu
|
|
chain tftp://${tftp-server}/local-vars.ipxe || echo ${VARS_ERR}
|
|
isset ${hostname} && chain --autofree tftp://${tftp-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
|
|
chain --autofree tftp://${tftp-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC (hexraw) not found, attempting by MAC (hexhyp)...
|
|
chain --autofree tftp://${tftp-server}/MAC-${mac:hexhyp}.ipxe || echo Custom boot by MAC (hexhyp) not found, booting default...
|
|
chain --autofree tftp://${tftp-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
|
|
|
|
:menu
|
|
{% if bootloader_https_enabled | bool %}
|
|
:menu_https
|
|
set conn_type https
|
|
goto menu_start
|
|
{% endif %}
|
|
|
|
{% if bootloader_http_enabled | bool %}
|
|
:menu_http
|
|
set conn_type http
|
|
goto menu_start
|
|
{% endif %}
|
|
|
|
:menu_start
|
|
isset ${netX/dns6} && goto menu_v6 || goto menu_v4
|
|
:menu_v6
|
|
isset ${netX/dns6_bak} && set netX/dns6 ${netX/dns6_bak} ||
|
|
set netX/dns6_bak ${netX/dns6}
|
|
echo Attempting ${conn_type} boot over IPv6...
|
|
chain --autofree ${conn_type}://${boot_domain}/menu.ipxe || echo ${conn_type} IPv6 failed... attempting IPv4...
|
|
clear netX/dns6
|
|
:menu_v4
|
|
echo Attempting ${conn_type} boot over IPv4...
|
|
chain --autofree ${conn_type}://${boot_domain}/menu.ipxe || echo ${conn_type} IPv4 failed...
|
|
iseq ${conn_type} https && goto menu_http || goto localboot
|
|
|
|
:localboot
|
|
exit
|
|
|
|
:retry
|
|
goto start
|
|
|
|
:reboot
|
|
reboot
|
|
goto start
|
|
|
|
:debug
|
|
echo Type "exit" to return to menu
|
|
shell
|
|
goto failsafe
|