netboot.xyz.j2 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 vlan Manual VLAN configuration
  30. item retry Retry boot
  31. item debug iPXE Debug Shell
  32. item reboot Reboot System
  33. choose failsafe_choice || exit
  34. goto ${failsafe_choice}
  35. :netconfig
  36. echo Network Configuration:
  37. echo Available interfaces...
  38. ifstat
  39. imgfree
  40. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  41. isset ${net} || set net 0
  42. echo -n IP: && read net${net}/ip
  43. echo -n Subnet mask: && read net${net}/netmask
  44. echo -n Gateway: && read net${net}/gateway
  45. echo -n DNS: && read dns
  46. ifopen net${net}
  47. echo Attempting chainload of ${boot_domain}...
  48. goto menu || goto failsafe
  49. :vlan
  50. echo VLAN Configuration:
  51. echo Available interfaces...
  52. ifstat
  53. imgfree
  54. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  55. isset ${net} || set net 0
  56. echo -n Set VLAN 802.1Q tag [0 to 4094]: ${} && read vlan
  57. vcreate --tag ${vlan} net${net}
  58. ifconf --configurator dhcp net${net}-${vlan} || echo DHCP failed trying manual && goto netvlan
  59. echo Attempting chainload of ${boot_domain}...
  60. goto menu || goto failsafe
  61. :netvlan
  62. echo -n IP: && read net${net}-${vlan}/ip
  63. echo -n Subnet mask: && read net${net}-${vlan}/netmask
  64. echo -n Gateway: && read net${net}-${vlan}/gateway
  65. echo -n DNS: && read dns
  66. ifopen net${net}-${vlan}
  67. echo Attempting chainload of ${boot_domain}...
  68. goto menu || goto failsafe
  69. :tftpmenu
  70. isset ${hostname} && chain --autofree tftp://${next-server}/HOSTNAME-${hostname}.ipxe || echo Custom boot by Hostname not found trying MAC...
  71. chain --autofree tftp://${next-server}/MAC-${mac:hexraw}.ipxe || echo Custom boot by MAC not found booting default...
  72. chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR} && goto menu
  73. :menu
  74. {% if bootloader_https_enabled | bool %}
  75. set conn_type https
  76. chain --autofree https://${boot_domain}/menu.ipxe || echo ${HTTPS_ERR}
  77. sleep 5
  78. {% endif %}
  79. {% if bootloader_http_enabled | bool %}
  80. set conn_type http
  81. chain --autofree http://${boot_domain}/menu.ipxe || echo ${HTTP_ERR}
  82. {% endif %}
  83. goto localboot
  84. :localboot
  85. exit
  86. :retry
  87. goto start
  88. :reboot
  89. reboot
  90. goto start
  91. :debug
  92. echo Type "exit" to return to menu
  93. shell
  94. goto failsafe