1
0

netboot.xyz.j2 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 VARS_ERR Local vars file not found... attempting TFTP boot...
  9. set TFTP_ERR Local TFTP failed... attempting remote HTTPS
  10. set HTTPS_ERR HTTPS appears to have failed... attempting HTTP
  11. set HTTP_ERR HTTP has failed, localbooting...
  12. set site_name {{ site_name }}
  13. set boot_domain {{ boot_domain }}
  14. set ipxe_version ${version}
  15. set version {{ boot_version }}
  16. :start
  17. echo ${bold}${fg_gre}${site_name} - ${fg_whi}v${version}${boldoff}
  18. iseq ${site_name} netboot.xyz || echo ${bold}${fg_whi}Powered by ${fg_gre}netboot.xyz${fg_whi}${boldoff}
  19. prompt --key m --timeout 4000 Hit the ${bold}m${boldoff} key to open failsafe menu... && goto failsafe || goto dhcp
  20. :dhcp
  21. echo
  22. dhcp || goto netconfig
  23. isset ${next-server} && iseq ${filename} {{ site_name }}.kpxe && goto tftpmenu ||
  24. isset ${next-server} && iseq ${filename} {{ site_name }}.efi && goto tftpmenu ||
  25. isset ${next-server} && iseq ${filename} {{ site_name }}-snp.efi && goto tftpmenu ||
  26. isset ${next-server} && iseq ${filename} {{ site_name }}-snponly.efi && goto tftpmenu ||
  27. isset ${next-server} && iseq ${filename} {{ site_name }}-arm64.efi && goto tftpmenu ||
  28. goto menu
  29. :failsafe
  30. menu ${boot_domain} Failsafe Menu
  31. item localboot Boot to local drive
  32. item netconfig Manual network configuration
  33. item vlan Manual VLAN configuration
  34. item retry Retry boot
  35. item debug iPXE Debug Shell
  36. item reboot Reboot System
  37. choose failsafe_choice || exit
  38. goto ${failsafe_choice}
  39. :netconfig
  40. echo Network Configuration:
  41. echo Available interfaces...
  42. ifstat
  43. imgfree
  44. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  45. isset ${net} || set net 0
  46. echo -n IP: && read net${net}/ip
  47. echo -n Subnet mask: && read net${net}/netmask
  48. echo -n Gateway: && read net${net}/gateway
  49. echo -n DNS: && read dns
  50. ifopen net${net}
  51. echo Attempting chainload of ${boot_domain}...
  52. goto menu || goto failsafe
  53. :vlan
  54. echo VLAN Configuration:
  55. echo Available interfaces...
  56. ifstat
  57. imgfree
  58. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  59. isset ${net} || set net 0
  60. echo -n Set VLAN 802.1Q tag [0 to 4094]: ${} && read vlan
  61. vcreate --tag ${vlan} net${net}
  62. ifconf --configurator dhcp net${net}-${vlan} || echo DHCP failed trying manual && goto netvlan
  63. echo Attempting chainload of ${boot_domain}...
  64. goto menu || goto failsafe
  65. :netvlan
  66. echo -n IP: && read net${net}-${vlan}/ip
  67. echo -n Subnet mask: && read net${net}-${vlan}/netmask
  68. echo -n Gateway: && read net${net}-${vlan}/gateway
  69. echo -n DNS: && read dns
  70. ifopen net${net}-${vlan}
  71. echo Attempting chainload of ${boot_domain}...
  72. goto menu || goto failsafe
  73. :tftpmenu
  74. chain tftp://${next-server}/local-vars.ipxe || echo ${VARS_ERR}
  75. isset ${hostname} && chain --autofree tftp://${next-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
  76. chain --autofree tftp://${next-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC not found booting default...
  77. chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
  78. :menu
  79. {% if bootloader_https_enabled | bool %}
  80. set conn_type https
  81. chain --autofree https://${boot_domain}/menu.ipxe || echo ${HTTPS_ERR}
  82. sleep 5
  83. {% endif %}
  84. {% if bootloader_http_enabled | bool %}
  85. set conn_type http
  86. chain --autofree http://${boot_domain}/menu.ipxe || echo ${HTTP_ERR}
  87. {% endif %}
  88. goto localboot
  89. :localboot
  90. exit
  91. :retry
  92. goto start
  93. :reboot
  94. reboot
  95. goto start
  96. :debug
  97. echo Type "exit" to return to menu
  98. shell
  99. goto failsafe