diff --git a/plugins/mysql-community/index.py b/plugins/mysql-community/index.py index bec36eb18..989524778 100755 --- a/plugins/mysql-community/index.py +++ b/plugins/mysql-community/index.py @@ -8,6 +8,7 @@ import subprocess import re import json +from packaging import version as pk_version web_dir = os.getcwd() + "/web" if os.path.exists(web_dir): @@ -726,7 +727,7 @@ def myDbStatus(version): gets = ['table_open_cache', 'thread_cache_size', 'key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_additional_mem_pool_size', 'innodb_log_buffer_size', 'max_connections', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] - if version != "8.0": + if pk_version.parse(ver) < pk_version.parse("8.0"): gets.append('query_cache_size') result['mem'] = {} @@ -743,8 +744,7 @@ def setDbStatus(version): gets = ['key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections', 'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] - if version != "8.0": - # gets.append('query_cache_size') + if pk_version.parse(ver) < pk_version.parse("8.0"): gets = ['key_buffer_size', 'query_cache_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections', 'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index db1cb8c2c..2070075a7 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -9,6 +9,7 @@ import subprocess import re import json +from packaging import version as pk_version web_dir = os.getcwd() + "/web" if os.path.exists(web_dir): @@ -854,8 +855,8 @@ def runInfo(version): return mw.getJson(result) -def myDbStatus(version): - if status(version) == 'stop': +def myDbStatus(ver): + if status(ver) == 'stop': return mw.returnJson(False, 'MySQL未启动', []) result = {} @@ -868,7 +869,7 @@ def myDbStatus(version): gets = ['table_open_cache', 'thread_cache_size', 'key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_additional_mem_pool_size', 'innodb_log_buffer_size', 'max_connections', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] - if version != "8.0": + if pk_version.parse(ver) < pk_version.parse("8.0"): gets.append('query_cache_size') result['mem'] = {} @@ -881,12 +882,11 @@ def myDbStatus(version): return mw.getJson(result) -def setDbStatus(version): +def setDbStatus(ver): gets = ['key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections', 'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] - if version != "8.0": - # gets.append('query_cache_size') + if pk_version.parse(ver) < pk_version.parse("8.0"): gets = ['key_buffer_size', 'query_cache_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections', 'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] @@ -957,6 +957,9 @@ def __createUser(dbname, username, password, address): def getDbBackupListFunc(dbname=''): bkDir = mw.getBackupDir() + '/database' + if not os.path.exists(bkDir): + mw.execShell('mkdir -p ' + bkDir) + blist = os.listdir(bkDir) r = [] diff --git a/requirements.txt b/requirements.txt index 65baed2fd..c1a3efeca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,3 +43,4 @@ pyTelegramBotAPI telebot pyyaml croniter +packaging diff --git a/scripts/install.sh b/scripts/install.sh index 386f36c25..d13c94835 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -53,11 +53,11 @@ elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-rele yum install -y wget curl zip unzip tar crontabs elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/os-release; then OSNAME='debian' - apt update -y + # apt update -y apt install -y wget curl zip unzip tar cron elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/os-release; then OSNAME='ubuntu' - apt update -y + # apt update -y apt install -y wget curl zip unzip tar cron else OSNAME='unknow'