netboot.xyz.j2 3.2 KB

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