From 1eb76f2b9025d826e18fce5cfae16a13304a5425 Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 13:56:40 +0800 Subject: [PATCH 01/13] update --- plugins/mongodb/info.json | 2 +- plugins/mongodb/versions/3.0/centos.sh | 110 +++++++++++++++++++++++ plugins/mongodb/versions/3.0/debian.sh | 88 ++++++++++++++++++ plugins/mongodb/versions/3.0/macos.sh | 76 ++++++++++++++++ plugins/mongodb/versions/3.0/opensuse.sh | 92 +++++++++++++++++++ plugins/mongodb/versions/3.0/rhel.sh | 63 +++++++++++++ plugins/mongodb/versions/3.0/ubuntu.sh | 89 ++++++++++++++++++ 7 files changed, 519 insertions(+), 1 deletion(-) create mode 100644 plugins/mongodb/versions/3.0/centos.sh create mode 100644 plugins/mongodb/versions/3.0/debian.sh create mode 100644 plugins/mongodb/versions/3.0/macos.sh create mode 100644 plugins/mongodb/versions/3.0/opensuse.sh create mode 100644 plugins/mongodb/versions/3.0/rhel.sh create mode 100644 plugins/mongodb/versions/3.0/ubuntu.sh diff --git a/plugins/mongodb/info.json b/plugins/mongodb/info.json index f42160c5e..0c6d350ca 100755 --- a/plugins/mongodb/info.json +++ b/plugins/mongodb/info.json @@ -7,7 +7,7 @@ "shell": "install.sh", "install_pre_inspection":true, "uninstall_pre_inspection":true, - "versions":["4.4","5.0","6.0","7.0","8.0","8.2"], + "versions":["3.0","4.4","5.0","6.0","7.0","8.0","8.2"], "tip": "soft", "checks": "server/mongodb", "path": "server/mongodb", diff --git a/plugins/mongodb/versions/3.0/centos.sh b/plugins/mongodb/versions/3.0/centos.sh new file mode 100644 index 000000000..3c10f1a0a --- /dev/null +++ b/plugins/mongodb/versions/3.0/centos.sh @@ -0,0 +1,110 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 +SYS_ARCH=`arch` + +SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +SYS_NAME=${SYS_VERSION_ID/./} +SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L` + +if [ "$SYS_NAME_LEN" == "1" ];then + SYS_NAME=${SYS_NAME}0 +fi + +if [ "$SYS_ARCH" == "aarch64" ];then + if [ "$SYS_NAME" -gt "82" ];then + SYS_NAME="82" + fi + + if [ "$SYS_NAME" -lt "62" ];then + SYS_NAME="62" + fi +else + + if [ "$SYS_NAME" -gt "80" ];then + SYS_NAME="80" + fi + + if [ "$SYS_NAME" -lt "70" ];then + SYS_NAME="70" + fi +fi + + +# https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.23.tgz +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.23.tgz +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.23.tgz +# https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.23.tgz +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.23.tgz + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +FILE_NAME=mongodb-linux-${SYS_ARCH}-rhel${SYS_NAME}-${VERSION} +FILE_NAME_TGZ=${FILE_NAME}.tgz + +if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${FILE_NAME} ];then + cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ} +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb +fi + +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} + +#--------------- mongodb database install ------------------ # +TOOL_VERSION=100.9.4 +TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION} +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION} +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} diff --git a/plugins/mongodb/versions/3.0/debian.sh b/plugins/mongodb/versions/3.0/debian.sh new file mode 100644 index 000000000..24008b150 --- /dev/null +++ b/plugins/mongodb/versions/3.0/debian.sh @@ -0,0 +1,88 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 +SYS_ARCH=`arch` +SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +SYS_NAME=${SYS_VERSION_ID/./} + +if [ "$SYS_NAME" -gt "10" ];then + SYS_NAME="10" +fi + +if [ "$SYS_NAME" -lt "10" ];then + SYS_NAME="10" +fi + +FILE_NAME=mongodb-linux-${SYS_ARCH}-debian${SYS_NAME}-${VERSION} +FILE_NAME_TGZ=${FILE_NAME}.tgz + + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ} +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb +fi + +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} + + +#--------------- mongodb database install ------------------ # +TOOL_VERSION=100.9.4 +TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION} +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} diff --git a/plugins/mongodb/versions/3.0/macos.sh b/plugins/mongodb/versions/3.0/macos.sh new file mode 100644 index 000000000..153b9390b --- /dev/null +++ b/plugins/mongodb/versions/3.0/macos.sh @@ -0,0 +1,76 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +if [ ! -f $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz ]; then + wget --no-check-certificate -O $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz + echo "wget --no-check-certificate -O $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz" +fi + +if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then + cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb +fi + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64 +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} + +#--------------- mongodb-database-tools ------------------ # +# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip +TOOL_VERSION=100.9.4 +TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION} +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION} +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION} +fi + +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/opensuse.sh b/plugins/mongodb/versions/3.0/opensuse.sh new file mode 100644 index 000000000..64ffcac37 --- /dev/null +++ b/plugins/mongodb/versions/3.0/opensuse.sh @@ -0,0 +1,92 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 +SYS_ARCH=`arch` + +SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'` + +SYS_NAME="15" +if [ "$SYS_VERSION_ID" -gt "15" ];then + SYS_NAME="15" +fi + +if [ "$SYS_NAME" -lt "12" ];then + SYS_NAME="12" +fi + +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse15-4.4.23.tgz +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse12-4.4.23.tgz + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +FILE_NAME=mongodb-linux-${SYS_ARCH}-suse${SYS_NAME}-${VERSION} +FILE_NAME_TGZ=${FILE_NAME}.tgz + +if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${FILE_NAME} ];then + cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ} +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb +fi + +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} + + +# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz +#--------------- mongodb database install ------------------ # +TOOL_VERSION=100.9.4 +TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION} +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/rhel.sh b/plugins/mongodb/versions/3.0/rhel.sh new file mode 100644 index 000000000..1f8210b22 --- /dev/null +++ b/plugins/mongodb/versions/3.0/rhel.sh @@ -0,0 +1,63 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 +SYS_ARCH=`arch` + +SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +SYS_NAME=${SYS_VERSION_ID/./} +SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L` + +if [ "$SYS_NAME_LEN" == "1" ];then + SYS_NAME=${SYS_NAME}0 +fi + +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.23.tgz + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +FILE_NAME=mongodb-linux-${SYS_ARCH}-ubuntu${SYS_NAME}-${VERSION} +FILE_NAME_TGZ=${FILE_NAME}.tgz + +if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${FILE_NAME} ];then + cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ} +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb +fi + +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/ubuntu.sh b/plugins/mongodb/versions/3.0/ubuntu.sh new file mode 100644 index 000000000..5eac1b70f --- /dev/null +++ b/plugins/mongodb/versions/3.0/ubuntu.sh @@ -0,0 +1,89 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=3.0.1 +SYS_ARCH=`arch` + +SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +SYS_NAME=${SYS_VERSION_ID/./} +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz + +if [ "$SYS_NAME" -gt "2004" ];then + SYS_NAME="2004" +fi + +if [ "$SYS_NAME" -lt "1604" ];then + SYS_NAME="1604" +fi + +MG_DIR=$serverPath/source/mongodb +mkdir -p $MG_DIR + +FILE_NAME=mongodb-linux-${SYS_ARCH}-ubuntu${SYS_NAME}-${VERSION} +FILE_NAME_TGZ=${FILE_NAME}.tgz + +if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${FILE_NAME} ];then + cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ} +fi + +if [ ! -d $serverPath/mongodb/bin ];then + mkdir -p $serverPath/mongodb + cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb +fi + +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} + +#--------------- mongosh tool install ------------------ # +TOOL_VERSION=2.2.5 +TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 +fi +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} + echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} + +# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz +#--------------- mongodb database install ------------------ # +TOOL_VERSION=100.9.4 +TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION} +if [ "aarch64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +if [ "arm64" == ${SYS_ARCH} ];then + TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION} +fi + +TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz +if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then + wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} +fi + +if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then + cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} +fi + +cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb +cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file From f7c88d2086c4ea1f568651614a58d53e236b26bb Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 14:01:26 +0800 Subject: [PATCH 02/13] update --- plugins/mongodb/versions/3.0/centos.sh | 44 +--------------------- plugins/mongodb/versions/3.0/debian.sh | 40 -------------------- plugins/mongodb/versions/3.0/macos.sh | 48 ------------------------ plugins/mongodb/versions/3.0/opensuse.sh | 44 ---------------------- plugins/mongodb/versions/3.0/rhel.sh | 21 +---------- plugins/mongodb/versions/3.0/ubuntu.sh | 43 --------------------- 6 files changed, 2 insertions(+), 238 deletions(-) diff --git a/plugins/mongodb/versions/3.0/centos.sh b/plugins/mongodb/versions/3.0/centos.sh index 3c10f1a0a..7c52b7c38 100644 --- a/plugins/mongodb/versions/3.0/centos.sh +++ b/plugins/mongodb/versions/3.0/centos.sh @@ -65,46 +65,4 @@ if [ ! -d $serverPath/mongodb/bin ];then cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb fi -cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} - -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} - -#--------------- mongodb database install ------------------ # -TOOL_VERSION=100.9.4 -TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION} -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION} -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/debian.sh b/plugins/mongodb/versions/3.0/debian.sh index 24008b150..e9cf34b75 100644 --- a/plugins/mongodb/versions/3.0/debian.sh +++ b/plugins/mongodb/versions/3.0/debian.sh @@ -44,45 +44,5 @@ fi cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} - - -#--------------- mongodb database install ------------------ # -TOOL_VERSION=100.9.4 -TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION} -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} diff --git a/plugins/mongodb/versions/3.0/macos.sh b/plugins/mongodb/versions/3.0/macos.sh index 153b9390b..437dc18f9 100644 --- a/plugins/mongodb/versions/3.0/macos.sh +++ b/plugins/mongodb/versions/3.0/macos.sh @@ -26,51 +26,3 @@ if [ ! -d $serverPath/mongodb/bin ];then mkdir -p $serverPath/mongodb cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb fi - -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64 -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} - -#--------------- mongodb-database-tools ------------------ # -# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip -TOOL_VERSION=100.9.4 -TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION} -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION} -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION} -fi - -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/opensuse.sh b/plugins/mongodb/versions/3.0/opensuse.sh index 64ffcac37..18d0a3442 100644 --- a/plugins/mongodb/versions/3.0/opensuse.sh +++ b/plugins/mongodb/versions/3.0/opensuse.sh @@ -46,47 +46,3 @@ if [ ! -d $serverPath/mongodb/bin ];then fi cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} - -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} - - -# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz -#--------------- mongodb database install ------------------ # -TOOL_VERSION=100.9.4 -TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION} -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/rhel.sh b/plugins/mongodb/versions/3.0/rhel.sh index 1f8210b22..2c556593d 100644 --- a/plugins/mongodb/versions/3.0/rhel.sh +++ b/plugins/mongodb/versions/3.0/rhel.sh @@ -41,23 +41,4 @@ if [ ! -d $serverPath/mongodb/bin ];then cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb fi -cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} - -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file +cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} \ No newline at end of file diff --git a/plugins/mongodb/versions/3.0/ubuntu.sh b/plugins/mongodb/versions/3.0/ubuntu.sh index 5eac1b70f..1e77eb1ea 100644 --- a/plugins/mongodb/versions/3.0/ubuntu.sh +++ b/plugins/mongodb/versions/3.0/ubuntu.sh @@ -44,46 +44,3 @@ if [ ! -d $serverPath/mongodb/bin ];then fi cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME} - -#--------------- mongosh tool install ------------------ # -TOOL_VERSION=2.2.5 -TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64 -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64 -fi -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ} - echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}" -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} - -# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz -#--------------- mongodb database install ------------------ # -TOOL_VERSION=100.9.4 -TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION} -if [ "aarch64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -if [ "arm64" == ${SYS_ARCH} ];then - TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION} -fi - -TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz -if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then - wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ} -fi - -if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then - cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ} -fi - -cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb -cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME} \ No newline at end of file From 32151a176fd51e84f0cd1861559ad1f999c0fd5e Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:04:27 +0800 Subject: [PATCH 03/13] update --- plugins/mongodb/versions/3.0/centos.sh | 2 +- plugins/mongodb/versions/3.0/debian.sh | 2 +- plugins/mongodb/versions/3.0/macos.sh | 2 +- plugins/mongodb/versions/3.0/opensuse.sh | 2 +- plugins/mongodb/versions/3.0/rhel.sh | 2 +- plugins/mongodb/versions/3.0/ubuntu.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/mongodb/versions/3.0/centos.sh b/plugins/mongodb/versions/3.0/centos.sh index 7c52b7c38..8e2848af8 100644 --- a/plugins/mongodb/versions/3.0/centos.sh +++ b/plugins/mongodb/versions/3.0/centos.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` diff --git a/plugins/mongodb/versions/3.0/debian.sh b/plugins/mongodb/versions/3.0/debian.sh index e9cf34b75..d2c568908 100644 --- a/plugins/mongodb/versions/3.0/debian.sh +++ b/plugins/mongodb/versions/3.0/debian.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` SYS_NAME=${SYS_VERSION_ID/./} diff --git a/plugins/mongodb/versions/3.0/macos.sh b/plugins/mongodb/versions/3.0/macos.sh index 437dc18f9..5064ade72 100644 --- a/plugins/mongodb/versions/3.0/macos.sh +++ b/plugins/mongodb/versions/3.0/macos.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 MG_DIR=$serverPath/source/mongodb mkdir -p $MG_DIR diff --git a/plugins/mongodb/versions/3.0/opensuse.sh b/plugins/mongodb/versions/3.0/opensuse.sh index 18d0a3442..7e22d7751 100644 --- a/plugins/mongodb/versions/3.0/opensuse.sh +++ b/plugins/mongodb/versions/3.0/opensuse.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'` diff --git a/plugins/mongodb/versions/3.0/rhel.sh b/plugins/mongodb/versions/3.0/rhel.sh index 2c556593d..75f891170 100644 --- a/plugins/mongodb/versions/3.0/rhel.sh +++ b/plugins/mongodb/versions/3.0/rhel.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` diff --git a/plugins/mongodb/versions/3.0/ubuntu.sh b/plugins/mongodb/versions/3.0/ubuntu.sh index 1e77eb1ea..a5b9b0f2e 100644 --- a/plugins/mongodb/versions/3.0/ubuntu.sh +++ b/plugins/mongodb/versions/3.0/ubuntu.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=3.0.1 +VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` From bd782362e8554705423bbccb626cd692dbc1e30f Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:06:37 +0800 Subject: [PATCH 04/13] update --- plugins/mongodb/versions/3.0/debian.sh | 4 +++- plugins/mongodb/versions/3.0/macos.sh | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/mongodb/versions/3.0/debian.sh b/plugins/mongodb/versions/3.0/debian.sh index d2c568908..c1430e703 100644 --- a/plugins/mongodb/versions/3.0/debian.sh +++ b/plugins/mongodb/versions/3.0/debian.sh @@ -8,6 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.15.tgz VERSION=3.0.15 SYS_ARCH=`arch` SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` @@ -21,7 +22,8 @@ if [ "$SYS_NAME" -lt "10" ];then SYS_NAME="10" fi -FILE_NAME=mongodb-linux-${SYS_ARCH}-debian${SYS_NAME}-${VERSION} +# FILE_NAME=mongodb-linux-${SYS_ARCH}-debian${SYS_NAME}-${VERSION} +FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION} FILE_NAME_TGZ=${FILE_NAME}.tgz diff --git a/plugins/mongodb/versions/3.0/macos.sh b/plugins/mongodb/versions/3.0/macos.sh index 5064ade72..6de12db37 100644 --- a/plugins/mongodb/versions/3.0/macos.sh +++ b/plugins/mongodb/versions/3.0/macos.sh @@ -8,6 +8,7 @@ rootPath=$(dirname "$rootPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +# https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.0.15.tgz VERSION=3.0.15 MG_DIR=$serverPath/source/mongodb From 5fc6eacc53a2aa536d67d04817448b07f145a98e Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:11:09 +0800 Subject: [PATCH 05/13] update --- plugins/mongodb/versions/3.0/centos.sh | 2 +- plugins/mongodb/versions/3.0/opensuse.sh | 2 +- plugins/mongodb/versions/3.0/rhel.sh | 2 +- plugins/mongodb/versions/3.0/ubuntu.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mongodb/versions/3.0/centos.sh b/plugins/mongodb/versions/3.0/centos.sh index 8e2848af8..f37c30079 100644 --- a/plugins/mongodb/versions/3.0/centos.sh +++ b/plugins/mongodb/versions/3.0/centos.sh @@ -48,7 +48,7 @@ fi MG_DIR=$serverPath/source/mongodb mkdir -p $MG_DIR -FILE_NAME=mongodb-linux-${SYS_ARCH}-rhel${SYS_NAME}-${VERSION} +FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION} FILE_NAME_TGZ=${FILE_NAME}.tgz if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then diff --git a/plugins/mongodb/versions/3.0/opensuse.sh b/plugins/mongodb/versions/3.0/opensuse.sh index 7e22d7751..218fe2a43 100644 --- a/plugins/mongodb/versions/3.0/opensuse.sh +++ b/plugins/mongodb/versions/3.0/opensuse.sh @@ -28,7 +28,7 @@ fi MG_DIR=$serverPath/source/mongodb mkdir -p $MG_DIR -FILE_NAME=mongodb-linux-${SYS_ARCH}-suse${SYS_NAME}-${VERSION} +FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION} FILE_NAME_TGZ=${FILE_NAME}.tgz if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then diff --git a/plugins/mongodb/versions/3.0/rhel.sh b/plugins/mongodb/versions/3.0/rhel.sh index 75f891170..6ff26b7ea 100644 --- a/plugins/mongodb/versions/3.0/rhel.sh +++ b/plugins/mongodb/versions/3.0/rhel.sh @@ -24,7 +24,7 @@ fi MG_DIR=$serverPath/source/mongodb mkdir -p $MG_DIR -FILE_NAME=mongodb-linux-${SYS_ARCH}-ubuntu${SYS_NAME}-${VERSION} +FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION} FILE_NAME_TGZ=${FILE_NAME}.tgz if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then diff --git a/plugins/mongodb/versions/3.0/ubuntu.sh b/plugins/mongodb/versions/3.0/ubuntu.sh index a5b9b0f2e..b5870eeaa 100644 --- a/plugins/mongodb/versions/3.0/ubuntu.sh +++ b/plugins/mongodb/versions/3.0/ubuntu.sh @@ -26,7 +26,7 @@ fi MG_DIR=$serverPath/source/mongodb mkdir -p $MG_DIR -FILE_NAME=mongodb-linux-${SYS_ARCH}-ubuntu${SYS_NAME}-${VERSION} +FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION} FILE_NAME_TGZ=${FILE_NAME}.tgz if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then From b43b35ccab72a6295a207d8e44659c049dac30ad Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:21:29 +0800 Subject: [PATCH 06/13] Update install.sh --- plugins/mongodb/install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/mongodb/install.sh b/plugins/mongodb/install.sh index a59ce4e29..c2512461d 100755 --- a/plugins/mongodb/install.sh +++ b/plugins/mongodb/install.sh @@ -6,6 +6,7 @@ export PATH # cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0 # cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0 +# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 3.0 # cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start @@ -78,6 +79,11 @@ Install_app() cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install fi + + if [ "${VERSION}" == "3.0" ];then + # 降低版本 + pip install pymongo==3.12.0 + fi } Uninstall_app() From 3a7d9f84c775cafd17a5a20a448abf8584e3cc3d Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:22:12 +0800 Subject: [PATCH 07/13] Update install.sh --- plugins/mongodb/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/mongodb/install.sh b/plugins/mongodb/install.sh index c2512461d..3bbb33b98 100755 --- a/plugins/mongodb/install.sh +++ b/plugins/mongodb/install.sh @@ -83,6 +83,8 @@ Install_app() if [ "${VERSION}" == "3.0" ];then # 降低版本 pip install pymongo==3.12.0 + else + pip install pymongo fi } From 0851f749c35443d3faf2d537e531c47ac8f0ea7e Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 15:57:20 +0800 Subject: [PATCH 08/13] Update mw.tpl --- scripts/init.d/mw.tpl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 70b186b3f..f8adc5bba 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -591,6 +591,7 @@ mw_connect_pgdb(){ mw_mongodb(){ + # /www/server/mongodb/bin/mongo --version CONF="${ROOT_PATH}/mongodb/mongodb.conf" if [ ! -f "$CONF" ]; then echo -e "not install mongodb!" @@ -606,7 +607,14 @@ mw_mongodb(){ AUTH_STR="-u root -p ${pwd}" fi - CLIEXEC="${ROOT_PATH}/mongodb/bin/mongosh --port ${MGDB_PORT} ${AUTH_STR}" + mg_version=$(/${ROOT_PATH}/mongodb/bin/mongo --version) + + # 根据 MongoDB 版本选择使用 mongo 还是 mongosh + if [[ "$mg_version" == *"3.0"* || "$mg_version" == *"3.2"* || "$mg_version" == *"3.4"* || "$mg_version" == *"3.6"* ]]; then + CLIEXEC="${ROOT_PATH}/mongodb/bin/mongo --port ${MGDB_PORT} ${AUTH_STR}" + else + CLIEXEC="${ROOT_PATH}/mongodb/bin/mongosh --port ${MGDB_PORT} ${AUTH_STR}" + fi echo $CLIEXEC ${CLIEXEC} } @@ -789,6 +797,7 @@ case "$1" in 'pgdb') mw_connect_pgdb;; 'redis') mw_redis;; 'valkey')mw_valkey;; + 'mgdb') mw_mongodb;; 'mongodb') mw_mongodb;; 'ssh') mw_ssh;; 'venv') mw_update_venv;; From b1f9c99eb1ce2a8b19113e23edd9dc295b523872 Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 16:04:53 +0800 Subject: [PATCH 09/13] Update mw.tpl --- scripts/init.d/mw.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index f8adc5bba..3a6b3b5d4 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -611,7 +611,7 @@ mw_mongodb(){ # 根据 MongoDB 版本选择使用 mongo 还是 mongosh if [[ "$mg_version" == *"3.0"* || "$mg_version" == *"3.2"* || "$mg_version" == *"3.4"* || "$mg_version" == *"3.6"* ]]; then - CLIEXEC="${ROOT_PATH}/mongodb/bin/mongo --port ${MGDB_PORT} ${AUTH_STR}" + CLIEXEC="${ROOT_PATH}/mongodb/bin/mongo --port ${MGDB_PORT} ${AUTH_STR} --authenticationDatabase admin" else CLIEXEC="${ROOT_PATH}/mongodb/bin/mongosh --port ${MGDB_PORT} ${AUTH_STR}" fi From a935acbc95404350f8fe4d2704b6f966254bca33 Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 16:12:16 +0800 Subject: [PATCH 10/13] update --- plugins/mongodb/index.py | 10 ++++++---- plugins/mongodb/scripts/backup.py | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index c6b74c6f8..9025997f5 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -196,10 +196,11 @@ def mongdbClientS(): mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') if auth == 'disabled': - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True) + client = pymongo.MongoClient(host=ip, port=int(port)) else: # print(auth,mg_root) - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root) + # 使用 admin 数据库进行认证,兼容 MongoDB 3.0 + client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') return client def mongdbClient(): @@ -210,11 +211,12 @@ def mongdbClient(): mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') # print(ip,port,auth,mg_root) if auth == 'disabled': - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True) + client = pymongo.MongoClient(host=ip, port=int(port)) else: # uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port) # client = pymongo.MongoClient(uri) - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root) + # 使用 admin 数据库进行认证,兼容 MongoDB 3.0 + client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') return client diff --git a/plugins/mongodb/scripts/backup.py b/plugins/mongodb/scripts/backup.py index bc3db6bf1..e6f64a324 100644 --- a/plugins/mongodb/scripts/backup.py +++ b/plugins/mongodb/scripts/backup.py @@ -122,11 +122,12 @@ def mongdbClient(): mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') # print(ip,port,auth,mg_root) if auth == 'disabled': - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True) + client = pymongo.MongoClient(host=ip, port=int(port)) else: # uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port) # client = pymongo.MongoClient(uri) - client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root) + # 使用 admin 数据库进行认证,兼容 MongoDB 3.0 + client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') return client class backupTools: From 8dff306a913fbd1467879cfe70d705cff69f11ba Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 16:20:03 +0800 Subject: [PATCH 11/13] Update index.py --- plugins/mongodb/index.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index 9025997f5..e49f1f910 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -713,7 +713,6 @@ def setRootPwd(version=''): def setUserPwd(version=''): client = mongdbClient() - db = client.admin sqlite_db = pSqliteDb('databases') args = getArgs() @@ -726,6 +725,8 @@ def setUserPwd(version=''): uid = args['id'] try: name = sqlite_db.where('id=?', (uid,)).getField('name') + # 将用户创建在目标数据库中,而不是 admin 数据库 + db = client[name] user_roles = [{'role': 'dbOwner', 'db': name}, {'role': 'userAdmin', 'db': name}] try: @@ -826,16 +827,16 @@ def getDbInfo(): def toDbBase(find): client = mongdbClient() - db_admin = client.admin data_name = find['name'] db = client[data_name] db.zchat.insert_one({}) user_roles = [{'role': 'dbOwner', 'db': data_name}, {'role': 'userAdmin', 'db': data_name}] + # 将用户创建在目标数据库中,而不是 admin 数据库 try: - db_admin.command("createUser", find['username'], pwd=find['password'], roles=user_roles) + db.command("createUser", find['username'], pwd=find['password'], roles=user_roles) except Exception as e: - db_admin.command("updateUser", find['username'], pwd=find['password'], roles=user_roles) + db.command("updateUser", find['username'], pwd=find['password'], roles=user_roles) return 1 def syncToDatabases(): @@ -992,7 +993,8 @@ def setDbAccess(): user_roles.append(t) client = mongdbClient() - db = client.admin + # 在目标数据库中操作用户,而不是 admin 数据库 + db = client[name] try: db.command("updateUser", username, pwd=mg_pass, roles=user_roles) From 48ef0e7a656f0ad48c25b5bc1d312473786024d3 Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 16:22:03 +0800 Subject: [PATCH 12/13] Update index.py --- plugins/mongodb/index.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index e49f1f910..a35fdd001 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -203,20 +203,48 @@ def mongdbClientS(): client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') return client +def getMongoDBVersion(): + '''获取MongoDB版本号''' + import pymongo + port = getConfPort() + ip = getConfLocalIp() + try: + # 先不使用认证连接 + client = pymongo.MongoClient(host=ip, port=int(port), serverSelectionTimeoutMS=5000) + db = client.admin + serverStatus = db.command('serverStatus') + version = serverStatus.get('version', '4.0') + client.close() + return version + except Exception as e: + # 如果无法获取版本,默认返回 4.0(新版本兼容模式) + return '4.0' + +def isMongoDB3x(): + '''判断是否为MongoDB 3.x版本''' + version = getMongoDBVersion() + # 匹配 3.x 版本 + if version.startswith('3.'): + return True + return False + def mongdbClient(): import pymongo port = getConfPort() auth = getConfAuth() ip = getConfLocalIp() mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root') - # print(ip,port,auth,mg_root) + if auth == 'disabled': client = pymongo.MongoClient(host=ip, port=int(port)) else: - # uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port) - # client = pymongo.MongoClient(uri) - # 使用 admin 数据库进行认证,兼容 MongoDB 3.0 - client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') + # 根据MongoDB版本选择认证方式 + if isMongoDB3x(): + # MongoDB 3.x 使用 authSource 指定认证数据库 + client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin') + else: + # MongoDB 4.x+ 默认在 admin 数据库认证 + client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root) return client From 9b7e9d4ffa6e425442361d92be32f792611cb40c Mon Sep 17 00:00:00 2001 From: dami Date: Thu, 7 May 2026 16:29:03 +0800 Subject: [PATCH 13/13] update --- requirements.txt | 3 ++- version/r3.6.txt | 3 ++- version/r3.7.txt | 3 ++- version/r3.8.txt | 3 ++- version/r3.9.txt | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 53f4271b0..0e17a9002 100644 --- a/requirements.txt +++ b/requirements.txt @@ -50,4 +50,5 @@ Flask-Compress brotli zstd zstandard -geoip2 \ No newline at end of file +geoip2 +docker \ No newline at end of file diff --git a/version/r3.6.txt b/version/r3.6.txt index 44b4e28c3..dd1db33f4 100644 --- a/version/r3.6.txt +++ b/version/r3.6.txt @@ -39,4 +39,5 @@ telebot pyyaml Flask-Compress croniter -geoip2 \ No newline at end of file +geoip2 +docker \ No newline at end of file diff --git a/version/r3.7.txt b/version/r3.7.txt index 44b4e28c3..dd1db33f4 100644 --- a/version/r3.7.txt +++ b/version/r3.7.txt @@ -39,4 +39,5 @@ telebot pyyaml Flask-Compress croniter -geoip2 \ No newline at end of file +geoip2 +docker \ No newline at end of file diff --git a/version/r3.8.txt b/version/r3.8.txt index 44b4e28c3..dd1db33f4 100644 --- a/version/r3.8.txt +++ b/version/r3.8.txt @@ -39,4 +39,5 @@ telebot pyyaml Flask-Compress croniter -geoip2 \ No newline at end of file +geoip2 +docker \ No newline at end of file diff --git a/version/r3.9.txt b/version/r3.9.txt index 44b4e28c3..dd1db33f4 100644 --- a/version/r3.9.txt +++ b/version/r3.9.txt @@ -39,4 +39,5 @@ telebot pyyaml Flask-Compress croniter -geoip2 \ No newline at end of file +geoip2 +docker \ No newline at end of file