fix(databasus): use get_system_arch and dynamic MongoDB version

- Replace manual dpkg arch detection with get_system_arch helper
- Fetch latest mongodb-database-tools version from GitHub API
  instead of hardcoding 100.10.0
- Fallback to 100.10.0 if API call fails
This commit is contained in:
CanbiZ (MickLesk)
2026-02-24 09:16:00 +01:00
parent a9fe74efaf
commit e6dd3c1457
2 changed files with 8 additions and 19 deletions

View File

@@ -41,16 +41,11 @@ function update_script() {
msg_info "Ensuring Database Clients"
ensure_dependencies mariadb-client
if ! command -v mongodump &>/dev/null; then
DEBIAN_ARCH=$(dpkg --print-architecture)
if [[ "$DEBIAN_ARCH" == "amd64" ]]; then
MONGO_ARCH="x86_64"
MONGO_DIST="debian12"
elif [[ "$DEBIAN_ARCH" == "arm64" ]]; then
MONGO_ARCH="arm64"
MONGO_DIST="ubuntu2204"
fi
MONGO_ARCH=$(get_system_arch uname)
MONGO_DIST=$([[ "$(get_system_arch)" == "amd64" ]] && echo "debian12" || echo "ubuntu2204")
MONGO_VERSION=$(curl -fsSL https://api.github.com/repos/mongodb/mongo-tools/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' || echo "100.10.0")
tmp_file=$(mktemp)
wget -q "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-${MONGO_DIST}-${MONGO_ARCH}-100.10.0.deb" -O "$tmp_file"
wget -q "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-${MONGO_DIST}-${MONGO_ARCH}-${MONGO_VERSION}.deb" -O "$tmp_file"
$STD dpkg -i "$tmp_file" || $STD apt-get install -f -y --no-install-recommends
rm -f "$tmp_file"
fi

View File

@@ -25,17 +25,11 @@ setup_go
NODE_VERSION="24" setup_nodejs
msg_info "Installing Database Clients"
$STD apt install -y
DEBIAN_ARCH=$(dpkg --print-architecture)
if [[ "$DEBIAN_ARCH" == "amd64" ]]; then
MONGO_ARCH="x86_64"
MONGO_DIST="debian12"
elif [[ "$DEBIAN_ARCH" == "arm64" ]]; then
MONGO_ARCH="arm64"
MONGO_DIST="ubuntu2204"
fi
MONGO_ARCH=$(get_system_arch uname)
MONGO_DIST=$([[ "$(get_system_arch)" == "amd64" ]] && echo "debian12" || echo "ubuntu2204")
MONGO_VERSION=$(curl -fsSL https://api.github.com/repos/mongodb/mongo-tools/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' || echo "100.10.0")
tmp_file=$(mktemp)
wget -q "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-${MONGO_DIST}-${MONGO_ARCH}-100.10.0.deb" -O "$tmp_file"
wget -q "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-${MONGO_DIST}-${MONGO_ARCH}-${MONGO_VERSION}.deb" -O "$tmp_file"
$STD dpkg -i "$tmp_file" || $STD apt-get install -f -y --no-install-recommends
rm -f "$tmp_file"
mkdir -p /usr/local/mariadb-{10.6,12.1}/bin /usr/local/mysql-{5.7,8.0,8.4,9}/bin /usr/local/mongodb-database-tools/bin