Compare commits

..

2 Commits

Author SHA1 Message Date
CanbiZ
876affb09f Refactor MongoDB install script to use setup_mongodb
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.
2025-11-06 08:52:31 +01:00
CanbiZ
cc16f4bb94 Add explicit suite mapping for Debian and Ubuntu
Introduces explicit mapping of distro codenames to repository suites for Debian and Ubuntu, with fallbacks for newer or unknown releases. This ensures proper repository setup even when upstream does not yet support the latest distributions.
2025-11-06 07:57:30 +01:00
2 changed files with 48 additions and 17 deletions

View File

@@ -15,25 +15,12 @@ update_os
read -p "${TAB3}Do you want to install MongoDB 8.0 instead of 7.0? [y/N]: " install_mongodb_8
if [[ "$install_mongodb_8" =~ ^[Yy]$ ]]; then
MONGODB_VERSION="8.0"
MONGO_VERSION="8.0" setup_mongodb
else
MONGODB_VERSION="7.0"
MONGO_VERSION="7.0" setup_mongodb
fi
msg_info "Installing MongoDB $MONGODB_VERSION"
curl -fsSL "https://www.mongodb.org/static/pgp/server-${MONGODB_VERSION}.asc" | gpg --dearmor >/usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg
cat <<EOF >/etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.sources
Types: deb
URIs: http://repo.mongodb.org/apt/debian
Suites: $(grep '^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2)/mongodb-org/${MONGODB_VERSION}
Components: main
Signed-By: /usr/share/keyrings/mongodb-server-${MONGODB_VERSION}.gpg
EOF
$STD apt update
$STD apt install -y mongodb-org
sed -i 's/bindIp: 127.0.0.1/bindIp: 0.0.0.0/' /etc/mongod.conf
systemctl enable -q --now mongod
msg_ok "Installed MongoDB $MONGODB_VERSION"
msg_ok "Installed MongoDB $MONGO_VERSION"
motd_ssh
customize

View File

@@ -450,7 +450,51 @@ manage_tool_repository() {
# Setup repository
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
suite=$(get_fallback_suite "$distro_id" "$distro_codename" "$repo_url")
# Suite mapping with fallback for newer releases not yet supported by upstream
if [[ "$distro_id" == "debian" ]]; then
case "$distro_codename" in
trixie | forky | sid)
# Testing/unstable releases fallback to latest stable suite
suite="bookworm"
;;
bookworm)
suite="bookworm"
;;
bullseye)
suite="bullseye"
;;
*)
# Unknown release: fallback to latest stable suite
msg_warn "Unknown Debian release '${distro_codename}', using bookworm"
suite="bookworm"
;;
esac
elif [[ "$distro_id" == "ubuntu" ]]; then
case "$distro_codename" in
oracular | plucky)
# Newer releases fallback to latest LTS
suite="noble"
;;
noble)
suite="noble"
;;
jammy)
suite="jammy"
;;
focal)
suite="focal"
;;
*)
# Unknown release: fallback to latest LTS
msg_warn "Unknown Ubuntu release '${distro_codename}', using noble"
suite="noble"
;;
esac
else
# For other distros, try generic fallback
suite=$(get_fallback_suite "$distro_id" "$distro_codename" "$repo_url")
fi
repo_component="main"
[[ "$distro_id" == "ubuntu" ]] && repo_component="multiverse"