Skip to content

Commit da217bb

Browse files
authored
Refactor: NodeBB (#6419)
1 parent f80c700 commit da217bb

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

ct/nodebb.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,22 @@ function update_script() {
3232
fi
3333

3434
RELEASE=$(curl -fsSL 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
35+
if [[ "${RELEASE}" != "$(cat ~/.nodebb)" ]] || [[ ! -f ~/.nodebb ]]; then
3636
msg_info "Stopping ${APP}"
3737
systemctl stop nodebb
3838
msg_ok "Stopped ${APP}"
3939

4040
msg_info "Updating ${APP} to v${RELEASE}"
4141
cd /opt/nodebb
4242
$STD ./nodebb upgrade
43-
echo "${RELEASE}" >/opt/${APP}_version.txt
43+
echo "${RELEASE}" > ~/.nodebb
4444
msg_ok "Updated ${APP} to v${RELEASE}"
4545

4646
msg_info "Starting ${APP}"
4747
systemctl start nodebb
4848
msg_ok "Started ${APP}"
49-
msg_ok "Updated Successfully"
49+
50+
msg_ok "Updated Successfully\n"
5051
else
5152
msg_ok "No update required. ${APP} is already at v${RELEASE}."
5253
fi
@@ -60,4 +61,4 @@ description
6061
msg_ok "Completed Successfully!\n"
6162
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
6263
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
63-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4567${CL}"
64+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4567${CL}"

install/nodebb-install.sh

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ msg_ok "Installed Dependencies"
2424
setup_mongodb
2525
NODE_VERSION="22" setup_nodejs
2626

27-
msg_info "Configure MongoDB"
27+
msg_info "Configuring MongoDB"
2828
MONGO_ADMIN_USER="admin"
2929
MONGO_ADMIN_PWD="$(openssl rand -base64 18 | cut -c1-13)"
3030
NODEBB_USER="nodebb"
@@ -63,14 +63,11 @@ sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf
6363
sed -i '/security:/d' /etc/mongod.conf
6464
bash -c 'echo -e "\nsecurity:\n authorization: enabled" >> /etc/mongod.conf'
6565
systemctl restart mongod
66-
msg_ok "MongoDB successfully configurated"
67-
68-
msg_info "Install NodeBB"
69-
cd /opt
70-
RELEASE=$(curl -fsSL https://api.github.com/repos/NodeBB/NodeBB/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
71-
curl -fsSL "https://github.com/NodeBB/NodeBB/archive/refs/tags/v${RELEASE}.zip" -o "/opt/v${RELEASE}.zip"
72-
$STD unzip v${RELEASE}.zip
73-
mv NodeBB-${RELEASE} /opt/nodebb
66+
msg_ok "MongoDB configured"
67+
68+
fetch_and_deploy_gh_release "nodebb" "NodeBB/NodeBB" "tarball"
69+
70+
msg_info "Configuring NodeBB"
7471
cd /opt/nodebb
7572
touch pidfile
7673
expect <<EOF >/dev/null 2>&1
@@ -107,8 +104,7 @@ expect "Confirm Password" {
107104
}
108105
expect eof
109106
EOF
110-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
111-
msg_ok "Installed NodeBB"
107+
msg_ok "Configured NodeBB"
112108

113109
msg_info "Creating Services"
114110
cat <<EOF >/etc/systemd/system/nodebb.service
@@ -136,7 +132,6 @@ motd_ssh
136132
customize
137133

138134
msg_info "Cleaning up"
139-
rm -R /opt/v${RELEASE}.zip
140135
$STD apt-get -y autoremove
141136
$STD apt-get -y autoclean
142137
msg_ok "Cleaned"

0 commit comments

Comments
 (0)