Skip to content

Commit c7fffd8

Browse files
committed
Expand MongoDB setup to support Ubuntu and update repo handling
Extended the MongoDB setup function to handle both Debian and Ubuntu distributions, mapping their codenames to supported MongoDB suites. Updated the GPG key URL and output path, and adjusted the repository source file structure to match MongoDB's nested layout.
1 parent 2ae6205 commit c7fffd8

File tree

1 file changed

+49
-26
lines changed

1 file changed

+49
-26
lines changed

misc/tools.func

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,28 +2382,51 @@ function setup_mongodb() {
23822382
cleanup_old_repo_files "mongodb-org-${MONGO_VERSION}"
23832383
cleanup_orphaned_sources
23842384

2385-
# Map Debian codenames to MongoDB-supported suites
2385+
# Map distro codenames to MongoDB-supported suites
23862386
local SUITE
2387-
case "$DISTRO_CODENAME" in
2388-
trixie | forky | sid)
2389-
# Debian 13+ and testing/unstable use Bookworm (MongoDB doesn't support newer)
2390-
SUITE="bookworm"
2391-
;;
2392-
bookworm)
2393-
SUITE="bookworm"
2394-
;;
2395-
bullseye)
2396-
SUITE="bullseye"
2397-
;;
2398-
buster)
2399-
SUITE="buster"
2400-
;;
2401-
*)
2402-
# Fallback: try bookworm for unknown releases
2403-
msg_warn "Unknown Debian release '${DISTRO_CODENAME}', using bookworm"
2404-
SUITE="bookworm"
2405-
;;
2406-
esac
2387+
if [[ "$DISTRO_ID" == "debian" ]]; then
2388+
case "$DISTRO_CODENAME" in
2389+
trixie | forky | sid)
2390+
# Debian 13+ and testing/unstable use Bookworm (MongoDB doesn't support newer)
2391+
SUITE="bookworm"
2392+
;;
2393+
bookworm)
2394+
SUITE="bookworm"
2395+
;;
2396+
bullseye)
2397+
SUITE="bullseye"
2398+
;;
2399+
buster)
2400+
SUITE="buster"
2401+
;;
2402+
*)
2403+
# Fallback: try bookworm for unknown Debian releases
2404+
msg_warn "Unknown Debian release '${DISTRO_CODENAME}', using bookworm"
2405+
SUITE="bookworm"
2406+
;;
2407+
esac
2408+
elif [[ "$DISTRO_ID" == "ubuntu" ]]; then
2409+
case "$DISTRO_CODENAME" in
2410+
oracular | plucky)
2411+
# Ubuntu 24.10+ uses noble
2412+
SUITE="noble"
2413+
;;
2414+
noble)
2415+
SUITE="noble"
2416+
;;
2417+
jammy)
2418+
SUITE="jammy"
2419+
;;
2420+
focal)
2421+
SUITE="focal"
2422+
;;
2423+
*)
2424+
# Fallback: try noble for unknown Ubuntu releases
2425+
msg_warn "Unknown Ubuntu release '${DISTRO_CODENAME}', using noble"
2426+
SUITE="noble"
2427+
;;
2428+
esac
2429+
fi
24072430

24082431
# Verify MongoDB repository is available (MongoDB has nested structure)
24092432
if ! curl -fsSL --max-time 10 "${MONGO_BASE_URL}/dists/${SUITE}/mongodb-org/${MONGO_VERSION}/Release" &>/dev/null; then
@@ -2413,19 +2436,19 @@ function setup_mongodb() {
24132436
fi
24142437

24152438
mkdir -p /etc/apt/keyrings
2416-
if ! curl -fsSL "https://pgp.mongodb.com/server-${MONGO_VERSION}.asc" |
2417-
gpg --dearmor --yes -o "/etc/apt/keyrings/mongodb-${MONGO_VERSION}.gpg"; then
2439+
if ! curl -fsSL "https://www.mongodb.org/static/pgp/server-${MONGO_VERSION}.asc" |
2440+
gpg --dearmor --yes -o "/etc/apt/keyrings/mongodb-server-${MONGO_VERSION}.gpg"; then
24182441
msg_error "Failed to download or import MongoDB GPG key"
24192442
return 1
24202443
fi
24212444

24222445
cat <<EOF >/etc/apt/sources.list.d/mongodb-org-${MONGO_VERSION}.sources
24232446
Types: deb
24242447
URIs: ${MONGO_BASE_URL}
2425-
Suites: ${SUITE}
2426-
Components: mongodb-org/${MONGO_VERSION}
2448+
Suites: ${SUITE}/mongodb-org/${MONGO_VERSION}
2449+
Components: ${REPO_COMPONENT}
24272450
Architectures: amd64 arm64
2428-
Signed-By: /etc/apt/keyrings/mongodb-${MONGO_VERSION}.gpg
2451+
Signed-By: /etc/apt/keyrings/mongodb-server-${MONGO_VERSION}.gpg
24292452
EOF
24302453

24312454
$STD apt update || {

0 commit comments

Comments
 (0)