ipxe-bootloader.j2 1.9 KB

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