ipxe-bootloader.j2 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. goto menu
  21. :failsafe
  22. menu ${boot_domain} Failsafe Menu
  23. item localboot Boot to local drive
  24. item netconfig Manual network configuration
  25. item retry Retry boot
  26. item debug iPXE Debug Shell
  27. item reboot Reboot System
  28. choose failsafe_choice || exit
  29. goto ${failsafe_choice}
  30. :netconfig
  31. echo Network Configuration:
  32. echo Available interfaces...
  33. ifstat
  34. imgfree
  35. echo -n Set network interface number [0 for net0, defaults to 0]: ${} && read net
  36. isset ${net} || set net 0
  37. echo -n IP: && read net${net}/ip
  38. echo -n Subnet mask: && read net${net}/netmask
  39. echo -n Gateway: && read net${net}/gateway
  40. echo -n DNS: && read dns
  41. ifopen net${net}
  42. echo Attempting chainload of ${boot_domain}...
  43. goto menu || goto failsafe
  44. :menu
  45. chain --autofree tftp://${next-server}/menu.ipxe || echo ${TFTP_ERR}
  46. set conn_type https
  47. chain --autofree https://${boot_domain}/menu.ipxe || echo ${HTTPS_ERR}
  48. sleep 5
  49. set conn_type http
  50. chain --autofree http://${boot_domain}/menu.ipxe || echo ${HTTP_ERR}
  51. goto localboot
  52. :localboot
  53. exit
  54. :retry
  55. goto start
  56. :reboot
  57. reboot
  58. goto start
  59. :debug
  60. echo Type "exit" to return to menu
  61. shell
  62. goto failsafe