Refactor: PeaNUT (#6002)

This commit is contained in:
CanbiZ 2025-07-15 12:22:38 +02:00 committed by GitHub
parent 417c4e466c
commit 7d223b984b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 58 additions and 54 deletions

View File

@ -8,7 +8,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
APP="PeaNUT" APP="PeaNUT"
var_tags="${var_tags:-network;ups;}" var_tags="${var_tags:-network;ups;}"
var_cpu="${var_cpu:-2}" var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-3072}" var_ram="${var_ram:-4096}"
var_disk="${var_disk:-7}" var_disk="${var_disk:-7}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-12}" var_version="${var_version:-12}"
@ -27,22 +27,31 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4) if ! command -v jq &>/dev/null; then
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then $STD apt-get install -y jq
msg_info "Updating $APP to ${RELEASE}" fi
NODE_VERSION="22" NODE_MODULE="pnpm" setup_nodejs
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if [[ "${RELEASE}" != "$(cat ~/.peanut 2>/dev/null)" ]] || [[ ! -f ~/.peanut ]]; then
msg_info "Stopping $APP"
systemctl stop peanut systemctl stop peanut
curl -fsSL "https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE}" -o "peanut.tar.gz" msg_ok "Stopped $APP"
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components=1
rm peanut.tar.gz fetch_and_deploy_gh_release "peanut" "Brandawg93/PeaNUT" "tarball" "latest" "/opt/peanut"
msg_info "Updating $APP to ${RELEASE}"
cd /opt/peanut cd /opt/peanut
$STD pnpm i $STD pnpm i
$STD pnpm run build $STD pnpm run build:local
cp -r .next/static .next/standalone/.next/ cp -r .next/static .next/standalone/.next/
mkdir -p /opt/peanut/.next/standalone/config mkdir -p /opt/peanut/.next/standalone/config
ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml
systemctl start peanut
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to ${RELEASE}" msg_ok "Updated $APP to ${RELEASE}"
msg_info "Starting $APP"
systemctl start peanut
msg_ok "Started $APP"
else else
msg_ok "No update required. ${APP} is already at ${RELEASE}" msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi fi

View File

@ -20,7 +20,7 @@
"script": "ct/peanut.sh", "script": "ct/peanut.sh",
"resources": { "resources": {
"cpu": 2, "cpu": 2,
"ram": 3072, "ram": 4096,
"hdd": 7, "hdd": 7,
"os": "debian", "os": "debian",
"version": "12" "version": "12"

View File

@ -14,22 +14,17 @@ setting_up_container
network_check network_check
update_os update_os
NODE_VERSION="22" setup_nodejs
msg_info "Installing NUT" msg_info "Installing NUT"
$STD apt-get install -y nut-client $STD apt-get install -y nut-client
msg_ok "Installed NUT" msg_ok "Installed NUT"
msg_info "Installing Peanut" NODE_VERSION="22" NODE_MODULE="pnpm" setup_nodejs
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4) fetch_and_deploy_gh_release "peanut" "Brandawg93/PeaNUT" "tarball" "latest" "/opt/peanut"
curl -fsSL "https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE}" -o "peanut.tar.gz"
mkdir -p /opt/peanut msg_info "Setup Peanut"
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components=1
rm peanut.tar.gz
cd /opt/peanut cd /opt/peanut
$STD npm install -g pnpm
$STD pnpm i $STD pnpm i
$STD pnpm run build $STD pnpm run build:local
cp -r .next/static .next/standalone/.next/ cp -r .next/static .next/standalone/.next/
mkdir -p /opt/peanut/.next/standalone/config mkdir -p /opt/peanut/.next/standalone/config
mkdir -p /etc/peanut/ mkdir -p /etc/peanut/
@ -40,7 +35,7 @@ NUT_HOST: 0.0.0.0
NUT_PORT: 3493 NUT_PORT: 3493
EOF EOF
ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml
msg_ok "Installed Peanut" msg_ok "Setup Peanut"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/peanut.service cat <<EOF >/etc/systemd/system/peanut.service