netboot.xyz.j2 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!ipxe
  2. set esc:hex 1b
  3. set bold ${esc:string}[1m
  4. set boldoff ${esc:string}[22m
  5. set fg_gre ${esc:string}[32m
  6. set fg_cya ${esc:string}[36m
  7. set fg_whi ${esc:string}[37m
  8. set TFTP_ERR Local TFTP failed... attempting remote HTTPS
  9. set HTTPS_ERR HTTPS appears to have failed... attempting HTTP
  10. set HTTP_ERR HTTP has failed, localbooting...
  11. set site_name {{ site_name }}
  12. set boot_domain {{ boot_domain }}
  13. set ipxe_version ${version}
  14. set version {{ boot_version }}
  15. :start
  16. echo ${bold}${fg_gre}${site_name} - ${fg_whi}v${version}${boldoff}
  17. iseq ${site_name} netboot.xyz || echo ${bold}${fg_whi}Powered by ${fg_gre}netboot.xyz${fg_whi}${boldoff}
  18. prompt --key m --timeout 4000 Hit the ${bold}m${boldoff} key to open failsafe menu... && goto failsafe || goto dhcp
  19. :dhcp
  20. echo
  21. dhcp || goto netconfig
  22. isset ${next-server} && iseq ${filename} {{ site_name }}.kpxe && goto tftpmenu ||
  23. isset ${next-server} && iseq ${filename} {{ site_name }}.efi && goto tftpmenu ||
  24. goto menu
  25. :failsafe
  26. menu ${boot_domain} Failsafe Menu
  27. item localboot Boot to local drive
  28. item netconfig Manual network configuration
  29. item retry Retry boot
  30. item debug iPXE Debug Shell
  31. item reboot Reboot System
  32. choose failsafe_choice || exit
  33. goto ${failsafe_choice}
  34. :netconfig
  35. echo Network Configuration:
  36. echo Available interfaces...
  37. ifstat
  38. imgfree
  39. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  40. isset ${net} || set net 0
  41. echo -n IP: && read net${net}/ip
  42. echo -n Subnet mask: && read net${net}/netmask
  43. echo -n Gateway: && read net${net}/gateway
  44. echo -n DNS: && read dns
  45. ifopen net${net}
  46. echo Attempting chainload of ${boot_domain}...
  47. goto menu || goto failsafe
  48. :tftpmenu
  49. isset ${hostname} && chain --autofree tftp://${next-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
  50. chain --autofree tftp://${next-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC not found booting default...
  51. chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
  52. :menu
  53. {% if bootloader_https_enabled | bool %}
  54. set conn_type https
  55. chain --autofree https://${boot_domain}/menu.ipxe || echo ${HTTPS_ERR}
  56. sleep 5
  57. {% endif %}
  58. {% if bootloader_http_enabled | bool %}
  59. set conn_type http
  60. chain --autofree http://${boot_domain}/menu.ipxe || echo ${HTTP_ERR}
  61. {% endif %}
  62. goto localboot
  63. :localboot
  64. exit
  65. :retry
  66. goto start
  67. :reboot
  68. reboot
  69. goto start
  70. :debug
  71. echo Type "exit" to return to menu
  72. shell
  73. goto failsafe