netboot.xyz.j2 2.4 KB

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