Skip to content

Commit 67d8bc2

Browse files
authored
Refactor MongoDB install script to use setup_mongodb (#8897)
Replaces inline MongoDB installation logic with a call to setup_mongodb, passing the selected version via MONGO_VERSION. Updates messaging to use the new variable and removes redundant code.
1 parent cc16f4b commit 67d8bc2

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

install/mongodb-install.sh

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,12 @@ update_os
1515

1616
read -p "${TAB3}Do you want to install MongoDB 8.0 instead of 7.0? [y/N]: " install_mongodb_8
1717
if [[ "$install_mongodb_8" =~ ^[Yy]$ ]]; then
18-
MONGODB_VERSION="8.0"
18+
MONGO_VERSION="8.0" setup_mongodb
1919
else
20-
MONGODB_VERSION="7.0"
20+
MONGO_VERSION="7.0" setup_mongodb
2121
fi
22-
23-
msg_info "Installing MongoDB $MONGODB_VERSION"
24-
curl -fsSL "https://www.mongodb.org/static/pgp/server-${MONGODB_VERSION}.asc" | gpg --dearmor >/usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg
25-
cat <<EOF >/etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.sources
26-
Types: deb
27-
URIs: http://repo.mongodb.org/apt/debian
28-
Suites: $(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/${MONGODB_VERSION}
29-
Components: main
30-
Signed-By: /usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg
31-
EOF
32-
$STD apt update
33-
$STD apt install -y mongodb-org
3422
sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf
35-
systemctl enable -q --now mongod
36-
msg_ok "Installed MongoDB $MONGODB_VERSION"
23+
msg_ok "Installed MongoDB $MONGO_VERSION"
3724

3825
motd_ssh
3926
customize

0 commit comments

Comments
 (0)