Refactor: PeaNUT (#6002)
This commit is contained in:
parent
417c4e466c
commit
7d223b984b
29
ct/peanut.sh
29
ct/peanut.sh
@ -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
|
||||
|
2
frontend/public/json/peanut.json
generated
2
frontend/public/json/peanut.json
generated
@ -20,7 +20,7 @@
|
||||
"script": "ct/peanut.sh",
|
||||
"resources": {
|
||||
"cpu": 2,
|
||||
"ram": 3072,
|
||||
"ram": 4096,
|
||||
"hdd": 7,
|
||||
"os": "debian",
|
||||
"version": "12"
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user