Files

147 lines
4.6 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
APPNAME="NodeBB"
OS="NodeBB"
if [[ "$1" == "--update" ]]; then
if [[ -d /opt/nodebb ]]; then
echo -e "\033[38;5;45m Checking Updates $APPNAME $OS....\033[0m"
eval "$(curl -fsSL https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main/core/OS_handler.func)"
export DEBIAN_FRONTEND=noninteractive
RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
CURRENT=$(cat /opt/NodeBB_version.txt 2>/dev/null || echo "0")
if [[ "${RELEASE}" != "${CURRENT}" ]]; then
echo -e "\033[38;5;45m Deactivating NodeBB...\033[0m"
if [[ "$OS_ID" == "alpine" ]]; then
rc-service nodebb stop 2>/dev/null || true
else
systemctl stop nodebb 2>/dev/null || true
fi
echo -e "\033[38;5;45m Updating to v${RELEASE}...\033[0m"
cd /opt/nodebb
./nodebb upgrade >/dev/null 2>&1
echo "${RELEASE}" >/opt/NodeBB_version.txt
echo -e "\033[38;5;45m Reactivating NodeBB...\033[0m"
if [[ "$OS_ID" == "alpine" ]]; then
rc-service nodebb start
else
systemctl start nodebb
fi
echo -e "\033[38;5;178m✅ Update Complete, $OS.\033[0m"
else
echo -e "\033[38;5;178m✅ NodeBB is already at v${RELEASE}.\033[0m"
fi
exit 0
else
echo -e "\033[38;5;196m❌ Error: Execution failed. Not on Proxmox Host, and no valid installation found.\033[0m"
exit 1
fi
fi
eval "$(curl -fsSL https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main/core/OS_handler.func)"
eval "$(curl -fsSL https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main/core/build.func)"
APP="NodeBB"
PORT="4567"
VERSION="1.2.0"
MODULE_PATH="modules/provision/social/nodebb.sh"
var_tags="forum;social"
var_disk="12"
var_cpu="4"
var_ram="2048"
var_os="debian"
var_version="12"
start
msg_info "Grounding $OS_CHOICE..."
cat << 'EOF' > /tmp/dynr_install.sh
eval "$(curl -fsSL https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main/core/OS_handler.func)"
export DEBIAN_FRONTEND=noninteractive
$PKG_UPDATE >/dev/null 2>&1
$PKG_INSTALL curl wget git sudo tzdata >/dev/null 2>&1
if [[ "$OS_ID" == "alpine" ]]; then
$PKG_INSTALL openssl nodejs npm mongodb mongodb-tools
rc-update add mongodb default
rc-service mongodb start
else
if [[ "$OS_ID" == "debian" || "$OS_ID" == "ubuntu" ]]; then
$PKG_INSTALL locales openssl gnupg >/dev/null 2>&1
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen >/dev/null 2>&1
locale-gen en_US.UTF-8 >/dev/null 2>&1
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
$PKG_INSTALL nodejs
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
$PKG_UPDATE
$PKG_INSTALL mongodb-org
systemctl enable --now mongod
else
$PKG_INSTALL openssl nodejs npm mongodb
fi
fi
mkdir -p /opt/nodebb
git clone -b v3.x https://github.com/NodeBB/NodeBB.git /opt/nodebb
cd /opt/nodebb
npm install --production
RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
echo "${RELEASE}" >/opt/NodeBB_version.txt
if [[ "$OS_ID" == "alpine" ]]; then
npm install -g pm2
pm2 start ./nodebb --name "nodebb" -- start
pm2 startup
pm2 save
else
cat <<SVC >/etc/systemd/system/nodebb.service
[Unit]
Description=NodeBB
Documentation=https://docs.nodebb.org
After=system.slice multi-user.target mongod.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/nodebb
ExecStart=/usr/bin/node ./nodebb start
Restart=always
[Install]
WantedBy=multi-user.target
SVC
systemctl daemon-reload
systemctl enable --now nodebb
fi
mkdir -p /opt/DYNR
echo "NodeBB: http://localhost:4567" > /opt/DYNR/urls.txt
cat << 'UPDATE' > /usr/local/bin/update
#!/usr/bin/env bash
curl -fsSL https://git.dynastyrevolution.com/DYNR/DynastyRevolution-Scripts/raw/branch/main/modules/provision/social/nodebb.sh | bash -s -- --update
UPDATE
chmod +x /usr/local/bin/update
EOF
msg_info "Welding NodeBB $CT_ID..."
pct push "$CT_ID" /tmp/dynr_install.sh /root/dynr_install.sh
msg_info "Sanding Provision..."
manifest_provision pct exec "$CT_ID" -- bash /root/dynr_install.sh
pct exec "$CT_ID" -- rm /root/dynr_install.sh
rm /tmp/dynr_install.sh
description