init.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # make our folders
  3. mkdir -p \
  4. /assets \
  5. /config/nginx/site-confs \
  6. /config/log/nginx \
  7. /run \
  8. /var/lib/nginx/tmp/client_body \
  9. /var/tmp/nginx
  10. # copy config files
  11. [[ ! -f /config/nginx/nginx.conf ]] && \
  12. cp /defaults/nginx.conf /config/nginx/nginx.conf
  13. [[ ! -f /config/nginx/site-confs/default ]] && \
  14. envsubst < /defaults/default > /config/nginx/site-confs/default
  15. # Ownership
  16. chown -R nbxyz:nbxyz /assets
  17. chown -R nbxyz:nbxyz /var/lib/nginx
  18. chown -R nbxyz:nbxyz /var/log/nginx
  19. # create local logs dir
  20. mkdir -p \
  21. /config/menus/remote \
  22. /config/menus/local
  23. # download menus if not found
  24. if [[ ! -f /config/menus/remote/menu.ipxe ]]; then
  25. if [[ -z ${MENU_VERSION+x} ]]; then
  26. MENU_VERSION=$(curl -sL "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | jq -r '.tag_name')
  27. fi
  28. echo "[netbootxyz-init] Downloading netboot.xyz at ${MENU_VERSION}"
  29. # menu files
  30. curl -o \
  31. /config/endpoints.yml -sL \
  32. "https://raw.githubusercontent.com/netbootxyz/netboot.xyz/${MENU_VERSION}/endpoints.yml"
  33. curl -o \
  34. /tmp/menus.tar.gz -sL \
  35. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/menus.tar.gz"
  36. tar xf \
  37. /tmp/menus.tar.gz -C \
  38. /config/menus/remote
  39. # boot files
  40. curl -o \
  41. /config/menus/remote/netboot.xyz.kpxe -sL \
  42. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.kpxe"
  43. curl -o \
  44. /config/menus/remote/netboot.xyz-undionly.kpxe -sL \
  45. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-undionly.kpxe"
  46. curl -o \
  47. /config/menus/remote/netboot.xyz.efi -sL \
  48. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.efi"
  49. curl -o \
  50. /config/menus/remote/netboot.xyz-snp.efi -sL \
  51. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-snp.efi"
  52. curl -o \
  53. /config/menus/remote/netboot.xyz-snponly.efi -sL \
  54. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-snponly.efi"
  55. curl -o \
  56. /config/menus/remote/netboot.xyz-arm64.efi -sL \
  57. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64.efi"
  58. curl -o \
  59. /config/menus/remote/netboot.xyz-arm64-snp.efi -sL \
  60. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64-snp.efi"
  61. curl -o \
  62. /config/menus/remote/netboot.xyz-arm64-snponly.efi -sL \
  63. "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64-snponly.efi"
  64. # layer and cleanup
  65. echo -n "${MENU_VERSION}" > /config/menuversion.txt
  66. cp -r /config/menus/remote/* /config/menus
  67. rm -f /tmp/menus.tar.gz
  68. fi
  69. # Ownership
  70. chown -R nbxyz:nbxyz /config