Files
ProxmoxVE/install/peanut-install.sh
T
2026-05-03 22:38:30 +02:00

79 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 tteck
# Author: tteck (tteckster)
# Co-Author: remz1337
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/Brandawg93/PeaNUT/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing NUT"
$STD apt install -y nut-client
msg_ok "Installed NUT"
NODE_VERSION="24" 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 pnpm i
$STD pnpm run build:local
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
if [[ ! -f /etc/peanut/settings.yml ]]; then
cat <<EOF >/etc/peanut/settings.yml
NUT_SERVERS: []
EOF
fi
ln -sf /etc/peanut/settings.yml /opt/peanut/.next/standalone/config/settings.yml
cat <<EOF >/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"
cat <<EOF >/etc/systemd/system/peanut.service
[Unit]
Description=Peanut
After=network.target
[Service]
SyslogIdentifier=peanut
Restart=always
RestartSec=5
Type=simple
EnvironmentFile=/etc/peanut/peanut.env
WorkingDirectory=/opt/peanut
ExecStart=node /opt/peanut/entrypoint.mjs
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now peanut
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc