Advertisement
Guest User

booter

a guest
May 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. #!ipxe
  2.  
  3. set os New Alpine Linux
  4. iseq ${ipxe_cloud_config} packet && set provider (Packet.net) ||
  5. iseq ${alpine_loader} true && set img_verify enabled || set img_verify disabled
  6. set console tty0 ||
  7. set cmdline modules=loop,squashfs quiet nomodeset ||
  8. set default_cmdline default ||
  9. set start_sshd no ||
  10. set branch v3.9 ||
  11. set version 3.9.1 ||
  12. set flavor vanilla ||
  13. iseq ${buildarch} arm64 && goto arm64 ||
  14. cpuid --ext 29 && goto x86_64 || goto x86
  15.  
  16. :arm64
  17. set arch aarch64 ||
  18. set acpi acpi=force ||
  19. set console ttyAMA0 ||
  20. iseq ${ipxe_cloud_config} packet && set console ttyAMA0,115200 ||
  21. goto menu
  22.  
  23. :x86_64
  24. set arch x86_64 ||
  25. iseq ${ipxe_cloud_config} packet && set console ttyS1,115200n8 ||
  26. goto menu
  27.  
  28. :x86
  29. set arch x86 ||
  30. goto menu
  31.  
  32. :menu
  33. set space:hex 20:20
  34. set space ${space:string}
  35. menu ${os} ${provider} [ ${arch} ]
  36. item --gap Boot options
  37. item branch ${space} Alpine release [ ${branch} ]
  38. iseq ${arch} x86_64 && item flavor ${space} Kernel flavor [ ${flavor} ] ||
  39. iseq ${alpine_loader} true && item img_verify ${space} Image verification [ ${img_verify} ] ||
  40. item cmdline ${space} Linux cmdline [ ${default_cmdline} ]
  41. item console ${space} Set console [ ${console} ]
  42. item start_sshd ${space} Start sshd at first boot [ ${start_sshd} ]
  43. item --gap Booting
  44. item boot ${space} Boot with above settings
  45. item --gap Utilities
  46. item shell ${space} iPXE Shell
  47. item reboot ${space} Reboot system
  48. choose item
  49. goto ${item}
  50.  
  51. :branch
  52. menu ${os} ${provider} [ ${arch} ]
  53. item v3.9 Version 3.9.1
  54. item edge Version 20190228
  55. item v3.8 Version 3.8.2
  56. choose branch || goto shell
  57. iseq ${branch} v3.9 && set version 3.9.1 ||
  58. iseq ${branch} edge && set version 20190228 ||
  59. iseq ${branch} v3.8 && set version 3.8.2 ||
  60. goto menu
  61.  
  62. :flavor
  63. menu ${os} ${provider} [ ${arch} ]
  64. item vanilla Linux vanilla
  65. item virt Linux virt
  66. choose flavor || goto shell
  67. goto menu
  68.  
  69. :console
  70. menu ${os} ${provider} [ ${arch} ]
  71. item tty0 Console on tty0
  72. item ttyS0 Console on ttyS0
  73. item ttyS1 Console on ttyS1
  74. item ttyAMA0 Console on ttyAMA0
  75. item custom Enter custom console
  76. choose console || goto menu
  77. iseq ${console} custom && goto custom_console ||
  78. goto menu
  79.  
  80. :custom_console
  81. clear console
  82. echo -n Enter console: && read console
  83. goto menu
  84.  
  85. :shell
  86. echo Type "exit" to return to menu.
  87. shell
  88. goto menu
  89.  
  90. :img_verify
  91. iseq ${img_verify} enabled && set img_verify disabled || set img_verify enabled
  92. goto menu
  93.  
  94. :cmdline
  95. echo -n Enter extra cmdline options:${space} && read cmdline
  96. set default_cmdline modified
  97. goto menu
  98.  
  99. :start_sshd
  100. clear start_sshd
  101. echo -n Enter url to ssh key:${space} && read ssh_key
  102. isset ${ssh_key} && set start_sshd yes || set start_sshd no
  103. iseq ${start_sshd} yes && set ssh_key ssh_key=${ssh_key} || clear ssh_key
  104. goto menu
  105.  
  106. :boot
  107. isset ${console} && set console console=${console} ||
  108. set mirror http://dl-cdn.alpinelinux.org/alpine
  109. set img-url ${mirror}/${branch}/releases/${arch}/netboot-${version}
  110. set sig-url sigs/${branch}/${arch}/${version}
  111. set repo-url ${mirror}/${branch}/main
  112. set modloop-url ${img-url}/modloop-${flavor}
  113. imgfree
  114. kernel ${img-url}/vmlinuz-${flavor} ${cmdline} alpine_repo=${repo-url} modloop=${modloop-url} ${console} ${acpi} ${ssh_key}
  115. initrd ${img-url}/initramfs-${flavor}
  116. iseq ${img_verify} enabled && goto verify_img || goto no_img_verify
  117. :verify_img
  118. imgverify vmlinuz-${flavor} ${sig-url}/vmlinuz-${flavor}.sig
  119. imgverify initramfs-${flavor} ${sig-url}/initramfs-${flavor}.sig
  120. :no_img_verify
  121. boot
  122. goto alpine_exit
  123.  
  124. :reboot
  125. reboot
  126.  
  127. :poweroff
  128. poweroff
  129.  
  130. :alpine_exit
  131. clear menu
  132. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement