From 08b1398e7b53b44180cee2c7a36d6075b35a8465 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Sun, 3 May 2026 22:38:30 +0200 Subject: [PATCH] Refactor: PeaNUT for v6 (#14224) --- ct/peanut.sh | 27 +++++++++++++++++++++++++++ install/peanut-install.sh | 31 +++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/ct/peanut.sh b/ct/peanut.sh index 38647c141..c90b27968 100644 --- a/ct/peanut.sh +++ b/ct/peanut.sh @@ -45,6 +45,33 @@ function update_script() { msg_ok "Fixed entrypoint" fi + if [[ ! -f /etc/peanut/peanut.env ]]; then + msg_info "Migrating service to EnvironmentFile" + mkdir -p /etc/peanut + cat </etc/peanut/peanut.env +NODE_ENV=production + +#WEB_HOST=0.0.0.0 +#WEB_PORT=8080 +#NUT_HOST=localhost +#NUT_PORT=3493 + +# Disable auth entirely: +#AUTH_DISABLED=true + +# Bootstrap initial account on first start (ignored afterwards): +#WEB_USERNAME=admin +#WEB_PASSWORD=changeme +EOF + chmod 600 /etc/peanut/peanut.env + sed -i '/^Environment=/d' /etc/systemd/system/peanut.service + if ! grep -q '^EnvironmentFile=/etc/peanut/peanut.env' /etc/systemd/system/peanut.service; then + sed -i '/^Type=simple/a EnvironmentFile=/etc/peanut/peanut.env' /etc/systemd/system/peanut.service + fi + systemctl daemon-reload + msg_ok "Migrated to /etc/peanut/peanut.env" + fi + msg_info "Updating PeaNUT" cd /opt/peanut $STD pnpm i diff --git a/install/peanut-install.sh b/install/peanut-install.sh index 5fa4cbaf3..9c65dd93b 100644 --- a/install/peanut-install.sh +++ b/install/peanut-install.sh @@ -29,13 +29,28 @@ cp -r .next/static .next/standalone/.next/ mkdir -p /opt/peanut/.next/standalone/config mkdir -p /etc/peanut/ ln -sf .next/standalone/server.js server.js -cat </etc/peanut/settings.yml -WEB_HOST: 0.0.0.0 -WEB_PORT: 8080 -NUT_HOST: 0.0.0.0 -NUT_PORT: 3493 +if [[ ! -f /etc/peanut/settings.yml ]]; then + cat </etc/peanut/settings.yml +NUT_SERVERS: [] EOF +fi ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml +cat </etc/peanut/peanut.env +NODE_ENV=production + +#WEB_HOST=0.0.0.0 +#WEB_PORT=8080 +#NUT_HOST=localhost +#NUT_PORT=3493 + +# Disable auth entirely: +#AUTH_DISABLED=true + +# Bootstrap initial account on first start (ignored afterwards): +#WEB_USERNAME=admin +#WEB_PASSWORD=changeme +EOF +chmod 600 /etc/peanut/peanut.env msg_ok "Setup Peanut" msg_info "Creating Service" @@ -48,11 +63,7 @@ SyslogIdentifier=peanut Restart=always RestartSec=5 Type=simple -Environment="NODE_ENV=production" -#Environment="NUT_HOST=localhost" -#Environment="NUT_PORT=3493" -#Environment="WEB_HOST=0.0.0.0" -#Environment="WEB_PORT=8080" +EnvironmentFile=/etc/peanut/peanut.env WorkingDirectory=/opt/peanut ExecStart=node /opt/peanut/entrypoint.mjs TimeoutStopSec=30