Skip to content

Commit 7d223b9

Browse files
authored
Refactor: PeaNUT (#6002)
1 parent 417c4e4 commit 7d223b9

File tree

3 files changed

+58
-54
lines changed

3 files changed

+58
-54
lines changed

ct/peanut.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
88
APP="PeaNUT"
99
var_tags="${var_tags:-network;ups;}"
1010
var_cpu="${var_cpu:-2}"
11-
var_ram="${var_ram:-3072}"
11+
var_ram="${var_ram:-4096}"
1212
var_disk="${var_disk:-7}"
1313
var_os="${var_os:-debian}"
1414
var_version="${var_version:-12}"
@@ -27,22 +27,31 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32-
msg_info "Updating $APP to ${RELEASE}"
30+
if ! command -v jq &>/dev/null; then
31+
$STD apt-get install -y jq
32+
fi
33+
NODE_VERSION="22" NODE_MODULE="pnpm" setup_nodejs
34+
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | jq -r '.tag_name' | sed 's/^v//')
35+
if [[ "${RELEASE}" != "$(cat ~/.peanut 2>/dev/null)" ]] || [[ ! -f ~/.peanut ]]; then
36+
37+
msg_info "Stopping $APP"
3338
systemctl stop peanut
34-
curl -fsSL "https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE}" -o "peanut.tar.gz"
35-
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components=1
36-
rm peanut.tar.gz
39+
msg_ok "Stopped $APP"
40+
41+
fetch_and_deploy_gh_release "peanut" "Brandawg93/PeaNUT" "tarball" "latest" "/opt/peanut"
42+
43+
msg_info "Updating $APP to ${RELEASE}"
3744
cd /opt/peanut
3845
$STD pnpm i
39-
$STD pnpm run build
46+
$STD pnpm run build:local
4047
cp -r .next/static .next/standalone/.next/
4148
mkdir -p /opt/peanut/.next/standalone/config
4249
ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml
43-
systemctl start peanut
44-
echo "${RELEASE}" >/opt/${APP}_version.txt
4550
msg_ok "Updated $APP to ${RELEASE}"
51+
52+
msg_info "Starting $APP"
53+
systemctl start peanut
54+
msg_ok "Started $APP"
4655
else
4756
msg_ok "No update required. ${APP} is already at ${RELEASE}"
4857
fi

frontend/public/json/peanut.json

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/peanut-install.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@ setting_up_container
1414
network_check
1515
update_os
1616

17-
NODE_VERSION="22" setup_nodejs
18-
1917
msg_info "Installing NUT"
2018
$STD apt-get install -y nut-client
2119
msg_ok "Installed NUT"
2220

23-
msg_info "Installing Peanut"
24-
RELEASE=$(curl -fsSL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
25-
curl -fsSL "https://api.github.com/repos/Brandawg93/PeaNUT/tarball/${RELEASE}" -o "peanut.tar.gz"
26-
mkdir -p /opt/peanut
27-
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components=1
28-
rm peanut.tar.gz
21+
NODE_VERSION="22" NODE_MODULE="pnpm" setup_nodejs
22+
fetch_and_deploy_gh_release "peanut" "Brandawg93/PeaNUT" "tarball" "latest" "/opt/peanut"
23+
24+
msg_info "Setup Peanut"
2925
cd /opt/peanut
30-
$STD npm install -g pnpm
3126
$STD pnpm i
32-
$STD pnpm run build
27+
$STD pnpm run build:local
3328
cp -r .next/static .next/standalone/.next/
3429
mkdir -p /opt/peanut/.next/standalone/config
3530
mkdir -p /etc/peanut/
@@ -40,7 +35,7 @@ NUT_HOST: 0.0.0.0
4035
NUT_PORT: 3493
4136
EOF
4237
ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml
43-
msg_ok "Installed Peanut"
38+
msg_ok "Setup Peanut"
4439

4540
msg_info "Creating Service"
4641
cat <<EOF >/etc/systemd/system/peanut.service

0 commit comments

Comments
 (0)