mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:19:25 +08:00
+44
-12
@@ -196,25 +196,55 @@ 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 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), 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)
|
||||
# 根据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
|
||||
|
||||
|
||||
@@ -711,7 +741,6 @@ def setRootPwd(version=''):
|
||||
def setUserPwd(version=''):
|
||||
|
||||
client = mongdbClient()
|
||||
db = client.admin
|
||||
sqlite_db = pSqliteDb('databases')
|
||||
|
||||
args = getArgs()
|
||||
@@ -724,6 +753,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:
|
||||
@@ -824,16 +855,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():
|
||||
@@ -990,7 +1021,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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,13 @@ 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
|
||||
else
|
||||
pip install pymongo
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_app()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/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.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/./}
|
||||
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}-${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}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/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")
|
||||
|
||||
# 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}'`
|
||||
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=mongodb-linux-${SYS_ARCH}-${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}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/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")
|
||||
|
||||
# https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.0.15.tgz
|
||||
VERSION=3.0.15
|
||||
|
||||
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
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/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.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}'`
|
||||
|
||||
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}-${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}
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/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.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/./}
|
||||
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}-${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}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/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.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/./}
|
||||
# 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}-${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}
|
||||
+2
-1
@@ -50,4 +50,5 @@ Flask-Compress
|
||||
brotli
|
||||
zstd
|
||||
zstandard
|
||||
geoip2
|
||||
geoip2
|
||||
docker
|
||||
+10
-1
@@ -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} --authenticationDatabase admin"
|
||||
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;;
|
||||
|
||||
+2
-1
@@ -39,4 +39,5 @@ telebot
|
||||
pyyaml
|
||||
Flask-Compress
|
||||
croniter
|
||||
geoip2
|
||||
geoip2
|
||||
docker
|
||||
+2
-1
@@ -39,4 +39,5 @@ telebot
|
||||
pyyaml
|
||||
Flask-Compress
|
||||
croniter
|
||||
geoip2
|
||||
geoip2
|
||||
docker
|
||||
+2
-1
@@ -39,4 +39,5 @@ telebot
|
||||
pyyaml
|
||||
Flask-Compress
|
||||
croniter
|
||||
geoip2
|
||||
geoip2
|
||||
docker
|
||||
+2
-1
@@ -39,4 +39,5 @@ telebot
|
||||
pyyaml
|
||||
Flask-Compress
|
||||
croniter
|
||||
geoip2
|
||||
geoip2
|
||||
docker
|
||||
Reference in New Issue
Block a user