mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	New Script: NodeBB (#1811)
This commit is contained in:
		
							
								
								
									
										63
									
								
								ct/nodebb.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								ct/nodebb.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
 | 
			
		||||
# Copyright (c) 2021-2025 community-scripts ORG
 | 
			
		||||
# Author: MickLesk (Canbiz)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
# App Default Values
 | 
			
		||||
APP="NodeBB"
 | 
			
		||||
var_tags="forum"
 | 
			
		||||
var_disk="10"
 | 
			
		||||
var_cpu="4"
 | 
			
		||||
var_ram="2048"
 | 
			
		||||
var_os="ubuntu"
 | 
			
		||||
var_version="24.04"
 | 
			
		||||
var_unprivileged="1"
 | 
			
		||||
 | 
			
		||||
# App Output & Base Settings
 | 
			
		||||
header_info "$APP"
 | 
			
		||||
 | 
			
		||||
# Core
 | 
			
		||||
variables
 | 
			
		||||
color
 | 
			
		||||
catch_errors
 | 
			
		||||
 | 
			
		||||
function update_script() {
 | 
			
		||||
  header_info
 | 
			
		||||
  check_container_storage
 | 
			
		||||
  check_container_resources
 | 
			
		||||
  if [[ ! -d /opt/nodebb ]]; then
 | 
			
		||||
    msg_error "No ${APP} Installation Found!"
 | 
			
		||||
    exit
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
			
		||||
  if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
 | 
			
		||||
    msg_info "Stopping ${APP}"
 | 
			
		||||
    systemctl stop nodebb
 | 
			
		||||
    msg_ok "Stopped ${APP}"
 | 
			
		||||
 | 
			
		||||
    msg_info "Updating ${APP} to v${RELEASE}"
 | 
			
		||||
    cd /opt/nodebb
 | 
			
		||||
    ./nodebb upgrade >/dev/null 2>&1
 | 
			
		||||
    echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
			
		||||
    msg_ok "Updated ${APP} to v${RELEASE}"
 | 
			
		||||
 | 
			
		||||
    msg_info "Starting ${APP}"
 | 
			
		||||
    systemctl start nodebb
 | 
			
		||||
    msg_ok "Started ${APP}"
 | 
			
		||||
    msg_ok "Updated Successfully"
 | 
			
		||||
  else
 | 
			
		||||
    msg_ok "No update required. ${APP} is already at v${RELEASE}."
 | 
			
		||||
  fi
 | 
			
		||||
  exit
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
start
 | 
			
		||||
build_container
 | 
			
		||||
description
 | 
			
		||||
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
			
		||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
			
		||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4567${CL}"
 | 
			
		||||
							
								
								
									
										164
									
								
								install/nodebb-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								install/nodebb-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,164 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
# Copyright (c) 2021-2024 tteck
 | 
			
		||||
# Author: MickLesk (Canbiz)
 | 
			
		||||
# License: MIT | https://github.com/tteck/Proxmox/raw/main/LICENSE
 | 
			
		||||
# Source: https://github.com/NodeBB/NodeBB
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
 | 
			
		||||
color
 | 
			
		||||
verb_ip6
 | 
			
		||||
catch_errors
 | 
			
		||||
setting_up_container
 | 
			
		||||
network_check
 | 
			
		||||
update_os
 | 
			
		||||
 | 
			
		||||
msg_info "Installing Dependencies (Patience)"
 | 
			
		||||
$STD apt-get install -y \
 | 
			
		||||
  build-essential \
 | 
			
		||||
  curl \
 | 
			
		||||
  sudo \
 | 
			
		||||
  make \
 | 
			
		||||
  redis-server \
 | 
			
		||||
  expect \
 | 
			
		||||
  gnupg \
 | 
			
		||||
  ca-certificates \
 | 
			
		||||
  mc
 | 
			
		||||
msg_ok "Installed Dependencies"
 | 
			
		||||
 | 
			
		||||
msg_info "Setting up Node.js & MongoDB Repository"
 | 
			
		||||
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_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
 | 
			
		||||
 | 
			
		||||
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg --dearmor -o /etc/apt/keyrings/mongodb-server-8.0.gpg
 | 
			
		||||
echo "deb [arch=amd64,arm64 signed-by=/etc/apt/keyrings/mongodb-server-8.0.gpg] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-8.0.list
 | 
			
		||||
$STD apt-get update
 | 
			
		||||
msg_ok "Set up Repositories"
 | 
			
		||||
 | 
			
		||||
msg_info "Installing Node.js"
 | 
			
		||||
$STD apt-get install -y nodejs
 | 
			
		||||
msg_ok "Installed Node.js"
 | 
			
		||||
 | 
			
		||||
msg_info "Installing MongoDB"
 | 
			
		||||
$STD apt-get install -y mongodb-org
 | 
			
		||||
systemctl enable -q --now mongod
 | 
			
		||||
sleep 10 # MongoDB needs some secounds to start, if not sleep it collide with following mongosh
 | 
			
		||||
msg_ok "Installed MongoDB"   
 | 
			
		||||
 | 
			
		||||
msg_info "Configure MongoDB"
 | 
			
		||||
MONGO_ADMIN_USER="admin"
 | 
			
		||||
MONGO_ADMIN_PWD="$(openssl rand -base64 18 | cut -c1-13)"
 | 
			
		||||
NODEBB_USER="nodebb"
 | 
			
		||||
NODEBB_PWD="$(openssl rand -base64 18 | cut -c1-13)"
 | 
			
		||||
MONGO_CONNECTION_STRING="mongodb://${NODEBB_USER}:${NODEBB_PWD}@localhost:27017/nodebb"
 | 
			
		||||
NODEBB_SECRET=$(uuidgen)
 | 
			
		||||
{
 | 
			
		||||
    echo "NodeBB-Credentials"
 | 
			
		||||
    echo "Mongo Database User: $MONGO_ADMIN_USER"
 | 
			
		||||
    echo "Mongo Database Password: $MONGO_ADMIN_PWD"
 | 
			
		||||
    echo "NodeBB User: $NODEBB_USER"
 | 
			
		||||
	echo "NodeBB Password: $NODEBB_PWD"
 | 
			
		||||
	echo "NodeBB Secret: $NODEBB_SECRET"
 | 
			
		||||
} >> ~/nodebb.creds
 | 
			
		||||
 | 
			
		||||
$STD mongosh <<EOF
 | 
			
		||||
use admin
 | 
			
		||||
db.createUser({
 | 
			
		||||
  user: "$MONGO_ADMIN_USER",
 | 
			
		||||
  pwd: "$MONGO_ADMIN_PWD",
 | 
			
		||||
  roles: [{ role: "root", db: "admin" }]
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
use nodebb
 | 
			
		||||
db.createUser({
 | 
			
		||||
  user: "$NODEBB_USER",
 | 
			
		||||
  pwd: "$NODEBB_PWD",
 | 
			
		||||
  roles: [
 | 
			
		||||
    { role: "readWrite", db: "nodebb" },
 | 
			
		||||
    { role: "clusterMonitor", db: "admin" }
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
quit()
 | 
			
		||||
EOF
 | 
			
		||||
sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf
 | 
			
		||||
sed -i '/security:/d' /etc/mongod.conf
 | 
			
		||||
bash -c 'echo -e "\nsecurity:\n  authorization: enabled" >> /etc/mongod.conf'
 | 
			
		||||
systemctl restart mongod
 | 
			
		||||
msg_ok "MongoDB successfully configurated" 
 | 
			
		||||
 | 
			
		||||
msg_info "Install NodeBB" 
 | 
			
		||||
cd /opt
 | 
			
		||||
RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
			
		||||
wget -q "https://github.com/NodeBB/NodeBB/archive/refs/tags/v${RELEASE}.zip"
 | 
			
		||||
unzip -q v${RELEASE}.zip
 | 
			
		||||
mv NodeBB-${RELEASE} /opt/nodebb
 | 
			
		||||
cd /opt/nodebb
 | 
			
		||||
touch pidfile
 | 
			
		||||
expect <<EOF > /dev/null 2>&1
 | 
			
		||||
log_file /dev/null
 | 
			
		||||
set timeout -1
 | 
			
		||||
 | 
			
		||||
spawn ./nodebb setup
 | 
			
		||||
expect "URL used to access this NodeBB" {
 | 
			
		||||
    send "http://localhost:4567\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Please enter a NodeBB secret" {
 | 
			
		||||
    send "$NODEBB_SECRET\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Would you like to submit anonymous plugin usage to nbbpm? (yes)" {
 | 
			
		||||
    send "no\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Which database to use (mongo)" {
 | 
			
		||||
    send "mongo\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Format: mongodb://*" {
 | 
			
		||||
    send "$MONGO_CONNECTION_STRING\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Administrator username" {
 | 
			
		||||
    send "helper-scripts\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Administrator email address" {
 | 
			
		||||
    send "helper-scripts@local.com\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Password" {
 | 
			
		||||
    send "helper-scripts\r"
 | 
			
		||||
}
 | 
			
		||||
expect "Confirm Password" {
 | 
			
		||||
    send "helper-scripts\r"
 | 
			
		||||
}
 | 
			
		||||
expect eof
 | 
			
		||||
EOF
 | 
			
		||||
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
 | 
			
		||||
msg_ok "Installed NodeBB"
 | 
			
		||||
 | 
			
		||||
msg_info "Creating Services"
 | 
			
		||||
cat <<EOF >/etc/systemd/system/nodebb.service
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=NodeBB
 | 
			
		||||
Documentation=https://docs.nodebb.org
 | 
			
		||||
After=system.slice multi-user.target mongod.service
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=forking
 | 
			
		||||
User=root
 | 
			
		||||
 | 
			
		||||
WorkingDirectory=/opt/nodebb
 | 
			
		||||
PIDFile=/opt/nodebb/pidfile
 | 
			
		||||
ExecStart=/usr/bin/node /opt/nodebb/loader.js
 | 
			
		||||
Restart=always
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
EOF
 | 
			
		||||
systemctl enable -q --now nodebb
 | 
			
		||||
msg_ok "Created Service"
 | 
			
		||||
 | 
			
		||||
motd_ssh
 | 
			
		||||
customize
 | 
			
		||||
 | 
			
		||||
msg_info "Cleaning up"
 | 
			
		||||
rm -R /opt/v${RELEASE}.zip
 | 
			
		||||
$STD apt-get -y autoremove
 | 
			
		||||
$STD apt-get -y autoclean
 | 
			
		||||
msg_ok "Cleaned"
 | 
			
		||||
							
								
								
									
										40
									
								
								json/nodebb.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								json/nodebb.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "NodeBB",
 | 
			
		||||
  "slug": "nodebb",
 | 
			
		||||
  "categories": [
 | 
			
		||||
    10,
 | 
			
		||||
    25
 | 
			
		||||
  ],
 | 
			
		||||
  "date_created": "2025-01-28",
 | 
			
		||||
  "type": "ct",
 | 
			
		||||
  "updateable": true,
 | 
			
		||||
  "privileged": false,
 | 
			
		||||
  "interface_port": 4567,
 | 
			
		||||
  "documentation": "https://docs.nodebb.org/",
 | 
			
		||||
  "website": "https://nodebb.org/",
 | 
			
		||||
  "logo": "https://raw.githubusercontent.com/NodeBB/NodeBB/refs/heads/master/public/logo.png",
 | 
			
		||||
  "description": "NodeBB Forum Software is powered by Node.js and supports either Redis, MongoDB, or a PostgreSQL database. It utilizes web sockets for instant interactions and real-time notifications. NodeBB takes the best of the modern web: real-time streaming discussions, mobile responsiveness, and rich RESTful read/write APIs, while staying true to the original bulletin board/forum format → categorical hierarchies, local user accounts, and asynchronous messaging.",
 | 
			
		||||
  "install_methods": [
 | 
			
		||||
    {
 | 
			
		||||
      "type": "default",
 | 
			
		||||
      "script": "ct/nodebb.sh",
 | 
			
		||||
      "resources": {
 | 
			
		||||
        "cpu": 4,
 | 
			
		||||
        "ram": 2048,
 | 
			
		||||
        "hdd": 10,
 | 
			
		||||
        "os": "Ubuntu",
 | 
			
		||||
        "version": "24.04"
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "default_credentials": {
 | 
			
		||||
    "username": "helper-scripts",
 | 
			
		||||
    "password": "helper-scripts"
 | 
			
		||||
  },
 | 
			
		||||
  "notes": [
 | 
			
		||||
    {
 | 
			
		||||
      "text": "Only use Ubuntu 24.04!",
 | 
			
		||||
      "type": "warning"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user