Compare commits

...

5 Commits

Author SHA1 Message Date
Rémi Bédard-Couture
0052550dc7 Fix update script with correct URL 2024-06-12 23:01:44 -04:00
Rémi Bédard-Couture
579012ae30 Silence peanut installation and update service configuration 2024-06-12 22:55:05 -04:00
Rémi Bédard-Couture
ac7997c117 Fix download URL and extraction 2024-06-12 22:54:57 -04:00
Rémi Bédard-Couture
8e1e02e8d0 First draft with manual local build command 2024-06-12 22:54:50 -04:00
Rémi Bédard-Couture
360706d54a (WIP) Writing script for Peanut 2024-06-12 22:54:12 -04:00
2 changed files with 167 additions and 0 deletions

87
ct/peanut.sh Normal file
View File

@@ -0,0 +1,87 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/remz1337/Proxmox/remz/misc/build.func)
# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# Co-Author: remz1337
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
function header_info {
clear
cat <<"EOF"
____ __
/ __ \___ ____ _____ __ __/ /_
/ /_/ / _ \/ __ `/ __ \/ / / / __/
/ ____/ __/ /_/ / / / / /_/ / /_
/_/ \___/\__,_/_/ /_/\__,_/\__/
EOF
}
header_info
echo -e "Loading..."
APP="Peanut"
var_disk="4"
var_cpu="2"
var_ram="2048"
var_os="debian"
var_version="12"
variables
color
catch_errors
function default_settings() {
CT_TYPE="1"
PW=""
CT_ID=$NEXTID
HN=$NSAPP
DISK_SIZE="$var_disk"
CORE_COUNT="$var_cpu"
RAM_SIZE="$var_ram"
BRG="vmbr0"
NET="dhcp"
GATE=""
APT_CACHER=""
APT_CACHER_IP=""
DISABLEIP6="no"
MTU=""
SD=""
NS=""
MAC=""
VLAN=""
SSH="no"
VERB="no"
echo_default
}
function update_script() {
header_info
if [[ ! -f /etc/systemd/system/peanut.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
RELEASE=$(curl -sL https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep '"tag_name":' | cut -d'"' -f4)
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
msg_info "Updating $APP LXC"
systemctl stop peanut
RELEASE_URL=$(curl -s https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep "tarball_url" | awk '{print substr($2, 2, length($2)-3)}')
wget -qO peanut.tar.gz $RELEASE_URL
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components 1
rm peanut.tar.gz
systemctl start peanut
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP LXC"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit
}
start
build_container
description
msg_info "Setting Container to Normal Resources"
pct set $CTID -memory 512
pct set $CTID -cores 1
msg_ok "Set Container to Normal Resources"
msg_ok "Completed Successfully!\n"
echo -e "${APP} should be reachable by going to the following URL.
${BL}http://${IP}:3000${CL} \n
${YW}Don't forget to update the NUT configuration!${CL} \n"

80
install/peanut-install.sh Normal file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# Co-Author: remz1337
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y curl
$STD apt-get install -y sudo
$STD apt-get install -y mc
$STD apt-get install -y wget
$STD apt-get install -y gpg
msg_ok "Installed Dependencies"
msg_info "Installing Node.js"
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
$STD apt-get update
$STD apt-get install -y nodejs
msg_ok "Installed Node.js"
msg_info "Installing NUT"
$STD apt-get install -y nut-client
msg_ok "Installed NUT"
msg_info "Installing Peanut"
RELEASE_URL=$(curl -s https://api.github.com/repos/Brandawg93/PeaNUT/releases/latest | grep "tarball_url" | awk '{print substr($2, 2, length($2)-3)}')
wget -qO peanut.tar.gz $RELEASE_URL
mkdir -p /opt/peanut
tar -xzf peanut.tar.gz -C /opt/peanut --strip-components 1
rm peanut.tar.gz
cd /opt/peanut
$STD npm install -g pnpm
$STD pnpm i
$STD npm run build
cp -r .next/static .next/standalone/.next/
msg_ok "Installed 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
Environment="NODE_ENV=production"
Environment="NUT_HOST=localhost"
Environment="NUT_PORT=3493"
Environment="WEB_HOST=0.0.0.0"
Environment="WEB_PORT=3000"
WorkingDirectory=/opt/peanut
ExecStart=node /opt/peanut/.next/standalone/server.js
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now peanut.service
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"