Skip to content

Commit

Permalink
Implemented support for proxydhcp variables (disbaled by default) (#953)
Browse files Browse the repository at this point in the history
* Implemented support for proxydhcp variables (disabled by default)
  • Loading branch information
notepass authored Oct 24, 2021
1 parent ffda2b6 commit 523a6f8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
33 changes: 22 additions & 11 deletions roles/netbootxyz/templates/disks/netboot.xyz.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ iseq ${site_name} netboot.xyz || echo ${bold}${fg_whi}Powered by ${fg_gre}netboo
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} && iseq ${filename} {{ site_name }}.kpxe && goto tftpmenu ||
isset ${next-server} && iseq ${filename} {{ site_name }}-undionly.kpxe && goto tftpmenu ||
isset ${next-server} && iseq ${filename} {{ site_name }}.efi && goto tftpmenu ||
isset ${next-server} && iseq ${filename} {{ site_name }}-snp.efi && goto tftpmenu ||
isset ${next-server} && iseq ${filename} {{ site_name }}-snponly.efi && goto tftpmenu ||
isset ${next-server} && iseq ${filename} {{ site_name }}-arm64.efi && goto tftpmenu ||
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} || prompt --key p --timeout 4000 DHCP proxy detected. Press ${bold}p${boldoff} to boot from && set use_proxydhcp_settings true
isset ${use_proxydhcp_settings} || set use_proxydhcp_settings false
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} {{ site_name }}.kpxe && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ site_name }}-undionly.kpxe && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ site_name }}.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ site_name }}-snp.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ site_name }}-snponly.efi && goto tftpmenu ||
isset ${tftp-server} && iseq ${filename} {{ site_name }}-arm64.efi && goto tftpmenu ||
goto menu

:failsafe
Expand Down Expand Up @@ -79,10 +90,10 @@ echo Attempting chainload of ${boot_domain}...
goto menu || goto failsafe

:tftpmenu
chain tftp://${next-server}/local-vars.ipxe || echo ${VARS_ERR}
isset ${hostname} && chain --autofree tftp://${next-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
chain --autofree tftp://${next-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC not found booting default...
chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
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 not found booting default...
chain --autofree tftp://${tftp-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu

:menu
{% if bootloader_https_enabled | bool %}
Expand Down
5 changes: 5 additions & 0 deletions roles/netbootxyz/templates/local-vars.ipxe.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

### set to enable enable github custom menu
#set github_user my_github_username

# If a DHCP proxy server is found and this variable is set to true, the tftp server provided by the DHCP proxy will be used instead of the tftp server provided by the root DHCP
# Please note that this variable is always read from the local-vars.ipxe onb the tftp server the root DHCP provided
# If the variable isn't present at runtime, the user will be queried to press a key to boot from the proxy DHCP prtovided ftfp server
#set use_proxydhcp_settings true
9 changes: 9 additions & 0 deletions roles/netbootxyz/templates/menu/netinfo.ipxe.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ item --gap Next-server:
item nextserver ${space} ${next-server}
item --gap Filename:
item filename ${space} ${netX/filename}
# Proxy DHCP info (Will only be displayed if proxydhcp is set)
item --gap DHCP proxy present
isset ${proxydhcp} && item proxy ${space} Yes || item proxy ${space} No
isset ${proxydhcp} && item --gap DHCP proxy next-server ||
isset ${proxydhcp} && item proxy-nextserver ${space} ${proxydhcp/next-server} ||
isset ${proxydhcp} && item --gap Using DHCP proxy next-server ||
isset ${proxydhcp} && iseq ${proxydhcp/next-server} ${tftp-server} && echo Yes || echo No (Using default next-server ${tftp-server})


choose empty ||
exit

0 comments on commit 523a6f8

Please sign in to comment.