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