Refactor: PeaNUT (#6002)

This commit is contained in:
CanbiZ
2025-07-15 12:22:38 +02:00
committed by GitHub
parent 417c4e466c
commit 7d223b984b
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"
var_tags="${var_tags:-network;ups;}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-3072}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-7}"
var_os="${var_os:-debian}"
var_version="${var_version:-12}"
@ -27,22 +27,31 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Updating $APP to ${RELEASE}"
if ! command -v jq &>/dev/null; then
$STD apt-get install -y jq
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
curl -fsSL "https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE}" -o "peanut.tar.gz"
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components=1
rm peanut.tar.gz
msg_ok "Stopped $APP"
fetch_and_deploy_gh_release "peanut" "Brandawg93/PeaNUT" "tarball" "latest" "/opt/peanut"
msg_info "Updating $APP to ${RELEASE}"
cd /opt/peanut
$STD pnpm i
$STD pnpm run build
$STD pnpm run build:local
cp -r .next/static .next/standalone/.next/
mkdir -p /opt/peanut/.next/standalone/config
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_info "Starting $APP"
systemctl start peanut
msg_ok "Started $APP"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi

View File

@ -1,35 +1,35 @@
{
"name": "PeaNUT",
"slug": "peanut",
"categories": [
4
],
"date_created": "2024-06-14",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 3000,
"documentation": null,
"website": "https://github.com/Brandawg93/PeaNUT/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/peanut.webp",
"config_path": "/etc/peanut/settings.yml",
"description": "PeaNUT is a small dashboard for Network UPS Tools (NUT). It provides a web interface to monitor and manage UPS devices. PeaNUT allows users to view device status, retrieve information, and manage UPS parameters through its API. It's customizable for different UPS devices and supports integration with the Homepage dashboard.",
"install_methods": [
{
"type": "default",
"script": "ct/peanut.sh",
"resources": {
"cpu": 2,
"ram": 3072,
"hdd": 7,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": []
"name": "PeaNUT",
"slug": "peanut",
"categories": [
4
],
"date_created": "2024-06-14",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 3000,
"documentation": null,
"website": "https://github.com/Brandawg93/PeaNUT/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/peanut.webp",
"config_path": "/etc/peanut/settings.yml",
"description": "PeaNUT is a small dashboard for Network UPS Tools (NUT). It provides a web interface to monitor and manage UPS devices. PeaNUT allows users to view device status, retrieve information, and manage UPS parameters through its API. It's customizable for different UPS devices and supports integration with the Homepage dashboard.",
"install_methods": [
{
"type": "default",
"script": "ct/peanut.sh",
"resources": {
"cpu": 2,
"ram": 4096,
"hdd": 7,
"os": "debian",
"version": "12"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": []
}

View File

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