Skip to content

Commit 3be6824

Browse files
authored
New Script: NodeBB (#1811)
1 parent f903cfd commit 3be6824

File tree

3 files changed

+267
-0
lines changed

3 files changed

+267
-0
lines changed

ct/nodebb.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (Canbiz)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
7+
# App Default Values
8+
APP="NodeBB"
9+
var_tags="forum"
10+
var_disk="10"
11+
var_cpu="4"
12+
var_ram="2048"
13+
var_os="ubuntu"
14+
var_version="24.04"
15+
var_unprivileged="1"
16+
17+
# App Output & Base Settings
18+
header_info "$APP"
19+
20+
# Core
21+
variables
22+
color
23+
catch_errors
24+
25+
function update_script() {
26+
header_info
27+
check_container_storage
28+
check_container_resources
29+
if [[ ! -d /opt/nodebb ]]; then
30+
msg_error "No ${APP} Installation Found!"
31+
exit
32+
fi
33+
34+
RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
35+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
36+
msg_info "Stopping ${APP}"
37+
systemctl stop nodebb
38+
msg_ok "Stopped ${APP}"
39+
40+
msg_info "Updating ${APP} to v${RELEASE}"
41+
cd /opt/nodebb
42+
./nodebb upgrade >/dev/null 2>&1
43+
echo "${RELEASE}" >/opt/${APP}_version.txt
44+
msg_ok "Updated ${APP} to v${RELEASE}"
45+
46+
msg_info "Starting ${APP}"
47+
systemctl start nodebb
48+
msg_ok "Started ${APP}"
49+
msg_ok "Updated Successfully"
50+
else
51+
msg_ok "No update required. ${APP} is already at v${RELEASE}."
52+
fi
53+
exit
54+
}
55+
56+
start
57+
build_container
58+
description
59+
60+
msg_ok "Completed Successfully!\n"
61+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
62+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
63+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4567${CL}"

install/nodebb-install.sh

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2024 tteck
4+
# Author: MickLesk (Canbiz)
5+
# License: MIT | https://github.com/tteck/Proxmox/raw/main/LICENSE
6+
# Source: https://github.com/NodeBB/NodeBB
7+
8+
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies (Patience)"
17+
$STD apt-get install -y \
18+
build-essential \
19+
curl \
20+
sudo \
21+
make \
22+
redis-server \
23+
expect \
24+
gnupg \
25+
ca-certificates \
26+
mc
27+
msg_ok "Installed Dependencies"
28+
29+
msg_info "Setting up Node.js & MongoDB Repository"
30+
mkdir -p /etc/apt/keyrings
31+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
32+
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
33+
34+
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | gpg --dearmor -o /etc/apt/keyrings/mongodb-server-8.0.gpg
35+
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
36+
$STD apt-get update
37+
msg_ok "Set up Repositories"
38+
39+
msg_info "Installing Node.js"
40+
$STD apt-get install -y nodejs
41+
msg_ok "Installed Node.js"
42+
43+
msg_info "Installing MongoDB"
44+
$STD apt-get install -y mongodb-org
45+
systemctl enable -q --now mongod
46+
sleep 10 # MongoDB needs some secounds to start, if not sleep it collide with following mongosh
47+
msg_ok "Installed MongoDB"
48+
49+
msg_info "Configure MongoDB"
50+
MONGO_ADMIN_USER="admin"
51+
MONGO_ADMIN_PWD="$(openssl rand -base64 18 | cut -c1-13)"
52+
NODEBB_USER="nodebb"
53+
NODEBB_PWD="$(openssl rand -base64 18 | cut -c1-13)"
54+
MONGO_CONNECTION_STRING="mongodb://${NODEBB_USER}:${NODEBB_PWD}@localhost:27017/nodebb"
55+
NODEBB_SECRET=$(uuidgen)
56+
{
57+
echo "NodeBB-Credentials"
58+
echo "Mongo Database User: $MONGO_ADMIN_USER"
59+
echo "Mongo Database Password: $MONGO_ADMIN_PWD"
60+
echo "NodeBB User: $NODEBB_USER"
61+
echo "NodeBB Password: $NODEBB_PWD"
62+
echo "NodeBB Secret: $NODEBB_SECRET"
63+
} >> ~/nodebb.creds
64+
65+
$STD mongosh <<EOF
66+
use admin
67+
db.createUser({
68+
user: "$MONGO_ADMIN_USER",
69+
pwd: "$MONGO_ADMIN_PWD",
70+
roles: [{ role: "root", db: "admin" }]
71+
})
72+
73+
use nodebb
74+
db.createUser({
75+
user: "$NODEBB_USER",
76+
pwd: "$NODEBB_PWD",
77+
roles: [
78+
{ role: "readWrite", db: "nodebb" },
79+
{ role: "clusterMonitor", db: "admin" }
80+
]
81+
})
82+
quit()
83+
EOF
84+
sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf
85+
sed -i '/security:/d' /etc/mongod.conf
86+
bash -c 'echo -e "\nsecurity:\n authorization: enabled" >> /etc/mongod.conf'
87+
systemctl restart mongod
88+
msg_ok "MongoDB successfully configurated"
89+
90+
msg_info "Install NodeBB"
91+
cd /opt
92+
RELEASE=$(curl -s https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
93+
wget -q "https://github.com/NodeBB/NodeBB/archive/refs/tags/v${RELEASE}.zip"
94+
unzip -q v${RELEASE}.zip
95+
mv NodeBB-${RELEASE} /opt/nodebb
96+
cd /opt/nodebb
97+
touch pidfile
98+
expect <<EOF > /dev/null 2>&1
99+
log_file /dev/null
100+
set timeout -1
101+
102+
spawn ./nodebb setup
103+
expect "URL used to access this NodeBB" {
104+
send "http://localhost:4567\r"
105+
}
106+
expect "Please enter a NodeBB secret" {
107+
send "$NODEBB_SECRET\r"
108+
}
109+
expect "Would you like to submit anonymous plugin usage to nbbpm? (yes)" {
110+
send "no\r"
111+
}
112+
expect "Which database to use (mongo)" {
113+
send "mongo\r"
114+
}
115+
expect "Format: mongodb://*" {
116+
send "$MONGO_CONNECTION_STRING\r"
117+
}
118+
expect "Administrator username" {
119+
send "helper-scripts\r"
120+
}
121+
expect "Administrator email address" {
122+
123+
}
124+
expect "Password" {
125+
send "helper-scripts\r"
126+
}
127+
expect "Confirm Password" {
128+
send "helper-scripts\r"
129+
}
130+
expect eof
131+
EOF
132+
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
133+
msg_ok "Installed NodeBB"
134+
135+
msg_info "Creating Services"
136+
cat <<EOF >/etc/systemd/system/nodebb.service
137+
[Unit]
138+
Description=NodeBB
139+
Documentation=https://docs.nodebb.org
140+
After=system.slice multi-user.target mongod.service
141+
142+
[Service]
143+
Type=forking
144+
User=root
145+
146+
WorkingDirectory=/opt/nodebb
147+
PIDFile=/opt/nodebb/pidfile
148+
ExecStart=/usr/bin/node /opt/nodebb/loader.js
149+
Restart=always
150+
151+
[Install]
152+
WantedBy=multi-user.target
153+
EOF
154+
systemctl enable -q --now nodebb
155+
msg_ok "Created Service"
156+
157+
motd_ssh
158+
customize
159+
160+
msg_info "Cleaning up"
161+
rm -R /opt/v${RELEASE}.zip
162+
$STD apt-get -y autoremove
163+
$STD apt-get -y autoclean
164+
msg_ok "Cleaned"

json/nodebb.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "NodeBB",
3+
"slug": "nodebb",
4+
"categories": [
5+
10,
6+
25
7+
],
8+
"date_created": "2025-01-28",
9+
"type": "ct",
10+
"updateable": true,
11+
"privileged": false,
12+
"interface_port": 4567,
13+
"documentation": "https://docs.nodebb.org/",
14+
"website": "https://nodebb.org/",
15+
"logo": "https://raw.githubusercontent.com/NodeBB/NodeBB/refs/heads/master/public/logo.png",
16+
"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.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/nodebb.sh",
21+
"resources": {
22+
"cpu": 4,
23+
"ram": 2048,
24+
"hdd": 10,
25+
"os": "Ubuntu",
26+
"version": "24.04"
27+
}
28+
}
29+
],
30+
"default_credentials": {
31+
"username": "helper-scripts",
32+
"password": "helper-scripts"
33+
},
34+
"notes": [
35+
{
36+
"text": "Only use Ubuntu 24.04!",
37+
"type": "warning"
38+
}
39+
]
40+
}

0 commit comments

Comments
 (0)