netboot.xyz.j2 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
  49. :menu
  50. {% if bootloader_https_enabled | bool %}
  51. set conn_type https
  52. chain --autofree https://${boot_domain}/menu.ipxe || echo ${HTTPS_ERR}
  53. sleep 5
  54. {% endif %}
  55. {% if bootloader_http_enabled | bool %}
  56. set conn_type http
  57. chain --autofree http://${boot_domain}/menu.ipxe || echo ${HTTP_ERR}
  58. {% endif %}
  59. goto localboot
  60. :localboot
  61. exit
  62. :retry
  63. goto start
  64. :reboot
  65. reboot
  66. goto start
  67. :debug
  68. echo Type "exit" to return to menu
  69. shell
  70. goto failsafe