diff --git a/root/defaults/nginx.conf b/root/defaults/nginx.conf index 7649f6d..ae1d6f0 100644 --- a/root/defaults/nginx.conf +++ b/root/defaults/nginx.conf @@ -1,4 +1,4 @@ -user abc; +user nbxyz; worker_processes 4; pid /run/nginx.pid; include /etc/nginx/modules/*.conf; diff --git a/root/donate.txt b/root/donate.txt new file mode 100644 index 0000000..dbcfea2 --- /dev/null +++ b/root/donate.txt @@ -0,0 +1,2 @@ +opencollective: https://opencollective.com/netbootxyz/donate +github: https://github.com/sponsors/netbootxyz diff --git a/root/etc/cont-init.d/20-nginx-config b/root/etc/cont-init.d/20-nginx-config deleted file mode 100644 index ab2991a..0000000 --- a/root/etc/cont-init.d/20-nginx-config +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/with-contenv bash - -# make our folders -mkdir -p \ - /assets \ - /config/{nginx/site-confs,log/nginx} \ - /run \ - /var/lib/nginx/tmp/client_body \ - /var/tmp/nginx - -# copy config files -[[ ! -f /config/nginx/nginx.conf ]] && \ - cp /defaults/nginx.conf /config/nginx/nginx.conf -[[ ! -f /config/nginx/site-confs/default ]] && \ - cp /defaults/default /config/nginx/site-confs/default - -# Ownership -chown -R abc:abc /assets \ No newline at end of file diff --git a/root/etc/cont-init.d/35-dev-config b/root/etc/cont-init.d/35-dev-config deleted file mode 100644 index abcbe3d..0000000 --- a/root/etc/cont-init.d/35-dev-config +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/with-contenv bash - -# create local logs dir -mkdir -p /applogs -chown -R abc:abc /applogs - diff --git a/root/etc/cont-init.d/36-download-menus b/root/etc/cont-init.d/36-download-menus deleted file mode 100644 index 738e8dc..0000000 --- a/root/etc/cont-init.d/36-download-menus +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/with-contenv bash - -# create local logs dir -mkdir -p \ - /config/menus/remote \ - /config/menus/local - -# download menus if not found -if [[ ! -f /config/menus/remote/menu.ipxe ]]; then - if [[ -z ${MENU_VERSION+x} ]]; then \ - MENU_VERSION=$(curl -sL "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | jq -r '.tag_name') - fi - echo "[netbootxyz-init] Downloading Netboot.xyz at ${MENU_VERSION}" - # menu files - curl -o \ - /config/endpoints.yml -sL \ - "https://raw.githubusercontent.com/netbootxyz/netboot.xyz/${MENU_VERSION}/endpoints.yml" - curl -o \ - /tmp/menus.tar.gz -sL \ - "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/menus.tar.gz" - tar xf \ - /tmp/menus.tar.gz -C \ - /config/menus/remote - # boot files - curl -o \ - /config/menus/remote/netboot.xyz-undionly.kpxe -sL \ - "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-undionly.kpxe" - curl -o \ - /config/menus/remote/netboot.xyz.efi -sL \ - "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.efi" - curl -o \ - /config/menus/remote/netboot.xyz.kpxe -sL \ - "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.kpxe" - # layer and cleanup - echo -n ${MENU_VERSION} > /config/menuversion.txt - cp /config/menus/remote/* /config/menus - rm -f /tmp/menus.tar.gz -fi - -# Ownership -chown -R abc:abc /config diff --git a/root/etc/services.d/nginx/run b/root/etc/services.d/nginx/run deleted file mode 100644 index daf42ab..0000000 --- a/root/etc/services.d/nginx/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/with-contenv bash -exec /usr/sbin/nginx -c /config/nginx/nginx.conf \ No newline at end of file diff --git a/root/etc/services.d/tftp/run b/root/etc/services.d/tftp/run deleted file mode 100644 index 35b39e2..0000000 --- a/root/etc/services.d/tftp/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bash - -/usr/sbin/in.tftpd \ - --foreground --listen --user abc --secure /config/menus \ No newline at end of file diff --git a/root/etc/services.d/webapp/run b/root/etc/services.d/webapp/run deleted file mode 100644 index ef8ddc5..0000000 --- a/root/etc/services.d/webapp/run +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/with-contenv bash - -# Run App in development mode -cd /code -exec \ -s6-setuidgid abc /usr/bin/nodemon app.js &> /applogs/app.log diff --git a/root/etc/supervisor.conf b/root/etc/supervisor.conf new file mode 100644 index 0000000..986420e --- /dev/null +++ b/root/etc/supervisor.conf @@ -0,0 +1,33 @@ +[supervisord] +nodaemon=true +user=root + +[program:syslog-ng] +command=/usr/sbin/syslog-ng --foreground --no-caps +stdout_syslog=true +stdout_capture_maxbytes=1MB +priority = 1 + +[program:nginx] +command = /usr/sbin/nginx -c /config/nginx/nginx.conf +startretries = 2 +daemon=off +priority = 2 + +[program:webapp] +environment=NODE_ENV="production",PORT=3000 +command=/usr/bin/node app.js +user=nbxyz +directory=/app +priority = 3 + +[program:in.tftpd] +command=/usr/sbin/in.tftpd -Lvvv --user nbxyz --secure %(ENV_TFTPD_OPTS)s /config/menus +stdout_logfile=/config/tftpd.log +redirect_stderr=true +priority = 4 + +[program:messages-log] +command=tail -f /var/log/messages +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 diff --git a/root/start.sh b/root/start.sh new file mode 100755 index 0000000..2aab5dc --- /dev/null +++ b/root/start.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# make our folders +mkdir -p \ + /assets \ + /config/nginx/site-confs \ + /config/log/nginx \ + /run \ + /var/lib/nginx/tmp/client_body \ + /var/tmp/nginx + +# copy config files +[[ ! -f /config/nginx/nginx.conf ]] && \ + cp /defaults/nginx.conf /config/nginx/nginx.conf +[[ ! -f /config/nginx/site-confs/default ]] && \ + cp /defaults/default /config/nginx/site-confs/default + +# Ownership +chown -R nbxyz:nbxyz /assets +chown -R nbxyz:nbxyz /var/lib/nginx +chown -R nbxyz:nbxyz /var/log/nginx + +# create local logs dir +mkdir -p \ + /config/menus/remote \ + /config/menus/local + +# download menus if not found +if [[ ! -f /config/menus/remote/menu.ipxe ]]; then + if [[ -z ${MENU_VERSION+x} ]]; then \ + MENU_VERSION=$(curl -sL "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | jq -r '.tag_name') + fi + echo "[netbootxyz-init] Downloading netboot.xyz at ${MENU_VERSION}" + # menu files + curl -o \ + /config/endpoints.yml -sL \ + "https://raw.githubusercontent.com/netbootxyz/netboot.xyz/${MENU_VERSION}/endpoints.yml" + curl -o \ + /tmp/menus.tar.gz -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/menus.tar.gz" + tar xf \ + /tmp/menus.tar.gz -C \ + /config/menus/remote + # boot files + curl -o \ + /config/menus/remote/netboot.xyz.kpxe -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.kpxe" + curl -o \ + /config/menus/remote/netboot.xyz-undionly.kpxe -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-undionly.kpxe" + curl -o \ + /config/menus/remote/netboot.xyz.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz.efi" + curl -o \ + /config/menus/remote/netboot.xyz-snp.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-snp.efi" + curl -o \ + /config/menus/remote/netboot.xyz-snponly.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-snponly.efi" + curl -o \ + /config/menus/remote/netboot.xyz-arm64.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64.efi" + curl -o \ + /config/menus/remote/netboot.xyz-arm64-snp.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64-snp.efi" + curl -o \ + /config/menus/remote/netboot.xyz-arm64-snponly.efi -sL \ + "https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/netboot.xyz-arm64-snponly.efi" + # layer and cleanup + echo -n ${MENU_VERSION} > /config/menuversion.txt + cp -r /config/menus/remote/* /config/menus + rm -f /tmp/menus.tar.gz +fi + +# Ownership +chown -R nbxyz:nbxyz /config + +echo " _ _ _ " +echo " _ __ ___| |_| |__ ___ ___ | |_ __ ___ _ ____ " +echo "| '_ \ / _ \ __| '_ \ / _ \ / _ \| __| \ \/ / | | |_ / " +echo "| | | | __/ |_| |_) | (_) | (_) | |_ _ > <| |_| |/ / " +echo "|_| |_|\___|\__|_.__/ \___/ \___/ \__(_)_/\_\\__, /___| " +echo " |___/ " + +supervisord -c /etc/supervisor.conf