From 5adcf51a5636258f4c9db36fe7d53ac6bf8de58a Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 11 Jul 2022 22:46:08 +0800 Subject: [PATCH 001/173] Update config_api.py --- class/core/config_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index 3f9d4ed36..af2938df8 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -17,7 +17,7 @@ class config_api: # 进行中. # 兼容主流Linux系统 - __version = '0.8.6.6' + __version = '0.8.6.7' def __init__(self): pass From 03077b4498c06f989f5132bf174744ecee70ba73 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 11 Jul 2022 23:23:55 +0800 Subject: [PATCH 002/173] Update install.sh --- plugins/mysql/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mysql/install.sh b/plugins/mysql/install.sh index 69d99bcb0..51a3f3c15 100755 --- a/plugins/mysql/install.sh +++ b/plugins/mysql/install.sh @@ -26,10 +26,11 @@ fi if [ "${action}" == "uninstall" ];then - if [ -f /usr/lib/systemd/system/mysql.service ];then + if [ -f /usr/lib/systemd/system/mysql.service ] || [ -f /lib/systemd/system/mysql.service ];then systemctl stop mysql systemctl disable mysql rm -rf /usr/lib/systemd/system/mysql.service + rm -rf /lib/systemd/system/mysql.service systemctl daemon-reload fi fi From 8d134e1bdaae913a92aaaf528187f75e625ea4a4 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 11 Jul 2022 23:36:28 +0800 Subject: [PATCH 003/173] Update index.py --- plugins/mysql/index.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 5645b06ae..51c1a8b04 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -358,8 +358,20 @@ def initMysqlPwd(): serverdir = getServerDir() pwd = mw.getRandomString(16) - cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd - mw.execShell(cmd_pass) + # cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd + + # cmd_pass = "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'127.0.0.1')" + # cmd_pass = cmd_pass + \ + # "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'localhost')" + # cmd_pass = cmd_pass + \ + # "UPDATE mysql.user SET password=PASSWORD('" + \ + # pwd + "') WHERE user='root'" + cmd_pass = serverdir + '/bin/mysql -uroot -e' + cmd_pass = cmd_pass + "\"UPDATE mysql.user SET password=PASSWORD('" + \ + pwd + "') WHERE user='root';" + cmd_pass = cmd_pass + "flush privileges;\"" + data = mw.execShell(cmd_pass) + print(data) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True From ddf6b520dca34d9e39deb20ebd7938e6ce8577c9 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 11 Jul 2022 23:38:05 +0800 Subject: [PATCH 004/173] Update index.py --- plugins/mysql/index.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 51c1a8b04..907e93005 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -356,7 +356,6 @@ def initMysqlPwd(): time.sleep(5) serverdir = getServerDir() - pwd = mw.getRandomString(16) # cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd From 065b73c3a4e83a8598171176a775c69a3c905d21 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 11 Jul 2022 23:44:11 +0800 Subject: [PATCH 005/173] Update index.py --- plugins/mysql/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 907e93005..9a11a5324 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -370,7 +370,7 @@ def initMysqlPwd(): pwd + "') WHERE user='root';" cmd_pass = cmd_pass + "flush privileges;\"" data = mw.execShell(cmd_pass) - print(data) + # print(data) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True @@ -388,13 +388,13 @@ def initMysql8Pwd(): "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" alter_root_pwd = alter_root_pwd + "flush privileges;" - cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' - data = mw.execShell(cmd_pass) + # cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' + # data = mw.execShell(cmd_pass) # print(data) tmp_file = "/tmp/mysql_init_tmp.log" mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql -uroot -proot < ' + tmp_file + cmd_pass = serverdir + '/bin/mysql -uroot -p < ' + tmp_file data = mw.execShell(cmd_pass) # print(data) From 3b2a441bb4a3f65f9fa6e0e39b61e038e22ba227 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 00:01:17 +0800 Subject: [PATCH 006/173] Update index.py --- plugins/php/index.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/php/index.py b/plugins/php/index.py index e6532ccef..160f7a625 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -78,7 +78,7 @@ def getFpmConfFile(version): return getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf' -def status(version): +def status_progress(version): # ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2} cmd = "ps -ef|grep 'php/" + version + \ "' |grep -v grep | grep -v python | awk '{print $2}'" @@ -88,6 +88,27 @@ def status(version): return 'start' +def getPhpSocket(version): + path = getFpmConfFile(version) + content = mw.readFile(path) + rep = 'listen\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def status(version): + ''' + sock文件判断是否启动 + ''' + sock = getPhpSocket(version) + if sock.find(':'): + return status_progress(version) + + if not os.path.exists(sock): + return 'stop' + return 'start' + + def contentReplace(content, version): service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getRootDir()) From 93102a17b621f641d621dad222f1f5333b782867 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 02:07:58 +0800 Subject: [PATCH 007/173] Update plugins_api.py --- class/core/plugins_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 04c0180ba..d989ff5ff 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -290,7 +290,7 @@ class plugins_api: except: mw.execShell("rm -rf " + tmp_path) return mw.returnJson(False, '在压缩包中没有找到插件信息,请检查插件包!') - protectPlist = ('openresty', 'mysql', 'php', 'redis', + protectPlist = ('openresty', 'mysql', 'php', 'redis', 'memcached' 'mongodb', 'swap', 'gogs', 'pureftp') if data['name'] in protectPlist: return mw.returnJson(False, '[' + data['name'] + '],重要插件不可修改!') From 88ce50fc23518062d9bcc136264c8392beada17d Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 02:21:00 +0800 Subject: [PATCH 008/173] up --- plugins/mysql/versions/5.5/install.sh | 1 + plugins/mysql/versions/5.6/install.sh | 1 + plugins/mysql/versions/5.7/install.sh | 1 + plugins/mysql/versions/8.0/install.sh | 1 + 4 files changed, 4 insertions(+) diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index 110dc6454..9cf5f5f1b 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -66,6 +66,7 @@ Install_mysql() else rm -rf ${mysqlDir}/mysql-5.5.62 echo '安装失败' > $install_tmp + echo 'install fail'>&2 exit 1 fi fi diff --git a/plugins/mysql/versions/5.6/install.sh b/plugins/mysql/versions/5.6/install.sh index 1e0540780..c3aad718d 100755 --- a/plugins/mysql/versions/5.6/install.sh +++ b/plugins/mysql/versions/5.6/install.sh @@ -82,6 +82,7 @@ Install_mysql() else rm -rf ${mysqlDir}/mysql-5.6.50 echo '安装失败' > $install_tmp + echo 'install fail'>&2 exit 1 fi fi diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 8e3cd819c..577aa572a 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -97,6 +97,7 @@ Install_mysql() else rm -rf ${mysqlDir}/mysql-${VERSION} echo '安装失败' > $install_tmp + echo 'install fail'>&2 exit 1 fi fi diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index 57a9f7ea3..038469b89 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -156,6 +156,7 @@ Install_mysql() else rm -rf ${mysqlDir}/mysql-${VERSION} echo '安装失败' > $install_tmp + echo 'install fail'>&2 exit 1 fi fi From 6ba3c6c93b059d72275589a79fe669c4feab86d9 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 08:52:21 +0800 Subject: [PATCH 009/173] Update compatibility.md --- compatibility.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compatibility.md b/compatibility.md index 16a3ab446..f624c3df6 100644 --- a/compatibility.md +++ b/compatibility.md @@ -57,8 +57,8 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh | CentOS 9 Stream |✅ |:x: |:x: |:x: | | Debian 10.3 |✅ |✅ |✅ |:x: | | Debian 11.3 |✅ |✅ |✅ |✅ | -| Ubuntu 18.04 |✅ |✅ |✅ |✅ | -| Ubuntu 20.04 |✅ |✅ |✅ |✅ | +| Ubuntu 18.04 |✅ |✅ |✅ |:x: | +| Ubuntu 20.04 |✅ |✅ |✅ |:x: | | Ubuntu 22.04 |✅ |✅ |✅ |✅ | | Fedora 31 |✅ |✅ |✅ |✅ | | Fedora 32 |✅ |✅ |✅ |✅ | From 465fd8c48747bd334ab6d8fbbe5a6855472cdaef Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 10:21:31 +0800 Subject: [PATCH 010/173] Update index.py --- plugins/mysql/index.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 9a11a5324..3c59f38b4 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -322,6 +322,9 @@ def initMysqlData(): def initMysql57Data(): + ''' + cd /www/server/mysql && /www/server/mysql/bin/mysqld --defaults-file=/www/server/mysql/etc/my.cnf --initialize-insecure --explicit_defaults_for_timestamp + ''' datadir = getDataDir() if not os.path.exists(datadir + '/mysql'): serverdir = getServerDir() @@ -329,8 +332,7 @@ def initMysql57Data(): user = pGetDbUser() cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ ' --initialize-insecure --explicit_defaults_for_timestamp' - # print(mw.execShell(cmd)) - + data = mw.execShell(cmd) return False return True From 9c2bbf7431c8b6d256a338ef8637a9d7e31dc610 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 10:23:23 +0800 Subject: [PATCH 011/173] up --- class/core/mw.py | 5 +- plugins/mariadb/class/mysqlDb.py | 99 ++ plugins/mariadb/conf/my.cnf | 99 ++ plugins/mariadb/conf/my5.7.cnf | 96 + plugins/mariadb/conf/my8.0.cnf | 98 ++ plugins/mariadb/conf/mysql.sql | 28 + plugins/mariadb/ico.png | Bin 0 -> 13002 bytes plugins/mariadb/index.html | 60 + plugins/mariadb/index.py | 2035 ++++++++++++++++++++++ plugins/mariadb/info.json | 18 + plugins/mariadb/init.d/mysql.service.tpl | 24 + plugins/mariadb/init.d/mysql.tpl | 383 ++++ plugins/mariadb/init.d/mysql8.0.tpl | 376 ++++ plugins/mariadb/install.sh | 44 + plugins/mariadb/js/mariadb.js | 1736 ++++++++++++++++++ plugins/mariadb/scripts/tools.py | 119 ++ plugins/mariadb/versions/10.6/install.sh | 86 + 17 files changed, 5304 insertions(+), 2 deletions(-) create mode 100755 plugins/mariadb/class/mysqlDb.py create mode 100644 plugins/mariadb/conf/my.cnf create mode 100644 plugins/mariadb/conf/my5.7.cnf create mode 100644 plugins/mariadb/conf/my8.0.cnf create mode 100755 plugins/mariadb/conf/mysql.sql create mode 100644 plugins/mariadb/ico.png create mode 100755 plugins/mariadb/index.html create mode 100755 plugins/mariadb/index.py create mode 100755 plugins/mariadb/info.json create mode 100644 plugins/mariadb/init.d/mysql.service.tpl create mode 100644 plugins/mariadb/init.d/mysql.tpl create mode 100755 plugins/mariadb/init.d/mysql8.0.tpl create mode 100755 plugins/mariadb/install.sh create mode 100755 plugins/mariadb/js/mariadb.js create mode 100755 plugins/mariadb/scripts/tools.py create mode 100755 plugins/mariadb/versions/10.6/install.sh diff --git a/class/core/mw.py b/class/core/mw.py index a760e5458..76daa8e5b 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -516,8 +516,9 @@ def getLastLine(inputfile, lineNum): result += lastre[num] + "\n" num -= 1 return result - except: - return getMsg('TASK_SLEEP') + except Exception as e: + return str(e) + # return getMsg('TASK_SLEEP') def getNumLines(path, num, p=1): diff --git a/plugins/mariadb/class/mysqlDb.py b/plugins/mariadb/class/mysqlDb.py new file mode 100755 index 000000000..867d3f3d7 --- /dev/null +++ b/plugins/mariadb/class/mysqlDb.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +import re +import os +import sys + +# sys.path.append("/usr/local/lib/python3.9/site-packages") + +sys.path.append(os.getcwd() + "/class/core") +import mw + +# if mw.isAppleSystem(): +# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' +# info = mw.execShell(cmd) +# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" +# sys.path.append(p) + + +class mysqlDb: + __DB_PASS = None + __DB_USER = 'root' + __DB_PORT = 3306 + __DB_HOST = 'localhost' + __DB_CONN = None + __DB_CUR = None + __DB_ERR = None + __DB_CNF = '/etc/my.cnf' + + def __Conn(self): + '''连接MYSQL数据库''' + try: + import mw + socket = '/www/server/mysql/mysql.sock' + try: + import MySQLdb + except Exception as ex: + # print('dd') + self.__DB_ERR = ex + return False + try: + myconf = mw.readFile(self.__DB_CNF) + rep = "port\s*=\s*([0-9]+)" + self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) + except: + self.__DB_PORT = 3306 + # print self.__DB_PASS + #self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root') + try: + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + except MySQLdb.Error as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + self.__DB_CUR = self.__DB_CONN.cursor() + return True + except MySQLdb.Error as e: + self.__DB_ERR = e + return False + + def setDbConf(self, conf): + self.__DB_CNF = conf + + def setPwd(self, pwd): + self.__DB_PASS = pwd + + def getPwd(self): + return self.__DB_PASS + + def execute(self, sql): + # 执行SQL语句返回受影响行 + if not self.__Conn(): + return self.__DB_ERR + try: + result = self.__DB_CUR.execute(sql) + self.__DB_CONN.commit() + self.__Close() + return result + except Exception as ex: + return ex + + def query(self, sql): + # 执行SQL语句返回数据集 + if not self.__Conn(): + return self.__DB_ERR + try: + self.__DB_CUR.execute(sql) + result = self.__DB_CUR.fetchall() + # 将元组转换成列表 + # data = list(map(list, result)) + self.__Close() + return result + except Exception as ex: + return ex + + # 关闭连接 + def __Close(self): + self.__DB_CUR.close() + self.__DB_CONN.close() diff --git a/plugins/mariadb/conf/my.cnf b/plugins/mariadb/conf/my.cnf new file mode 100644 index 000000000..c699ed3e3 --- /dev/null +++ b/plugins/mariadb/conf/my.cnf @@ -0,0 +1,99 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock + +[mysqld] +pid-file = {$SERVER_APP_PATH}/data/mysql.pid +user = mysql +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +basedir = {$SERVER_APP_PATH} +datadir = {$SERVER_APP_PATH}/data +log-error = {$SERVER_APP_PATH}/data/error.log +default_storage_engine = MyISAM +key_buffer_size = 8M +max_allowed_packet = 100M +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +lower_case_table_names=1 +query_cache_size = 4M +tmp_table_size = 8M + +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 65535 + +#skip-networking +#skip-name-resolve +#skip-external-locking +#loose-skip-innodb +#skip-grant-tables + + +log-bin=mysql-bin +binlog_format=mixed +server-id = 1 +expire_logs_days = 10 +slow_query_log=1 +slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log +long_query_time=3 +#log_queries_not_using_indexes=on + +relay-log=mdserver +relay-log-index=mdserver + +#master +#binlog-do-db +binlog-ignore-db = test +binlog-ignore-db = mysql +binlog-ignore-db = information_schema +binlog-ignore-db = performance_schema + +#slave +log-slave-updates +#replicate-do-db +replicate-ignore-db = information_schema +replicate-ignore-db = performance_schema +replicate-ignore-db = mysql +replicate-ignore-db = test + +default_storage_engine = InnoDB +innodb_data_home_dir = {$SERVER_APP_PATH}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = {$SERVER_APP_PATH}/data +innodb_buffer_pool_size = 16M +innodb_additional_mem_pool_size = 2M +innodb_log_file_size = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 120 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 1 +innodb_write_io_threads = 1 +innodb_file_per_table=1 + + +secure-file-priv={$SERVER_APP_PATH}/tmp + +[mysqldump] +quick +max_allowed_packet = 16M + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout \ No newline at end of file diff --git a/plugins/mariadb/conf/my5.7.cnf b/plugins/mariadb/conf/my5.7.cnf new file mode 100644 index 000000000..b0a71d37f --- /dev/null +++ b/plugins/mariadb/conf/my5.7.cnf @@ -0,0 +1,96 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +default-character-set = UTF8MB4 + +[mysqld] +pid-file = {$SERVER_APP_PATH}/data/mysql.pid +user = mysql +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +basedir = {$SERVER_APP_PATH} +datadir = {$SERVER_APP_PATH}/data +log-error = {$SERVER_APP_PATH}/data/error.log +default_storage_engine = MyISAM + +key_buffer_size = 8M +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +lower_case_table_names=0 +tmp_table_size = 8M +character-set-server = UTF8MB4 + +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 2560 +max_allowed_packet = 128M + +#skip-external-locking +#skip-grant-tables +#loose-skip-innodb +#skip-networking +#skip-name-resolve + +log-bin=mysql-bin +binlog_format=mixed +server-id = 1 +slow_query_log=1 +slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log +long_query_time=3 +#log_queries_not_using_indexes=on + +relay-log=mdserver +relay-log-index=mdserver + +#master +#binlog-do-db +binlog-ignore-db = test +binlog-ignore-db = mysql +binlog-ignore-db = information_schema +binlog-ignore-db = performance_schema + +#slave +log-slave-updates +#replicate-do-db +replicate-ignore-db = information_schema +replicate-ignore-db = performance_schema +replicate-ignore-db = mysql +replicate-ignore-db = test + +default_storage_engine = InnoDB +innodb_data_home_dir = {$SERVER_APP_PATH}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = {$SERVER_APP_PATH}/data +innodb_buffer_pool_size = 16M +innodb_log_file_size = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 120 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 1 +innodb_write_io_threads = 1 +innodb_file_per_table=1 + +secure-file-priv={$SERVER_APP_PATH}/tmp + +[mysqldump] +quick + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout \ No newline at end of file diff --git a/plugins/mariadb/conf/my8.0.cnf b/plugins/mariadb/conf/my8.0.cnf new file mode 100644 index 000000000..7e390ce92 --- /dev/null +++ b/plugins/mariadb/conf/my8.0.cnf @@ -0,0 +1,98 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +default-character-set = UTF8MB4 + +[mysqld] +default_authentication_plugin=mysql_native_password +pid-file = {$SERVER_APP_PATH}/data/mysql.pid +user = mysql +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +basedir = {$SERVER_APP_PATH} +datadir = {$SERVER_APP_PATH}/data +log-error = {$SERVER_APP_PATH}/data/error.log +default_storage_engine = MyISAM + +key_buffer_size = 8M +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +lower_case_table_names=0 +tmp_table_size = 8M +character-set-server = UTF8MB4 + +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 2560 +max_allowed_packet = 128M + +#skip-external-locking +#skip-grant-tables +#loose-skip-innodb +#skip-networking +#skip-name-resolve + +log-bin=mysql-bin +binlog_format=mixed +server-id = 1 +slow_query_log=1 +slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log +long_query_time=3 +#log_queries_not_using_indexes=on + +relay-log=mdserver +relay-log-index=mdserver + +#master +#binlog-do-db +binlog-ignore-db = test +binlog-ignore-db = mysql +binlog-ignore-db = information_schema +binlog-ignore-db = performance_schema + +#slave +log_replica_updates +#replicate-do-db +replicate-ignore-db = information_schema +replicate-ignore-db = performance_schema +replicate-ignore-db = mysql +replicate-ignore-db = test + +default_storage_engine = InnoDB +innodb_data_home_dir = {$SERVER_APP_PATH}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = {$SERVER_APP_PATH}/data +innodb_buffer_pool_size = 16M +innodb_log_file_size = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 120 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 1 +innodb_write_io_threads = 1 +innodb_file_per_table=1 +binlog_expire_logs_seconds=2592000 + +secure-file-priv={$SERVER_APP_PATH}/tmp + +[mysqldump] +quick + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout \ No newline at end of file diff --git a/plugins/mariadb/conf/mysql.sql b/plugins/mariadb/conf/mysql.sql new file mode 100755 index 000000000..38b822738 --- /dev/null +++ b/plugins/mariadb/conf/mysql.sql @@ -0,0 +1,28 @@ +CREATE TABLE IF NOT EXISTS `config` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + `mysql_root` TEXT +); + +INSERT INTO `config` (`id`, `mysql_root`) VALUES (1, 'admin'); + +CREATE TABLE IF NOT EXISTS `databases` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + `pid` INTEGER, + `name` TEXT, + `username` TEXT, + `password` TEXT, + `accept` TEXT, + `ps` TEXT, + `addtime` TEXT +); + +CREATE TABLE IF NOT EXISTS `master_replication_user` ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT, + `username` TEXT, + `password` TEXT, + `accept` TEXT, + `ps` TEXT, + `addtime` TEXT +); + + diff --git a/plugins/mariadb/ico.png b/plugins/mariadb/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..8a9f3b3146c9aabc2208dcc7fd116ebfa521aa44 GIT binary patch literal 13002 zcmcJ#_g_=b6EB>EgdRZY2_g|`AEby7KtYkHh;&7I2}PwO5Co({LJ6pJX(Avep^sp5>ul zcGEijjov}r&PY*vOWuXDiBfZjUa~H> zWz7~0;cTC*LO|Fb9S5Kqot2;h{m$J?kB1DH=)=kMRUcc1lBo=dZ(J1LZJOVZ0fgYD zb+x29n34GKa^hq?0+?48r(4Nc2Ki{utIajRP>sqnA3_V7&r(&E&ixJmvma&^tNi{4 zDzTJxEL{f=TzxDR2iaR6SLGk%Ct9R=!Ls>|M(R)+mzENNpw9{IUxLwHFt3X(SZAv{ zL{qmVi6hRbR%W)KvWvJ6RW%@+oGXv<81O-{cYpgTj9&KlV67R$Lwwl1?U%}=B7k@U z;vj#NCc6K6%n8`3x9ivQg3<3UB{Vp(&bk&%cG!Sy%Vj^ry$7uY=>%V9n|=OwvfBt` ztDu%xC&}P5vf}sHh_Q;@Itl#Q!0q9G#Lu`7nFXLDJF~}3!MzN)lKnn2P{@eTKKc?5 z)u+3e1LkJmC-WW_7~>e@BT00O$wg%gTt+~i<>aEMd|DWyT`a&*7D@{shU}i~uxx<> zY2u8`hxhrQ;M&FJaX?zhOSDgOkOZ~MKT-$lekj*c2S+~*P@txzNibCT{W;G`MtkXMEwdxsts1UNPE$}-!mvgJ8v=7FXDlpGKg9+v}hbd4>z3Koc+G`9p*C<&eb z-UvXvo@S${FU<})2ZW5+!DKOjpxe1-e{d(2W`WXgR54;zPPcPm`|)QUfk(f4E5c?Y z8}p?=db9_U#F3m%gd&6yXo4Z$UWUsR; zRaaH*hY$?1M*f~7UflKYf{FMvDFS4QpE$Wa%|i_MqsT)w#Xk*F0==hhb7NR zm08RIERZAg=!EDUN`Q3!7gc*^d7-CDaL`GNtDeoV5mkZ6c3Aaa1nzw1tUy2W_r^u2 z883|=#F|@L0^@e*=7S)o)X|1OIZid+ao|`=sx|V1d2J;1DN$tgsO0#q?(T+ zl&-O_3|dam8Dpa|EapjrIFo>+qn}A>6PF{(o+<;9qm3Pgz0+q1O1JuC0SY$kzYDk_ z;V^}qCH;9pK>_r+7I>zevq!cE6xViBFk8?54Le2R%?K#yoIji*{Pej3RdfVc>r;15 z;&dk#a9O+Ngmjz`^2rSD0&~>11<2K2hG@eDS5Qcf*%s>_Tl*1$YAczw2yT9HoY-{4 zKosY%K2fB=M_u;*@U9wUgI76?#}KvN;F$^H<75ym%Lxh5eOiOkcyVKb3#(lP2md`` z^Z%@_&7kHy)yL9!a9|5%!G>Hfrm<=cb{?#VRVJA-fC( z%mesGonLTAuxecF1F&`#Cp9VhK4?Cn!Ic%u4wDBuR=fQ59mLN>0w4A@s$zu72bf~l ziEm;Y7TZ(faf%fQfJbWqmwy3<-SU5Oz>iO-9Lq?u07K&gn1?LDjegKES1c>Q)SobF zi2(j#H-K0b1`t;R$L{We6;Jfmi`vr6l))vQ&9Ma_CK`cf7Mn&dx&rzuI&;I8X!Kaq zlKKsP4_FnIUF-vfv@Eq&X(Y&upU54y4qDpj}e|mOmkTc`tcYq>)5# zHWM_}=Zkz*1(=Q!wg!_WtV;3BRi1moFoE+DeJ5lKRusX42fNs50`FEUpiK?%XY+|? zoQN@i$n3W$1EP9>$%v@zD^~?4-IIx~LCLROpWs?~e4nivPV%nky+6U_6qAsPXO6xF zWGZ!F6&P*2{6%&M4b1}}U{gmtX7=X%Ga)>N%A*P(#;@?XAR$YlPRLM)IpHe!+;LC2 z;RF}qf}*5oyf;CEi@>+l!Qm-gP>r6xAAk#6Py_PxBvq5Hs>h6&R zAms%hSmeG+JaZcA(y%3D*o||&#loFYAg^R5rU|qjKNF3&q5g{Fo@gZAsu)1aX-J(2 z#%1Qt{AM#`iLGvjFkHO&5VX8B9>)?1y|yIsiZP+8>^@-gW}-n15TLoNYB@< z5fEcn>fpB!CdMwUy7U4N!vcjLOU#hx1qfl-6;ueWh?FG$kMMVGaKX$PwCW;q02p18 z3R2CHrlOAlkAS;)vU&bAN-|U^DgwUQ0dr~VVC0epN>`GmRnm2-h05m&k`V(uk`bgP z4XN;@6S)(c+arP0K#mX)F-i#syJH8@BYjdNHO=TdtBt zaLhYqOm-Nv0A95^m|J z`SL$4>_V<2dx4*T0_xpt0r3Govo%E8$<K2`iX}#j z$ghA6{$R~c)6a9(Kqp_=-Jz-pb_9B@IDG824#Ry~mBD0Dy;GDxoKY-IN&Jt0o1P-bzpihoOJ8nyby_7! z=V#$&TY@6=HsY~j;CV!%B6KG_Ha$^Y8#Bq`(7NBQ^@4gHPO{?ecUM5dpCfyuhOHTN zTKC^SY{*9+a!o`_Fer{-s}OLXL&fT`Lr(dGNbEM{<1Yy<7;N&zm&Qq#4aW7NY(=oJ zW(!sc;eYtOD7y+oHl(C|3R)-(bP5A_g6q>3^T5`&i(y{{%zX6VH(#`mtk!IS=6Xz6h|f}KP;@AcQ~?!_^fpRYW0)G92S^G&yGS8f_-)-){~MGDsU^9JHY8mPlX%2J|sJ#pYav$MeYlq4*!TKYkH@4J`nPmT>qM z;Z(6+D1-za3SV4YZcW!Mnp+dFmH@9Pw$VOIjOjkQ#ivvS8!!DJdF4gr;JZjh43U-f zR_?Vq-}R^7-4LgSj@1fTUtow-eH;nl<+)+~Ok9p0JF9KFU5+X%}IE_$K`t2(^;VSDW zUF%4d*eXOcG5A_1I>-x_xM&O_p5Y!|s=gQuLBKsSaGqs;9~K{1a6p_C+Z^6}@yHFt zC}xC#LQ%qsVDuBixjC$QN)miE6$O!PQwFkJ>|fTL(%uWhc@2MpsW4_c59J`I{CV0k65gz8tqg2r#sx7!BZmz)`2itE zo*$y7UIfK96CmBn_ODL0escXSJe<9(>HpT+nwrsP@qI;NY3qYsy2J0!h>*>*pEfwx zy2)8jKm7)2>Pi?oOg8Q2{=;qs$GN%`wOo7bwMMqO{^Z);S^H?6-&xAz4i-?C?l?@$ zzs;JQ!`PUnTOBu#jbo}bLOaPGk%&j@jAz8IDF0RM7{51D{poqd$iCe>7CFO-((*31 z<#UDd0%tm`!t^=sxxkm#tPSt++ig^Br)uAl>v`b@3q?t^%5;Ud#01Ax$LZ6~)>JCm zgkhuVAu8K`g10n!I%*>J=Tf>pqv;HDqMnQbj6ib}3LA;Ja zj2Eg8jg`?zadJ5YO+5|0IZgJ!}V6)|LJ<_nLF zY}0g+oP4n{lBRJXkKC#*c#U1BwRXtJJr?ndyG|zeuZXmvt+xSV?SsBH&FP?ptP9g$ zXju=K`PRB;H;PiD^i!x!D_QKr_V;cxt}5wp-4<@H{QZDkVY6E$t(Ya1bqVYdHz&n& zne!AADfO(M!q%CHv=UJ}=FiQ`HFaTBCiC!~216Mmo$Gy&%#je@Ila_CyL?)FI~iyn zW-pw*z7Z7jJ}~y>6SO;eME&5Xq^*u&y(cXjX@Qn><3zmXd1vP7!Q3f?oGN1YdUnd6 zC%?}V6dS2pB(9g*d@2Y&mNe&!Z4+nV{4W_2BXN=>2Q|U-oPdZkVe0s_uYTNb79soy z_BpM5C;O5{Ug$XzFU8n^VsyRbdBjVf#En?)9wp|w+2Nt$2Lswzdq$WL=h$S#S(6%T zomt=8mhf9W-6mAiaToe{8=Uay(rT$)&zAR_4xOmZ zy=9rp#V%$zpZlIMY!S;Gy=7S&>ZBq7VZbZB$0`6=N<{|+r7#4=7#bA3XS~#62+_uj zyU25~x9skp7yH?EV(d2Jt4UZlK_2>~=3CVbmIy3!BH7r$kojcft~yCnAT$qEDY0i~ z=Nh9C5jV!&!p*)K`Y2yIz5B_f|A@KmT&p*xHNdMJoaPw=VNbD=q&(EFaJb9PDL-sM zVsvx;fddyIQsyN;Qx5m5F*HVG#Bs8oW%9+Zl9suYEOdQnLSsEkUGL<*R<5nb@56|~ zFUSFW)4`ymzbv;AwcK;%31T=-WXBwrJMAihRK;npGCezwvjZ*yKg4?{VXzP-xU zgj5k|r5h6A#hjYEt@hjA_-w<=En}Ms#oPnkKho=179OlEh6yu<-w_mCI-0iU8|dV^ z_yg*N>Qifk{p2bEHFM?xw|sjmfv+OwQz_XeLn zDeHNcV`MEb9!Mis7-ixTA`0He4iRFjUYQM4O`#PEZwCxMs>rVOZk77F=8oDiRD>>; z^{`y~OFS-H756O~q9lvWLbYfTE?ne)@sNHa%ckgP`N2j)z#)9(2>>j?x1G_VwKPw!WY4hg70qs483-ay|&sGQc5XQ z8|FDUWv9Z?d72R6=C?`k0^8~g#(j$Wj~RJA{phPC%l_dV_&=55#8jfIZgQAWnA`|-8?5OiUAE8qL+E3o9ht?DLdqYiBk zqt$C53v(|DP^JQFK^Y<>RgO*mcr>i3OTc}|5_)IPQ5+eV!y8+;sK(Xta%Z5WTY<$1+R$pO80 zdys%YwCvZcwBEmHftVz#d=UgAp9yS;Jo#E?ocN}2hEOGWdH+=~>c!7TbZ(ra!4lv1 zgy6z>c9hucMVnJuXRqT`;u?AVkowu{5qqQeES`Xezplr#_q+_weG4y4410~m`049d zEu1_(7ld&eII7ehn;WhF93x?rm39%O{n z!|&|?iZz&aQf_VJmDK6o#!KpP_MvebHWeitmWX^-FPjh#LeV{2{9fd5tbKI(bM%{0 zzg2wu_@_*dW)2-hCmXKE60Ks~-@?RNos<8HK3uPketL_CN+$AJuUzsLpqJf0dYk(t zkSEf6vMiqk_7Tqb0vwK+{bVkijx%X=TSsAYQ)F< zP*Pc7n&A9WET%d{UJ$)X;;+eh;BUP43u1nhWz(ePrP}Cy+-($fwi@*~d=ur4iRwyB zdFjO>J?Z!U6_uwNHSlKmlh1@aCGUZy#g{A1g*x$Xir~ituLIwq`}o_LqB2(om7YcI zdmEIzK?`+wH8MEdN1DW%BGj#Od%SI22}MP4k27wzcp8E8*9F`lXu|>!NA6*`5wO-^2!t$ z^?Uz6ArR~5_@8beYE{23<898#>xPjM-xMnmNMxXDX}XkD%p4_L_wYGK{X)7F*txHcIVS`?Z&;vZM^2Hob9 z;VtKiAvWOaB%;q%Nf{h{<#P!0R661;^z64Vn9(mk{^zM$YmV8ZN*fN5U*{YA8^ryj z`+8@#+vy9Ce9P_Pu6bA8;%5&MI~sNP`>1O0{emC&&M5i6Y_yQCi7aR399Z~V-Cd>{ zJ&|N{eoWgTed~UbOu^ai29#e(!(AXD+im$G|Kmkr2^A3fXG z-b59E$JY|#NT#y~RS>>1Dh6j3Z2q+fzFU>ye&f|8Mc#sbZ z+EH|gZ=R0{KWkIu^&3jzO$@J8B}Tc*G}HiC;AHmHh-mqojo)PoDU!cIuSsjDA&X#P zHblO4&AWx^*X6yfAJf8@?z#5T`sb0OIsbgOALlnMUe&vT|Rc%nwZS_ioZT zy6iK8c#-L`nR&hLv{qyAu^RIG*yvFZx@y<0&(*<|gvJMC37(b{68ioWr6H>`Di1=& z$s>DAsg1p4%meo{xan_kIji!y*|f0&Z=2L|F~{@lw%o|6+hbhGb_(41E?{C7NdH+6 z){2~iWItb=iZ74%t7@sT*jW2ex~j+Na9mUmh1-p`WTG)m9*B#!q>+6qxBB^zu{C03 z?J}7jr;)mL_v{DfyGFT^?A{IHoGLV6P`u=NeA35HWTW$FA@j<1)sdXGxz&JJTQc+Y zAu`%}o{Fyvh6%f2{`yt)PH>%}XO>OSIX!EZ@bkxaI<}(?Zib6I#LP1IPm(#`gWNFt z(%{$#9PM;m9i3E0-H=3n9}KqbB2&3P&OL+E zn0BL6q+b2$h6pgf;TaCXO$<3LH~s;dH-9O zEIac8b#1J7bRfT2V3Hj79!R7OEeZ@5RV!pxs=xGPF@|lvKuvjX7i3u*q%$~r6X&#X zuiqU1(=+{6P(EB*B=J7ZY(3bP5+k=;fcsp0cGdT-+LM0gb4Ea0T3hBpb|@wsh#EP>>W0NXtIX=HYdisUl`>A4SEch3qx8CJh&g_*yDx6W4l_vcWsieD zRa=KiHOF0m`-RcI4#FxbLp}zo$~~m1)zm-kU%l9IbqEtNYM2dip)m)V_#x}hHbD0r zXd6L+B_lZ?SM8bsd3V@HU#~1U=5NAJ4$N_+z4ETsvk54&gN4@+c^TVrdqQ5(Ov4u! z<@T9&rA%}nv&*~6Nl8)TZO|#?Q5DGj+9b^;R=u#*ofcCJ2{1)+=$>h)hhrEd)P#|- z{|0q`HVTJ)Eo-bD_gNx6kG+B0Gj-oSRSZHq`s7YKdwnyi#BF*u>TOX&ymY(ua=2Y_`E*Qvk*PXEe+{+EI(uQnwGuz#jh|X#5 zJ=fXVmt$WelkQEDJ!Wn6t|P~Fl>4IRi^u6p5p5p|;Hyt|Nca@cMra6R@*Bh|@-fPh zmHInr&Qmxj9p3pX_BNI53p+@5{sz<^z1q4o`1>ghmDpdsqw@Y1U1YsxNLl&ZjsWtB@`|P!8Y;_) zt>akaWM_KJg#8cl0_aG|x2MSpyuL;7jdJ^sz2v3qAS^D*Iv%164KVtZ$>>ZqhKlFr z!KGQoxkh=%hKq^ghD00AYk1H|vED>N@g{FEF9h_r1Li7lP_CuPSE=SprG<>**$Ux_7KAW}HW*ZG}VY^FQHUxsl zsbp6n+l6leT9wJwIVe9Qt0}bz{_zW$I;KOsiJr|V z_!m%y5v;h3eJB@Sy_$&js!E3s3M_pEGWt$DLkP|(zU8djnIxFs_c&_UAI`+c4eNgL zOOwjEgbqm`lkB(fk3f;Ro=cxy9=PGgK9VEP7zqA&TcuwjLurbdh5z23 zMsKl=8@d?jZ0DodPovwUEF09-E@S@g(~1zX5NYXDf#S@Z)sYCbcU+~!te{mV zjsnO$G78?(*Lx8FofdMVhAG^B?T%^4hBF*xU$6yN&z*m^OqB=QV}5YpLOSmh92Y zJJyMaO)B`n$E(@e$ny9K_?7ogG>$g1}`8tG60UwwvFr1la7{sHX)Rw+HkHIUP=-btCM>AEl= zM5r~VW}~C6wli=Ti!bCiyprx!c2G!81nxFdqx-M6RcQi613?u1|z_=RBuz)G>@^Frj70IJqZo{m=mH@Tn{N&^CLkgdq_c+fiJrP8HmsYr>ioPLx+u7%qm0ut5 zk7PQ)U{2@N-#p0gVP*RNi;3Nzn5^chs==gb7?v2Yq@@?0uH{wvmihD~%Jtj)M8~vQJh+;2XJj ze4q%P>U2jt_$JckiA9Ej1D#{#@$Tph=@;O!_ilJd<#1CGwo^fDhjD!?6-I^-wJIuzJRH5YQ z${nLzK)8Wsode@E%+y}m>=w0X5(5DA&s zq%RxNX9vk#FI&s?;8TxjT#xGo#?7jn2V*_AA4)Co!n|ZkMZvSFs@7Tkms# zGfr;e%*>up=J@kKz+;k18Iys{ngz$}A#!fncEfaG-?+6oU+o;M%)CbY!OCtmD02jZ z(;$qtm2#;Mk>`2kA-ulna5k<4mN71Y{S;RQWZJ)#y#lp8To!B7SN6c1cx1f(Au+b#tHb%7-@f@wicjyBQzrXRc?E?&3 z+r79-lrR#K`yb$|sF{dLv?iyEHSh((y&}l!eKd~Y!_g)_s*~)y>)D~am}8BAKYO2O zH^G;Uo=og|k|e6$P1bnXvy1~E^qoeA5aF9ONBojC?{G06U1;a-k@m!qDX}5tGv9*F zs5oE_LX)~i7gmU~Z|9`0{z-ldm(nqv-A6}jxa?)3s|;_QHV=8oMv-y{v3Yf`oYr|! zgib1@zQWak!7uaRq~O!fGoyMCEymfK{!pxEs`h58IQlI-Uz&ani3l7Hns{o{{k?E; zvnlIRU2Kc3f0+7zudT$4k$3e6Ka0f4Rpfl$V;HN=+(}p4m6dO+$=odrVG6~hKKwW| znK({w-Swa}ehq1cOViml-z$U9E25!v^&I21Cr`Np3SXu_@^2|bZ#hS;338Bvo8ijY zp1Q+iD&3XtR|JyH;nAdby)~5h?iyHM1bT^DGR`O?O(IZ1i zhRZ5n1xUYYE$~kH|Iq`H=^Scnz`3?*jE2@M-LDUOrq`<;!!7r-p>4|qS@Wg6Pet$@brbLFr4|5~ zZier%$H2i)8aLB@oYU7I`yJOEl@^YS%SX)3smE?=oSdjWN*I%Y8QDbMKMmAVjun-4 z&D(LEdm&Dwt0GlNS?-uEnU}mpRBpU)m2Hoa(*xx9xX@ewGaunsJ8(w%Xj=w!X+ssr z4dT(#bGauC8*^`9oW`?n(HBmI!0Q^}hpJVLtqvFvZN@JqXdq}-8=ujfN^1FKafh=8 zm5=g|zIcot4g_{}CGMwB<8|jCFO*7Hk$Wcw8kXM{z4CAM4^v(Q&$4|N))kOH z=qgcL>+P*obd`+tj3f8H1LkLKldg5XF}6~PI*4OdO!mo+0&&*bjg3d=M>fLo(96b@ z(fDgO?|82@;xyC(E^VODRn*U~2{2)M+Ub79y@$uWcqdW5MxZN>?o=xH+3?LW7Fv!? zVQ@bO9|=`OaTx4Ekrt^NgR*>;D9TZFQ6@*rhf^$2P7cyYI_OjHgrT_f6VA85DYMDD zywK=f;Wj?%$s?!=c_TEZKJ(CjGfzo87p0A4HBoD4GS-+R?+_m8Fn|oY@1mjgm!6#a zb<$%-3Yh+8rlduavK(lHf3H{uPhUam)yzF~7g4G0^hNQ~w<6G6I|QZa-P7MeLH?u{ zA2$)sK8kxeB`V1&wJ70O5HCHE7dVn54rgP2SUQT>zLWAV=|kdAHEoA=#V}Zx2OG2r0 zgSgwt55gjyf$ow5w-oV@fS+kLX|;94F26f>`sbAcW~CCh&y{xCXYC$HQ(h3^FzdZQ z!>Sd+G_jCZ;cgmAf3&`(kxUh<>LWVke)1KFXm#fscnt;xUpVxr4EqChOTRrW{} zIDoe-(DUp9PqqWjOy-L;ZZz|w+^u4J1AU|4+XWGEoUMZ~kz?`bnyi3Vg6Vp~ZnQ?f z?=7-xz;TMl;tfoSv*Gi>xcOH&P|S8FB@C!A1JKxM^=UF*IlM9nzVX}xs9jVL8}w+F zOU3$(j&|>%S1HzHgSsxO^FAez87qzumlLhU{Q1VfolcUTwr3k~_$t>%Y&g1wKkU zQ*CSZ6?yKjI1++Whkt3*fC0r!xcJJCDBw$9nYCBjilEcT9<#U4nkS*RXj#{KsyNU2 z$HBWzQ@WUnG}@&piSU2}pA64ozSGoxUTpM+SHJnPvo=r2iihK5)~lRdqu}8Aq}_QV zUPGRCD8J`lwtX+HoDqAg1IvZ^*XH1xMvc|4JWD%{+thJJoQ5kuCiiD-btvTbkhzfi g*v{9eWUW7C^_pDk0Vbw8CqE@=-_*ZRs)-H#Kj^E?-2eap literal 0 HcmV?d00001 diff --git a/plugins/mariadb/index.html b/plugins/mariadb/index.html new file mode 100755 index 000000000..80a73bb58 --- /dev/null +++ b/plugins/mariadb/index.html @@ -0,0 +1,60 @@ +
+
+
+
+ +

服务

+

自启动

+

配置文件

+

存储位置

+

端口

+

当前状态

+

性能优化

+

日志

+

慢日志

+

管理列表

+
+
+
+
+
+ +
+ + + + \ No newline at end of file diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py new file mode 100755 index 000000000..a7bb60bf8 --- /dev/null +++ b/plugins/mariadb/index.py @@ -0,0 +1,2035 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import subprocess +import re +import json + + +# reload(sys) +# sys.setdefaultencoding('utf-8') + +sys.path.append(os.getcwd() + "/class/core") +import mw + + +if mw.isAppleSystem(): + cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' + info = mw.execShell(cmd) + p = "/usr/local/lib/" + info[0].strip() + "/site-packages" + sys.path.append(p) + + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'mariadb' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + +sys.path.append(getPluginDir() + "/class") +import mysqlDb + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + if app_debug: + return '/tmp/' + getPluginName() + return '/etc/init.d/' + getPluginName() + + +def is_number(s): + try: + float(s) + return True + except ValueError: + pass + + try: + import unicodedata + unicodedata.numeric(s) + return True + except (TypeError, ValueError): + pass + + return False + + +def getArgs(): + args = sys.argv[2:] + + # print(args) + + # if is_number(args): + # args = sys.argv[3:] + + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':') + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':') + tmp[t[0]] = t[1] + + return tmp + + +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, mw.returnJson(True, 'ok')) + + +def getConf(): + path = getServerDir() + '/etc/my.cnf' + return path + + +def getInitdTpl(version=''): + path = getPluginDir() + '/init.d/mysql' + version + '.tpl' + if not os.path.exists(path): + path = getPluginDir() + '/init.d/mysql.tpl' + return path + + +def contentReplace(content): + service_path = mw.getServerDir() + if content.find('{$ROOT_PATH}') != -1: + content = content.replace('{$ROOT_PATH}', mw.getRootDir()) + + if content.find('{$SERVER_PATH}') != -1: + content = content.replace('{$SERVER_PATH}', service_path) + + if content.find('{$SERVER_APP_PATH}') != -1: + content = content.replace( + '{$SERVER_APP_PATH}', service_path + '/mysql') + return content + + +def pSqliteDb(dbname='databases'): + file = getServerDir() + '/mysql.db' + name = 'mysql' + if not os.path.exists(file): + conn = mw.M(dbname).dbPos(getServerDir(), name) + csql = mw.readFile(getPluginDir() + '/conf/mysql.sql') + csql_list = csql.split(';') + for index in range(len(csql_list)): + conn.execute(csql_list[index], ()) + else: + # 现有run + # conn = mw.M(dbname).dbPos(getServerDir(), name) + # csql = mw.readFile(getPluginDir() + '/conf/mysql.sql') + # csql_list = csql.split(';') + # for index in range(len(csql_list)): + # conn.execute(csql_list[index], ()) + conn = mw.M(dbname).dbPos(getServerDir(), name) + return conn + + +def pMysqlDb(): + db = mysqlDb.mysqlDb() + db.__DB_CNF = getConf() + db.setDbConf(getConf()) + db.setPwd(pSqliteDb('config').where( + 'id=?', (1,)).getField('mysql_root')) + return db + + +def initDreplace(version=''): + initd_tpl = getInitdTpl(version) + + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + + file_bin = initD_path + '/' + getPluginName() + if not os.path.exists(file_bin): + content = mw.readFile(initd_tpl) + content = contentReplace(content) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + mysql_conf_dir = getServerDir() + '/etc' + if not os.path.exists(mysql_conf_dir): + os.mkdir(mysql_conf_dir) + + mysql_tmp = getServerDir() + '/tmp' + if not os.path.exists(mysql_tmp): + os.mkdir(mysql_tmp) + mw.execShell("chown -R mysql:mysql " + mysql_tmp) + + mysql_conf = mysql_conf_dir + '/my.cnf' + if not os.path.exists(mysql_conf): + mysql_conf_tpl = getPluginDir() + '/conf/my' + version + '.cnf' + content = mw.readFile(mysql_conf_tpl) + content = contentReplace(content) + mw.writeFile(mysql_conf, content) + + # systemd + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/mysql.service' + systemServiceTpl = getPluginDir() + '/init.d/mysql.service.tpl' + if os.path.exists(systemDir) and not os.path.exists(systemService): + service_path = mw.getServerDir() + se_content = mw.readFile(systemServiceTpl) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + if mw.getOs() != 'darwin': + mw.execShell('chown -R mysql mysql ' + getServerDir()) + return file_bin + + +def status(version=''): + data = mw.execShell( + "ps -ef|grep mysqld |grep -v grep | grep -v python | awk '{print $2}'") + if data[0] == '': + return 'stop' + + pid = getPidFile() + if not os.path.exists(pid): + return 'stop' + + return 'start' + + +def getDataDir(): + file = getConf() + content = mw.readFile(file) + rep = 'datadir\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getPidFile(): + file = getConf() + content = mw.readFile(file) + rep = 'pid-file\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def binLog(): + args = getArgs() + conf = getConf() + con = mw.readFile(conf) + + if con.find('#log-bin=mysql-bin') != -1: + if 'status' in args: + return mw.returnJson(False, '0') + con = con.replace('#log-bin=mysql-bin', 'log-bin=mysql-bin') + con = con.replace('#binlog_format=mixed', 'binlog_format=mixed') + mw.execShell('sync') + restart() + else: + path = getDataDir() + if 'status' in args: + dsize = 0 + for n in os.listdir(path): + if len(n) < 9: + continue + if n[0:9] == 'mysql-bin': + dsize += os.path.getsize(path + '/' + n) + return mw.returnJson(True, dsize) + con = con.replace('log-bin=mysql-bin', '#log-bin=mysql-bin') + con = con.replace('binlog_format=mixed', '#binlog_format=mixed') + mw.execShell('sync') + restart() + mw.execShell('rm -f ' + path + '/mysql-bin.*') + + mw.writeFile(conf, con) + return mw.returnJson(True, '设置成功!') + + +def setSkipGrantTables(v): + ''' + 设置是否密码验证 + ''' + conf = getConf() + con = mw.readFile(conf) + if v: + if con.find('#skip-grant-tables') != -1: + con = con.replace('#skip-grant-tables', 'skip-grant-tables') + else: + con = con.replace('skip-grant-tables', '#skip-grant-tables') + mw.writeFile(conf, con) + return True + + +def getErrorLog(): + args = getArgs() + path = getDataDir() + filename = '' + for n in os.listdir(path): + if len(n) < 5: + continue + if n == 'error.log': + filename = path + '/' + n + break + # print filename + if not os.path.exists(filename): + return mw.returnJson(False, '指定文件不存在!') + if 'close' in args: + mw.writeFile(filename, '') + return mw.returnJson(False, '日志已清空') + info = mw.getNumLines(filename, 18) + return mw.returnJson(True, 'OK', info) + + +def getShowLogFile(): + file = getConf() + content = mw.readFile(file) + rep = 'slow-query-log-file\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def pGetDbUser(): + if mw.isAppleSystem(): + user = mw.execShell( + "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + return user + return 'mysql' + + +def initMysqlData(): + datadir = getDataDir() + if not os.path.exists(datadir + '/mysql'): + serverdir = getServerDir() + myconf = serverdir + "/etc/my.cnf" + user = pGetDbUser() + cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --defaults-file=' + myconf + mw.execShell(cmd) + return False + return True + + +def initMysql57Data(): + datadir = getDataDir() + if not os.path.exists(datadir + '/mysql'): + serverdir = getServerDir() + myconf = serverdir + "/etc/my.cnf" + user = pGetDbUser() + cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ + ' --initialize-insecure --explicit_defaults_for_timestamp' + # print(mw.execShell(cmd)) + + return False + return True + + +def initMysql8Data(): + datadir = getDataDir() + if not os.path.exists(datadir + '/mysql'): + serverdir = getServerDir() + user = pGetDbUser() + # cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ + # datadir + ' --initialize' + + cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ + datadir + ' --initialize-insecure' + + # print(cmd) + mw.execShell(cmd) + return False + return True + + +def initMysqlPwd(): + time.sleep(5) + + serverdir = getServerDir() + pwd = mw.getRandomString(16) + # cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd + + # cmd_pass = "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'127.0.0.1')" + # cmd_pass = cmd_pass + \ + # "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'localhost')" + # cmd_pass = cmd_pass + \ + # "UPDATE mysql.user SET password=PASSWORD('" + \ + # pwd + "') WHERE user='root'" + cmd_pass = serverdir + '/bin/mysql -uroot -e' + cmd_pass = cmd_pass + "\"UPDATE mysql.user SET password=PASSWORD('" + \ + pwd + "') WHERE user='root';" + cmd_pass = cmd_pass + "flush privileges;\"" + data = mw.execShell(cmd_pass) + # print(data) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) + return True + + +def initMysql8Pwd(): + time.sleep(2) + + serverdir = getServerDir() + pwd = mw.getRandomString(16) + + alter_root_pwd = 'flush privileges;' + alter_root_pwd = alter_root_pwd + \ + "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" + alter_root_pwd = alter_root_pwd + \ + "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" + alter_root_pwd = alter_root_pwd + "flush privileges;" + + # cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' + # data = mw.execShell(cmd_pass) + # print(data) + + tmp_file = "/tmp/mysql_init_tmp.log" + mw.writeFile(tmp_file, alter_root_pwd) + cmd_pass = serverdir + '/bin/mysql -uroot -p < ' + tmp_file + + data = mw.execShell(cmd_pass) + # print(data) + os.remove(tmp_file) + + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) + + return True + + +def myOp(version, method): + # import commands + init_file = initDreplace() + try: + isInited = initMysqlData() + if not isInited: + mw.execShell('systemctl start mysql') + initMysqlPwd() + mw.execShell('systemctl stop mysql') + + mw.execShell('systemctl ' + method + ' mysql') + return 'ok' + except Exception as e: + return str(e) + + +def my8cmd(version, method): + # mysql 8.0 and 5.7 + init_file = initDreplace(version) + cmd = init_file + ' ' + method + try: + if version == '5.7': + isInited = initMysql57Data() + elif version == '8.0': + isInited = initMysql8Data() + + if not isInited: + + if mw.isAppleSystem(): + cmd_init_start = init_file + ' start' + subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + + time.sleep(6) + else: + mw.execShell('systemctl start mysql') + + initMysql8Pwd() + + if mw.isAppleSystem(): + cmd_init_stop = init_file + ' stop' + subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + time.sleep(3) + else: + mw.execShell('systemctl stop mysql') + + if mw.isAppleSystem(): + sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + sub.wait(5) + else: + mw.execShell('systemctl ' + method + ' mysql') + return 'ok' + except Exception as e: + return str(e) + + +def appCMD(version, action): + if version == '8.0' or version == '5.7': + return my8cmd(version, action) + return myOp(version, action) + + +def start(version=''): + return appCMD(version, 'start') + + +def stop(version=''): + return appCMD(version, 'stop') + + +def restart(version=''): + return appCMD(version, 'restart') + + +def reload(version=''): + return appCMD(version, 'reload') + + +def initdStatus(): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + shell_cmd = 'systemctl status mysql | grep loaded | grep "enabled;"' + data = mw.execShell(shell_cmd) + if data[0] == '': + return 'fail' + return 'ok' + + +def initdInstall(): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl enable mysql') + return 'ok' + + +def initdUinstall(): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl disable mysql') + return 'ok' + + +def getMyDbPos(): + file = getConf() + content = mw.readFile(file) + rep = 'datadir\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def setMyDbPos(): + args = getArgs() + data = checkArgs(args, ['datadir']) + if not data[0]: + return data[1] + + s_datadir = getMyDbPos() + t_datadir = args['datadir'] + if t_datadir == s_datadir: + return mw.returnJson(False, '与当前存储目录相同,无法迁移文件!') + + if not os.path.exists(t_datadir): + mw.execShell('mkdir -p ' + t_datadir) + + # mw.execShell('/etc/init.d/mysqld stop') + stop() + mw.execShell('cp -rf ' + s_datadir + '/* ' + t_datadir + '/') + mw.execShell('chown -R mysql mysql ' + t_datadir) + mw.execShell('chmod -R 755 ' + t_datadir) + mw.execShell('rm -f ' + t_datadir + '/*.pid') + mw.execShell('rm -f ' + t_datadir + '/*.err') + + path = getServerDir() + myfile = path + '/etc/my.cnf' + mycnf = mw.readFile(myfile) + mw.writeFile(path + '/etc/my_backup.cnf', mycnf) + + mycnf = mycnf.replace(s_datadir, t_datadir) + mw.writeFile(myfile, mycnf) + start() + + result = mw.execShell( + 'ps aux|grep mysqld| grep -v grep|grep -v python') + if len(result[0]) > 10: + mw.writeFile('data/datadir.pl', t_datadir) + return mw.returnJson(True, '存储目录迁移成功!') + else: + mw.execShell('pkill -9 mysqld') + mw.writeFile(myfile, mw.readFile(path + '/etc/my_backup.cnf')) + start() + return mw.returnJson(False, '文件迁移失败!') + + +def getMyPort(): + file = getConf() + content = mw.readFile(file) + rep = 'port\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def setMyPort(): + args = getArgs() + data = checkArgs(args, ['port']) + if not data[0]: + return data[1] + + port = args['port'] + file = getConf() + content = mw.readFile(file) + rep = "port\s*=\s*([0-9]+)\s*\n" + content = re.sub(rep, 'port = ' + port + '\n', content) + mw.writeFile(file, content) + restart() + return mw.returnJson(True, '编辑成功!') + + +def runInfo(): + + if status(version) == 'stop': + return mw.returnJson(False, 'MySQL未启动', []) + + db = pMysqlDb() + data = db.query('show global status') + gets = ['Max_used_connections', 'Com_commit', 'Com_rollback', 'Questions', 'Innodb_buffer_pool_reads', 'Innodb_buffer_pool_read_requests', 'Key_reads', 'Key_read_requests', 'Key_writes', + 'Key_write_requests', 'Qcache_hits', 'Qcache_inserts', 'Bytes_received', 'Bytes_sent', 'Aborted_clients', 'Aborted_connects', + 'Created_tmp_disk_tables', 'Created_tmp_tables', 'Innodb_buffer_pool_pages_dirty', 'Opened_files', 'Open_tables', 'Opened_tables', 'Select_full_join', + 'Select_range_check', 'Sort_merge_passes', 'Table_locks_waited', 'Threads_cached', 'Threads_connected', 'Threads_created', 'Threads_running', 'Connections', 'Uptime'] + + try: + # print data + if data[0] == 1045 or data[0] == 2003: + pwd = db.getPwd() + return mw.returnJson(False, 'mysql password error:' + pwd + '!') + except Exception as e: + pass + + result = {} + + # print(data) + + for d in data: + for g in gets: + if d[0] == g: + result[g] = d[1] + + # print(result, int(result['Uptime'])) + result['Run'] = int(time.time()) - int(result['Uptime']) + tmp = db.query('show master status') + try: + result['File'] = tmp[0][0] + result['Position'] = tmp[0][1] + except: + result['File'] = 'OFF' + result['Position'] = 'OFF' + return mw.getJson(result) + + +def myDbStatus(): + result = {} + db = pMysqlDb() + data = db.query('show variables') + isError = isSqlError(data) + if isError != None: + return isError + + 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'] + result['mem'] = {} + for d in data: + for g in gets: + if d[0] == g: + result['mem'][g] = d[1] + # if result['mem']['query_cache_type'] != 'ON': + # result['mem']['query_cache_size'] = '0' + return mw.getJson(result) + + +def setDbStatus(): + 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'] + emptys = ['max_connections', 'thread_cache_size', 'table_open_cache'] + args = getArgs() + conFile = getConf() + content = mw.readFile(conFile) + n = 0 + for g in gets: + s = 'M' + if n > 5: + s = 'K' + if g in emptys: + s = '' + rep = '\s*' + g + '\s*=\s*\d+(M|K|k|m|G)?\n' + c = g + ' = ' + args[g] + s + '\n' + if content.find(g) != -1: + content = re.sub(rep, '\n' + c, content, 1) + else: + content = content.replace('[mysqld]\n', '[mysqld]\n' + c) + n += 1 + mw.writeFile(conFile, content) + return mw.returnJson(True, '设置成功!') + + +def isSqlError(mysqlMsg): + # 检测数据库执行错误 + mysqlMsg = str(mysqlMsg) + if "MySQLdb" in mysqlMsg: + return mw.returnJson(False, 'MySQLdb组件缺失!
进入SSH命令行输入: pip install mysql-python | pip install mysqlclient==2.0.3') + if "2002," in mysqlMsg: + return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') + if "2003," in mysqlMsg: + return mw.returnJson(False, "Can't connect to MySQL server on '127.0.0.1' (61)") + if "using password:" in mysqlMsg: + return mw.returnJson(False, '数据库管理密码错误!') + if "Connection refused" in mysqlMsg: + return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') + if "1133" in mysqlMsg: + return mw.returnJson(False, '数据库用户不存在!') + if "1007" in mysqlMsg: + return mw.returnJson(False, '数据库已经存在!') + return None + + +def mapToList(map_obj): + # map to list + try: + if type(map_obj) != list and type(map_obj) != str: + map_obj = list(map_obj) + return map_obj + except: + return [] + + +def __createUser(dbname, username, password, address): + pdb = pMysqlDb() + + if username == 'root': + dbname = '*' + + pdb.execute( + "CREATE USER `%s`@`localhost` IDENTIFIED BY '%s'" % (username, password)) + pdb.execute( + "grant all privileges on %s.* to `%s`@`localhost`" % (dbname, username)) + for a in address.split(','): + pdb.execute( + "CREATE USER `%s`@`%s` IDENTIFIED BY '%s'" % (username, a, password)) + pdb.execute( + "grant all privileges on %s.* to `%s`@`%s`" % (dbname, username, a)) + pdb.execute("flush privileges") + + +def getDbBackupListFunc(dbname=''): + bkDir = mw.getRootDir() + '/backup/database' + blist = os.listdir(bkDir) + r = [] + + bname = 'db_' + dbname + blen = len(bname) + for x in blist: + fbstr = x[0:blen] + if fbstr == bname: + r.append(x) + return r + + +def setDbBackup(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + scDir = mw.getRunDir() + '/scripts/backup.py' + + cmd = 'python ' + scDir + ' database ' + args['name'] + ' 3' + os.system(cmd) + return mw.returnJson(True, 'ok') + + +def importDbBackup(): + args = getArgs() + data = checkArgs(args, ['file', 'name']) + if not data[0]: + return data[1] + + file = args['file'] + name = args['name'] + + file_path = mw.getRootDir() + '/backup/database/' + file + file_path_sql = mw.getRootDir() + '/backup/database/' + file.replace('.gz', '') + + if not os.path.exists(file_path_sql): + cmd = 'cd ' + mw.getRootDir() + '/backup/database && gzip -d ' + file + mw.execShell(cmd) + + pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') + + mysql_cmd = mw.getRootDir() + '/server/mysql/bin/mysql -uroot -p' + pwd + \ + ' ' + name + ' < ' + file_path_sql + + # print(mysql_cmd) + os.system(mysql_cmd) + return mw.returnJson(True, 'ok') + + +def deleteDbBackup(): + args = getArgs() + data = checkArgs(args, ['filename']) + if not data[0]: + return data[1] + + bkDir = mw.getRootDir() + '/backup/database' + + os.remove(bkDir + '/' + args['filename']) + return mw.returnJson(True, 'ok') + + +def getDbBackupList(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + r = getDbBackupListFunc(args['name']) + bkDir = mw.getRootDir() + '/backup/database' + rr = [] + for x in range(0, len(r)): + p = bkDir + '/' + r[x] + data = {} + data['name'] = r[x] + + rsize = os.path.getsize(p) + data['size'] = mw.toSize(rsize) + + t = os.path.getctime(p) + t = time.localtime(t) + + data['time'] = time.strftime('%Y-%m-%d %H:%M:%S', t) + rr.append(data) + + data['file'] = p + + return mw.returnJson(True, 'ok', rr) + + +def getDbList(): + args = getArgs() + page = 1 + page_size = 10 + search = '' + data = {} + if 'page' in args: + page = int(args['page']) + + if 'page_size' in args: + page_size = int(args['page_size']) + + if 'search' in args: + search = args['search'] + + conn = pSqliteDb('databases') + limit = str((page - 1) * page_size) + ',' + str(page_size) + condition = '' + if not search == '': + condition = "name like '%" + search + "%'" + field = 'id,pid,name,username,password,accept,ps,addtime' + clist = conn.where(condition, ()).field( + field).limit(limit).order('id desc').select() + + for x in range(0, len(clist)): + dbname = clist[x]['name'] + blist = getDbBackupListFunc(dbname) + # print(blist) + clist[x]['is_backup'] = False + if len(blist) > 0: + clist[x]['is_backup'] = True + + count = conn.where(condition, ()).count() + _page = {} + _page['count'] = count + _page['p'] = page + _page['row'] = page_size + _page['tojs'] = 'dbList' + data['page'] = mw.getPage(_page) + data['data'] = clist + + info = {} + info['root_pwd'] = pSqliteDb('config').where( + 'id=?', (1,)).getField('mysql_root') + data['info'] = info + + return mw.getJson(data) + + +def syncGetDatabases(): + pdb = pMysqlDb() + psdb = pSqliteDb('databases') + data = pdb.query('show databases') + isError = isSqlError(data) + if isError != None: + return isError + users = pdb.query( + "select User,Host from mysql.user where User!='root' AND Host!='localhost' AND Host!=''") + nameArr = ['information_schema', 'performance_schema', 'mysql', 'sys'] + n = 0 + for value in data: + b = False + for key in nameArr: + if value[0] == key: + b = True + break + if b: + continue + if psdb.where("name=?", (value[0],)).count(): + continue + host = '127.0.0.1' + for user in users: + if value[0] == user[0]: + host = user[1] + break + + ps = mw.getMsg('INPUT_PS') + if value[0] == 'test': + ps = mw.getMsg('DATABASE_TEST') + addTime = time.strftime('%Y-%m-%d %X', time.localtime()) + if psdb.add('name,username,password,accept,ps,addtime', (value[0], value[0], '', host, ps, addTime)): + n += 1 + + msg = mw.getInfo('本次共从服务器获取了{1}个数据库!', (str(n),)) + return mw.returnJson(True, msg) + + +def toDbBase(find): + pdb = pMysqlDb() + psdb = pSqliteDb('databases') + if len(find['password']) < 3: + find['username'] = find['name'] + find['password'] = mw.md5(str(time.time()) + find['name'])[0:10] + psdb.where("id=?", (find['id'],)).save( + 'password,username', (find['password'], find['username'])) + + result = pdb.execute("create database `" + find['name'] + "`") + if "using password:" in str(result): + return -1 + if "Connection refused" in str(result): + return -1 + + password = find['password'] + __createUser(find['name'], find['username'], password, find['accept']) + return 1 + + +def syncToDatabases(): + args = getArgs() + data = checkArgs(args, ['type', 'ids']) + if not data[0]: + return data[1] + + pdb = pMysqlDb() + result = pdb.execute("show databases") + isError = isSqlError(result) + if isError: + return isError + + stype = int(args['type']) + psdb = pSqliteDb('databases') + n = 0 + + if stype == 0: + data = psdb.field('id,name,username,password,accept').select() + for value in data: + result = toDbBase(value) + if result == 1: + n += 1 + else: + data = json.loads(args['ids']) + for value in data: + find = psdb.where("id=?", (value,)).field( + 'id,name,username,password,accept').find() + # print find + result = toDbBase(find) + if result == 1: + n += 1 + msg = mw.getInfo('本次共同步了{1}个数据库!', (str(n),)) + return mw.returnJson(True, msg) + + +def setRootPwd(): + args = getArgs() + data = checkArgs(args, ['password']) + if not data[0]: + return data[1] + + password = args['password'] + try: + pdb = pMysqlDb() + result = pdb.query("show databases") + isError = isSqlError(result) + if isError != None: + return isError + + m_version = mw.readFile(getServerDir() + '/version.pl') + if m_version.find('5.7') == 0 or m_version.find('8.0') == 0: + pdb.execute( + "UPDATE mysql.user SET authentication_string='' WHERE user='root'") + pdb.execute( + "ALTER USER 'root'@'localhost' IDENTIFIED BY '%s'" % password) + pdb.execute( + "ALTER USER 'root'@'127.0.0.1' IDENTIFIED BY '%s'" % password) + else: + result = pdb.execute( + "update mysql.user set Password=password('" + password + "') where User='root'") + pdb.execute("flush privileges") + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (password,)) + return mw.returnJson(True, '数据库root密码修改成功!') + except Exception as ex: + return mw.returnJson(False, '修改错误:' + str(ex)) + + +def setUserPwd(): + args = getArgs() + data = checkArgs(args, ['password', 'name']) + if not data[0]: + return data[1] + + newpassword = args['password'] + username = args['name'] + id = args['id'] + try: + pdb = pMysqlDb() + psdb = pSqliteDb('databases') + name = psdb.where('id=?', (id,)).getField('name') + + m_version = mw.readFile(getServerDir() + '/version.pl') + if m_version.find('5.7') == 0 or m_version.find('8.0') == 0: + tmp = pdb.query( + "select Host from mysql.user where User='" + name + "' AND Host!='localhost'") + accept = mapToList(tmp) + pdb.execute( + "update mysql.user set authentication_string='' where User='" + username + "'") + result = pdb.execute( + "ALTER USER `%s`@`localhost` IDENTIFIED BY '%s'" % (username, newpassword)) + for my_host in accept: + pdb.execute("ALTER USER `%s`@`%s` IDENTIFIED BY '%s'" % ( + username, my_host[0], newpassword)) + else: + result = pdb.execute("update mysql.user set Password=password('" + + newpassword + "') where User='" + username + "'") + isError = isSqlError(result) + if isError != None: + return isError + pdb.execute("flush privileges") + psdb.where("id=?", (id,)).setField('password', newpassword) + return mw.returnJson(True, mw.getInfo('修改数据库[{1}]密码成功!', (name,))) + except Exception as ex: + # print str(ex) + return mw.returnJson(False, mw.getInfo('修改数据库[{1}]密码失败!', (name,))) + + +def setDbPs(): + args = getArgs() + data = checkArgs(args, ['id', 'name', 'ps']) + if not data[0]: + return data[1] + + ps = args['ps'] + sid = args['id'] + name = args['name'] + try: + psdb = pSqliteDb('databases') + psdb.where("id=?", (sid,)).setField('ps', ps) + return mw.returnJson(True, mw.getInfo('修改数据库[{1}]备注成功!', (name,))) + except Exception as e: + return mw.returnJson(True, mw.getInfo('修改数据库[{1}]备注失败!', (name,))) + + +def addDb(): + args = getArgs() + data = checkArgs(args, + ['password', 'name', 'codeing', 'db_user', 'dataAccess', 'ps']) + if not data[0]: + return data[1] + + if not 'address' in args: + address = '' + else: + address = args['address'].strip() + + dbname = args['name'].strip() + dbuser = args['db_user'].strip() + codeing = args['codeing'].strip() + password = args['password'].strip() + dataAccess = args['dataAccess'].strip() + ps = args['ps'].strip() + + reg = "^[\w\.-]+$" + if not re.match(reg, args['name']): + return mw.returnJson(False, '数据库名称不能带有特殊符号!') + checks = ['root', 'mysql', 'test', 'sys', 'panel_logs'] + if dbuser in checks or len(dbuser) < 1: + return mw.returnJson(False, '数据库用户名不合法!') + if dbname in checks or len(dbname) < 1: + return mw.returnJson(False, '数据库名称不合法!') + + if len(password) < 1: + password = mw.md5(time.time())[0:8] + + wheres = { + 'utf8': 'utf8_general_ci', + 'utf8mb4': 'utf8mb4_general_ci', + 'gbk': 'gbk_chinese_ci', + 'big5': 'big5_chinese_ci' + } + codeStr = wheres[codeing] + + pdb = pMysqlDb() + psdb = pSqliteDb('databases') + + if psdb.where("name=? or username=?", (dbname, dbuser)).count(): + return mw.returnJson(False, '数据库已存在!') + + result = pdb.execute("create database `" + dbname + + "` DEFAULT CHARACTER SET " + codeing + " COLLATE " + codeStr) + # print result + isError = isSqlError(result) + if isError != None: + return isError + + pdb.execute("drop user '" + dbuser + "'@'localhost'") + for a in address.split(','): + pdb.execute("drop user '" + dbuser + "'@'" + a + "'") + + __createUser(dbname, dbuser, password, address) + + addTime = time.strftime('%Y-%m-%d %X', time.localtime()) + psdb.add('pid,name,username,password,accept,ps,addtime', + (0, dbname, dbuser, password, address, ps, addTime)) + return mw.returnJson(True, '添加成功!') + + +def delDb(): + args = getArgs() + data = checkArgs(args, ['id', 'name']) + if not data[0]: + return data[1] + try: + id = args['id'] + name = args['name'] + psdb = pSqliteDb('databases') + pdb = pMysqlDb() + find = psdb.where("id=?", (id,)).field( + 'id,pid,name,username,password,accept,ps,addtime').find() + accept = find['accept'] + username = find['username'] + + # 删除MYSQL + result = pdb.execute("drop database `" + name + "`") + isError = isSqlError(result) + if isError != None: + return isError + + users = pdb.query( + "select Host from mysql.user where User='" + username + "' AND Host!='localhost'") + pdb.execute("drop user '" + username + "'@'localhost'") + for us in users: + pdb.execute("drop user '" + username + "'@'" + us[0] + "'") + pdb.execute("flush privileges") + + # 删除SQLITE + psdb.where("id=?", (id,)).delete() + return mw.returnJson(True, '删除成功!') + except Exception as ex: + return mw.returnJson(False, '删除失败!' + str(ex)) + + +def getDbAccess(): + args = getArgs() + data = checkArgs(args, ['username']) + if not data[0]: + return data[1] + username = args['username'] + pdb = pMysqlDb() + + users = pdb.query("select Host from mysql.user where User='" + + username + "' AND Host!='localhost'") + isError = isSqlError(users) + if isError != None: + return isError + + users = mapToList(users) + if len(users) < 1: + return mw.returnJson(True, "127.0.0.1") + accs = [] + for c in users: + accs.append(c[0]) + userStr = ','.join(accs) + return mw.returnJson(True, userStr) + + +def toSize(size): + d = ('b', 'KB', 'MB', 'GB', 'TB') + s = d[0] + for b in d: + if size < 1024: + return str(size) + ' ' + b + size = size / 1024 + s = b + _size = round(size, 2) + # print(size, _size) + return str(size) + ' ' + b + + +def setDbAccess(): + args = getArgs() + data = checkArgs(args, ['username', 'access']) + if not data[0]: + return data[1] + name = args['username'] + access = args['access'] + pdb = pMysqlDb() + psdb = pSqliteDb('databases') + + dbname = psdb.where('username=?', (name,)).getField('name') + + if name == 'root': + password = pSqliteDb('config').where( + 'id=?', (1,)).getField('mysql_root') + else: + password = psdb.where("username=?", (name,)).getField('password') + users = pdb.query("select Host from mysql.user where User='" + + name + "' AND Host!='localhost'") + for us in users: + pdb.execute("drop user '" + name + "'@'" + us[0] + "'") + + __createUser(dbname, name, password, access) + + psdb.where('username=?', (name,)).save('accept', (access,)) + return mw.returnJson(True, '设置成功!') + + +def getDbInfo(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + db_name = args['name'] + pdb = pMysqlDb() + # print 'show tables from `%s`' % db_name + table_res = pdb.query('show tables from `%s`' % db_name) + isError = isSqlError(table_res) + if isError != None: + return isError + + tables = mapToList(table_res) + + ret = {} + if type(tables) == list: + try: + data = mapToList(pdb.query( + "select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables where table_schema='%s'" % db_name))[0][0] + except: + data = 0 + + if not data: + data = 0 + ret['data_size'] = mw.toSize(data) + # print ret + ret['database'] = db_name + + ret3 = [] + + for i in tables: + if i == 1049: + return mw.returnJson(False, '指定数据库不存在!') + table = mapToList( + pdb.query("show table status from `%s` where name = '%s'" % (db_name, i[0]))) + if not table: + continue + try: + ret2 = {} + ret2['type'] = table[0][1] + ret2['rows_count'] = table[0][4] + ret2['collation'] = table[0][14] + data_size = table[0][6] + table[0][8] + ret2['data_byte'] = data_size + ret2['data_size'] = mw.toSize(data_size) + ret2['table_name'] = i[0] + ret3.append(ret2) + except: + continue + ret['tables'] = (ret3) + + return mw.getJson(ret) + + +def repairTable(): + args = getArgs() + data = checkArgs(args, ['db_name', 'tables']) + if not data[0]: + return data[1] + + db_name = args['db_name'] + tables = json.loads(args['tables']) + pdb = pMysqlDb() + mysql_table = mapToList(pdb.query('show tables from `%s`' % db_name)) + ret = [] + if type(mysql_table) == list: + if len(mysql_table) > 0: + for i in mysql_table: + for i2 in tables: + if i2 == i[0]: + ret.append(i2) + if len(ret) > 0: + for i in ret: + pdb.execute('REPAIR TABLE `%s`.`%s`' % (db_name, i)) + return mw.returnJson(True, "修复完成!") + return mw.returnJson(False, "修复失败!") + + +def optTable(): + args = getArgs() + data = checkArgs(args, ['db_name', 'tables']) + if not data[0]: + return data[1] + + db_name = args['db_name'] + tables = json.loads(args['tables']) + pdb = pMysqlDb() + mysql_table = mapToList(pdb.query('show tables from `%s`' % db_name)) + ret = [] + if type(mysql_table) == list: + if len(mysql_table) > 0: + for i in mysql_table: + for i2 in tables: + if i2 == i[0]: + ret.append(i2) + if len(ret) > 0: + for i in ret: + pdb.execute('OPTIMIZE TABLE `%s`.`%s`' % (db_name, i)) + return mw.returnJson(True, "优化成功!") + return mw.returnJson(False, "优化失败或者已经优化过了!") + + +def alterTable(): + args = getArgs() + data = checkArgs(args, ['db_name', 'tables']) + if not data[0]: + return data[1] + + db_name = args['db_name'] + tables = json.loads(args['tables']) + table_type = args['table_type'] + pdb = pMysqlDb() + mysql_table = mapToList(pdb.query('show tables from `%s`' % db_name)) + ret = [] + if type(mysql_table) == list: + if len(mysql_table) > 0: + for i in mysql_table: + for i2 in tables: + if i2 == i[0]: + ret.append(i2) + if len(ret) > 0: + for i in ret: + pdb.execute('alter table `%s`.`%s` ENGINE=`%s`' % + (db_name, i, table_type)) + return mw.returnJson(True, "更改成功!") + return mw.returnJson(False, "更改失败!") + + +def getTotalStatistics(): + st = status() + data = {} + + isInstall = os.path.exists(getServerDir() + '/version.pl') + + if st == 'start' and isInstall: + data['status'] = True + data['count'] = pSqliteDb('databases').count() + data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip() + return mw.returnJson(True, 'ok', data) + else: + data['status'] = False + data['count'] = 0 + return mw.returnJson(False, 'fail', data) + + +def findBinlogDoDb(): + conf = getConf() + con = mw.readFile(conf) + rep = r"binlog-do-db\s*?=\s*?(.*)" + dodb = re.findall(rep, con, re.M) + return dodb + + +def findBinlogSlaveDoDb(): + conf = getConf() + con = mw.readFile(conf) + rep = r"replicate-do-db\s*?=\s*?(.*)" + dodb = re.findall(rep, con, re.M) + return dodb + + +def getMasterDbList(version=''): + args = getArgs() + page = 1 + page_size = 10 + search = '' + data = {} + if 'page' in args: + page = int(args['page']) + + if 'page_size' in args: + page_size = int(args['page_size']) + + if 'search' in args: + search = args['search'] + + conn = pSqliteDb('databases') + limit = str((page - 1) * page_size) + ',' + str(page_size) + condition = '' + dodb = findBinlogDoDb() + data['dodb'] = dodb + + slave_dodb = findBinlogSlaveDoDb() + + if not search == '': + condition = "name like '%" + search + "%'" + field = 'id,pid,name,username,password,accept,ps,addtime' + clist = conn.where(condition, ()).field( + field).limit(limit).order('id desc').select() + count = conn.where(condition, ()).count() + + for x in range(0, len(clist)): + if clist[x]['name'] in dodb: + clist[x]['master'] = 1 + else: + clist[x]['master'] = 0 + + if clist[x]['name'] in slave_dodb: + clist[x]['slave'] = 1 + else: + clist[x]['slave'] = 0 + + _page = {} + _page['count'] = count + _page['p'] = page + _page['row'] = page_size + _page['tojs'] = 'dbList' + data['page'] = mw.getPage(_page) + data['data'] = clist + + return mw.getJson(data) + + +def setDbMaster(version): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + conf = getConf() + con = mw.readFile(conf) + rep = r"(binlog-do-db\s*?=\s*?(.*))" + dodb = re.findall(rep, con, re.M) + + isHas = False + for x in range(0, len(dodb)): + + if dodb[x][1] == args['name']: + isHas = True + + con = con.replace(dodb[x][0] + "\n", '') + mw.writeFile(conf, con) + + if not isHas: + prefix = '#binlog-do-db' + con = con.replace( + prefix, prefix + "\nbinlog-do-db=" + args['name']) + mw.writeFile(conf, con) + + restart(version) + time.sleep(4) + return mw.returnJson(True, '设置成功', [args, dodb]) + + +def setDbSlave(version): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + conf = getConf() + con = mw.readFile(conf) + rep = r"(replicate-do-db\s*?=\s*?(.*))" + dodb = re.findall(rep, con, re.M) + + isHas = False + for x in range(0, len(dodb)): + if dodb[x][1] == args['name']: + isHas = True + + con = con.replace(dodb[x][0] + "\n", '') + mw.writeFile(conf, con) + + if not isHas: + prefix = '#replicate-do-db' + con = con.replace( + prefix, prefix + "\nreplicate-do-db=" + args['name']) + mw.writeFile(conf, con) + + restart(version) + time.sleep(4) + return mw.returnJson(True, '设置成功', [args, dodb]) + + +def getMasterStatus(version=''): + + if status(version) == 'stop': + return mw.returnJson(False, 'MySQL未启动,或正在启动中...!', []) + + conf = getConf() + con = mw.readFile(conf) + master_status = False + if con.find('#log-bin') == -1 and con.find('log-bin') > 1: + dodb = findBinlogDoDb() + if len(dodb) > 0: + master_status = True + data = {} + data['status'] = master_status + + db = pMysqlDb() + dlist = db.query('show slave status') + # print(dlist, len(dlist)) + if len(dlist) > 0 and (dlist[0][10] == 'Yes' or dlist[0][11] == 'Yes'): + data['slave_status'] = True + + return mw.returnJson(master_status, '设置成功', data) + + +def setMasterStatus(version=''): + + conf = getConf() + con = mw.readFile(conf) + + if con.find('#log-bin') != -1: + return mw.returnJson(False, '必须开启二进制日志') + + sign = 'mdserver_ms_open' + + dodb = findBinlogDoDb() + if not sign in dodb: + prefix = '#binlog-do-db' + con = con.replace(prefix, prefix + "\nbinlog-do-db=" + sign) + mw.writeFile(conf, con) + else: + con = con.replace("binlog-do-db=" + sign + "\n", '') + rep = r"(binlog-do-db\s*?=\s*?(.*))" + dodb = re.findall(rep, con, re.M) + for x in range(0, len(dodb)): + con = con.replace(dodb[x][0] + "\n", '') + mw.writeFile(conf, con) + + restart(version) + return mw.returnJson(True, '设置成功') + + +def getMasterRepSlaveList(version=''): + args = getArgs() + page = 1 + page_size = 10 + search = '' + data = {} + if 'page' in args: + page = int(args['page']) + + if 'page_size' in args: + page_size = int(args['page_size']) + + if 'search' in args: + search = args['search'] + + conn = pSqliteDb('master_replication_user') + limit = str((page - 1) * page_size) + ',' + str(page_size) + condition = '' + + if not search == '': + condition = "name like '%" + search + "%'" + field = 'id,username,password,accept,ps,addtime' + clist = conn.where(condition, ()).field( + field).limit(limit).order('id desc').select() + count = conn.where(condition, ()).count() + + _page = {} + _page['count'] = count + _page['p'] = page + _page['row'] = page_size + _page['tojs'] = 'getMasterRepSlaveList' + data['page'] = mw.getPage(_page) + data['data'] = clist + + return mw.getJson(data) + + +def addMasterRepSlaveUser(version=''): + args = getArgs() + data = checkArgs(args, + ['username', 'password']) + if not data[0]: + return data[1] + + if not 'address' in args: + address = '' + else: + address = args['address'].strip() + + username = args['username'].strip() + password = args['password'].strip() + # ps = args['ps'].strip() + # address = args['address'].strip() + # dataAccess = args['dataAccess'].strip() + + reg = "^[\w\.-]+$" + if not re.match(reg, username): + return mw.returnJson(False, '用户名不能带有特殊符号!') + checks = ['root', 'mysql', 'test', 'sys', 'panel_logs'] + if username in checks or len(username) < 1: + return mw.returnJson(False, '用户名不合法!') + if password in checks or len(password) < 1: + return mw.returnJson(False, '密码不合法!') + + if len(password) < 1: + password = mw.md5(time.time())[0:8] + + pdb = pMysqlDb() + psdb = pSqliteDb('master_replication_user') + + if psdb.where("username=?", (username)).count(): + return mw.returnJson(False, '用户已存在!') + + result = pdb.execute("GRANT REPLICATION SLAVE ON *.* TO '" + + username + "'@'%' identified by '" + password + "';FLUSH PRIVILEGES;") + # print result + isError = isSqlError(result) + if isError != None: + return isError + + addTime = time.strftime('%Y-%m-%d %X', time.localtime()) + psdb.add('username,password,accept,ps,addtime', + (username, password, '%', '', addTime)) + return mw.returnJson(True, '添加成功!') + + +def getMasterRepSlaveUserCmd(version): + args = getArgs() + data = checkArgs(args, ['username', 'db']) + if not data[0]: + return data[1] + + psdb = pSqliteDb('master_replication_user') + f = 'username,password' + if args['username'] == '': + + count = psdb.count() + + if count == 0: + return mw.returnJson(False, '请添加同步账户!') + + clist = psdb.field(f).limit('1').order('id desc').select() + else: + clist = psdb.field(f).where("username=?", (args['username'],)).limit( + '1').order('id desc').select() + + ip = mw.getLocalIp() + port = getMyPort() + + db = pMysqlDb() + tmp = db.query('show master status') + + if len(tmp) == 0: + return mw.returnJson(False, '未开启!') + + sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \ + clist[0]['username'] + "', MASTER_PASSWORD='" + \ + clist[0]['password'] + \ + "', MASTER_LOG_FILE='" + tmp[0][0] + \ + "',MASTER_LOG_POS=" + str(tmp[0][1]) + "" + + # if args['db'] != '': + # replicate-do-table + + return mw.returnJson(True, 'OK!', sql) + + +def delMasterRepSlaveUser(version=''): + args = getArgs() + data = checkArgs(args, ['username']) + if not data[0]: + return data[1] + + pdb = pMysqlDb() + psdb = pSqliteDb('master_replication_user') + pdb.execute("drop user '" + args['username'] + "'@'%'") + psdb.where("username=?", (args['username'],)).delete() + + return mw.returnJson(True, '删除成功!') + + +def updateMasterRepSlaveUser(version=''): + args = getArgs() + data = checkArgs(args, ['username', 'password']) + if not data[0]: + return data[1] + + pdb = pMysqlDb() + psdb = pSqliteDb('master_replication_user') + pdb.execute("drop user '" + args['username'] + "'@'%'") + + pdb.execute("GRANT REPLICATION SLAVE ON *.* TO '" + + args['username'] + "'@'%' identified by '" + args['password'] + "'") + + psdb.where("username=?", (args['username'],)).save( + 'password', args['password']) + + return mw.returnJson(True, '更新成功!') + + +def getSlaveList(version=''): + + db = pMysqlDb() + dlist = db.query('show slave status') + + # print(dlist) + ret = [] + for x in range(0, len(dlist)): + tmp = {} + tmp['Master_User'] = dlist[x][2] + tmp['Master_Host'] = dlist[x][1] + tmp['Master_Port'] = dlist[x][3] + tmp['Master_Log_File'] = dlist[x][5] + tmp['Slave_IO_Running'] = dlist[x][10] + tmp['Slave_SQL_Running'] = dlist[x][11] + ret.append(tmp) + data = {} + data['data'] = ret + + return mw.getJson(data) + + +def setSlaveStatus(version=''): + db = pMysqlDb() + dlist = db.query('show slave status') + + if len(dlist) == 0: + return mw.returnJson(False, '需要手动添加主服务同步命令!') + + if len(dlist) > 0 and (dlist[0][10] == 'Yes' or dlist[0][11] == 'Yes'): + db.query('stop slave') + else: + db.query('start slave') + + return mw.returnJson(True, '设置成功!') + + +def deleteSlave(version=''): + db = pMysqlDb() + dlist = db.query('stop slave;reset slave all') + return mw.returnJson(True, '删除成功!') + + +def dumpMysqlData(version): + + args = getArgs() + data = checkArgs(args, ['db']) + if not data[0]: + return data[1] + + pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') + if args['db'] == 'all' or args['db'] == 'ALL': + dlist = findBinlogDoDb() + cmd = getServerDir() + "/bin/mysqldump -uroot -p" + \ + pwd + " --databases " + ' '.join(dlist) + \ + " > /tmp/dump.sql" + else: + cmd = getServerDir() + "/bin/mysqldump -uroot -p" + pwd + \ + " --databases " + args['db'] + " > /tmp/dump.sql" + + ret = mw.execShell(cmd) + + if ret[0] == '': + return 'ok' + return 'fail' + + +from threading import Thread +from time import sleep + + +def mw_async(f): + def wrapper(*args, **kwargs): + thr = Thread(target=f, args=args, kwargs=kwargs) + thr.start() + return wrapper + + +def doFullSync(): + + args = getArgs() + data = checkArgs(args, ['db']) + if not data[0]: + return data[1] + + status_data = {} + status_data['progress'] = 5 + + db = pMysqlDb() + + dlist = db.query('show slave status') + if len(dlist) == 0: + status_data['code'] = -1 + status_data['msg'] = '没有启动...' + + ip = dlist[0][1] + print(ip) + + status_file = '/tmp/db_async_status.txt' + + status_data['code'] = 0 + status_data['msg'] = '运行中...' + mw.writeFile(status_file, json.dumps(status_data)) + + import paramiko + paramiko.util.log_to_file('paramiko.log') + ssh = paramiko.SSHClient() + + SSH_PRIVATE_KEY = '/root/.ssh/id_rsa' + + if mw.getOs() == 'darwin': + user = mw.execShell( + "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + SSH_PRIVATE_KEY = '/Users/' + user + '/.ssh/id_rsa' + + print(SSH_PRIVATE_KEY) + if not os.path.exists(SSH_PRIVATE_KEY): + status_data['code'] = 0 + status_data['msg'] = '需要配置免登录...' + mw.writeFile(status_file, json.dumps(status_data)) + return + + try: + key = paramiko.RSAKey.from_private_key_file(SSH_PRIVATE_KEY) + # ssh.load_system_host_keys() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(hostname=ip, port=22, username='root', pkey=key) + except Exception as e: + status_data['code'] = 0 + status_data['msg'] = '需要配置免登录....' + mw.writeFile(status_file, json.dumps(status_data)) + return + + cmd = "cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py dump_mysql_data {\"db\":'" + args[ + 'db'] + "'}" + stdin, stdout, stderr = ssh.exec_command(cmd) + result = stdout.read() + result_err = stderr.read() + + if result == 'ok': + status_data['code'] = 1 + status_data['msg'] = '主服务器备份完成...' + status_data['progress'] = 30 + mw.writeFile(status_file, json.dumps(status_data)) + + r = mw.execShell('scp root@' + ip + ':/tmp/dump.sql /tmp') + if r[0] == '': + status_data['code'] = 2 + status_data['msg'] = '数据同步本地完成...' + status_data['progress'] = 40 + mw.writeFile(status_file, json.dumps(status_data)) + + cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"","db":""}' + stdin, stdout, stderr = ssh.exec_command(cmd) + result = stdout.read() + result_err = stderr.read() + cmd_data = json.loads(result) + + db.query('stop slave') + status_data['code'] = 3 + status_data['msg'] = '停止从库完成...' + status_data['progress'] = 45 + mw.writeFile(status_file, json.dumps(status_data)) + + dlist = db.query(cmd_data['data']) + status_data['code'] = 4 + status_data['msg'] = '刷新库信息完成...' + status_data['progress'] = 50 + mw.writeFile(status_file, json.dumps(status_data)) + + pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') + cmd = getServerDir() + "/bin/mysql -uroot -p" + pwd + " < /tmp/dump.sql" + print(mw.execShell(cmd)) + status_data['code'] = 5 + status_data['msg'] = '同步数据完成...' + status_data['progress'] = 90 + mw.writeFile(status_file, json.dumps(status_data)) + + db.query('start slave') + status_data['code'] = 6 + status_data['msg'] = '从库重启完成...' + status_data['progress'] = 100 + mw.writeFile(status_file, json.dumps(status_data)) + + return True + + +def fullSync(version=''): + args = getArgs() + data = checkArgs(args, ['db', 'begin']) + if not data[0]: + return data[1] + + status_file = '/tmp/db_async_status.txt' + if args['begin'] == '1': + cmd = 'cd ' + mw.getRunDir() + ' && python ' + \ + getPluginDir() + \ + '/index.py do_full_sync {"db":"' + args['db'] + '"} &' + mw.execShell(cmd) + return json.dumps({'code': 0, 'msg': '同步数据中!', 'progress': 0}) + + if os.path.exists(status_file): + c = mw.readFile(status_file) + d = json.loads(c) + + if d['code'] == 6: + os.remove(status_file) + return c + + return json.dumps({'code': 0, 'msg': '点击开始,开始同步!', 'progress': 0}) + + +def uninstallPreInspection(version): + # return "请手动删除MySQL[{}]".format(version) + return 'ok' + +if __name__ == "__main__": + func = sys.argv[1] + + version = "5.6" + if (len(sys.argv) > 2): + version = sys.argv[2] + + if func == 'status': + print(status(version)) + elif func == 'start': + print(start(version)) + elif func == 'stop': + print(stop(version)) + elif func == 'restart': + print(restart(version)) + elif func == 'reload': + print(reload(version)) + elif func == 'initd_status': + print(initdStatus()) + elif func == 'initd_install': + print(initdInstall()) + elif func == 'initd_uninstall': + print(initdUinstall()) + elif func == 'uninstall_pre_inspection': + print(uninstallPreInspection(version)) + elif func == 'run_info': + print(runInfo()) + elif func == 'db_status': + print(myDbStatus()) + elif func == 'set_db_status': + print(setDbStatus()) + elif func == 'conf': + print(getConf()) + elif func == 'bin_log': + print(binLog()) + elif func == 'error_log': + print(getErrorLog()) + elif func == 'show_log': + print(getShowLogFile()) + elif func == 'my_db_pos': + print(getMyDbPos()) + elif func == 'set_db_pos': + print(setMyDbPos()) + elif func == 'my_port': + print(getMyPort()) + elif func == 'set_my_port': + print(setMyPort()) + elif func == 'init_pwd': + print(initMysqlPwd()) + elif func == 'get_db_list': + print(getDbList()) + elif func == 'set_db_backup': + print(setDbBackup()) + elif func == 'import_db_backup': + print(importDbBackup()) + elif func == 'delete_db_backup': + print(deleteDbBackup()) + elif func == 'get_db_backup_list': + print(getDbBackupList()) + elif func == 'add_db': + print(addDb()) + elif func == 'del_db': + print(delDb()) + elif func == 'sync_get_databases': + print(syncGetDatabases()) + elif func == 'sync_to_databases': + print(syncToDatabases()) + elif func == 'set_root_pwd': + print(setRootPwd()) + elif func == 'set_user_pwd': + print(setUserPwd()) + elif func == 'get_db_access': + print(getDbAccess()) + elif func == 'set_db_access': + print(setDbAccess()) + elif func == 'set_db_ps': + print(setDbPs()) + elif func == 'get_db_info': + print(getDbInfo()) + elif func == 'repair_table': + print(repairTable()) + elif func == 'opt_table': + print(optTable()) + elif func == 'alter_table': + print(alterTable()) + elif func == 'get_total_statistics': + print(getTotalStatistics()) + elif func == 'get_masterdb_list': + print(getMasterDbList(version)) + elif func == 'get_master_status': + print(getMasterStatus(version)) + elif func == 'set_master_status': + print(setMasterStatus(version)) + elif func == 'set_db_master': + print(setDbMaster(version)) + elif func == 'set_db_slave': + print(setDbSlave(version)) + elif func == 'get_master_rep_slave_list': + print(getMasterRepSlaveList(version)) + elif func == 'add_master_rep_slave_user': + print(addMasterRepSlaveUser(version)) + elif func == 'del_master_rep_slave_user': + print(delMasterRepSlaveUser(version)) + elif func == 'update_master_rep_slave_user': + print(updateMasterRepSlaveUser(version)) + elif func == 'get_master_rep_slave_user_cmd': + print(getMasterRepSlaveUserCmd(version)) + elif func == 'get_slave_list': + print(getSlaveList(version)) + elif func == 'set_slave_status': + print(setSlaveStatus(version)) + elif func == 'delete_slave': + print(deleteSlave(version)) + elif func == 'full_sync': + print(fullSync(version)) + elif func == 'do_full_sync': + print(doFullSync()) + elif func == 'dump_mysql_data': + print(dumpMysqlData(version)) + else: + print('error') diff --git a/plugins/mariadb/info.json b/plugins/mariadb/info.json new file mode 100755 index 000000000..65df8cf16 --- /dev/null +++ b/plugins/mariadb/info.json @@ -0,0 +1,18 @@ +{ + "title":"MariaDB", + "tip":"soft", + "name":"mariadb", + "type":"运行环境", + "ps":"[DEV]一种关系数据库管理系统!", + "uninstall_pre_inspection":true, + "checks": "server/mariadb/VERSION/bin/mysql", + "path": "server/mariadb/VERSION", + "versions":["10.6", "5.6", "5.7","8.0"], + "shell":"install.sh", + "checks":"server/mariadb", + "path":"server/mariadb", + "author":"mariadb", + "home":"https://mariadb.com/products/community-server/", + "date":"2022-07-12", + "pid": "2" +} \ No newline at end of file diff --git a/plugins/mariadb/init.d/mysql.service.tpl b/plugins/mariadb/init.d/mysql.service.tpl new file mode 100644 index 000000000..765c61ae0 --- /dev/null +++ b/plugins/mariadb/init.d/mysql.service.tpl @@ -0,0 +1,24 @@ +[Unit] +Description=MySQL Community Server +Documentation=man:mysqld(8) +Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html +After=network.service +After=syslog.target + +[Service] +User=mysql +Group=mysql +Type=simple +ExecStart={$SERVER_PATH}/mariadb/bin/mysqld --defaults-file={$SERVER_PATH}/mariadb/etc/my.cnf +ExecReload=/bin/kill -USR2 $MAINPID +TimeoutSec=0 +PermissionsStartOnly=true +LimitNOFILE=5000 +Restart=on-failure +RestartSec=10 +RestartPreventExitStatus=1 +PrivateTmp=false + + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/plugins/mariadb/init.d/mysql.tpl b/plugins/mariadb/init.d/mysql.tpl new file mode 100644 index 000000000..ef861da5a --- /dev/null +++ b/plugins/mariadb/init.d/mysql.tpl @@ -0,0 +1,383 @@ +#!/bin/sh +# chkconfig: 2345 55 25 +# Description: mysql service +# distro. For CentOS/Redhat run: 'chkconfig --add mysql' + +# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB +# This file is public domain and comes with NO WARRANTY of any kind + +# MySQL daemon start/stop script. + +# Usually this is put in /etc/init.d (at least on machines SYSV R4 based +# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. +# When this is done the mysql server will be started when the machine is +# started and shut down when the systems goes down. + +# Comments to support chkconfig on RedHat Linux +# chkconfig: 2345 64 36 +# description: A very fast and reliable SQL database engine. + +# Comments to support LSB init script conventions +### BEGIN INIT INFO +# Provides: mysql +# Required-Start: $local_fs $network $remote_fs +# Should-Start: ypbind nscd ldap ntpd xntpd +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop MySQL +# Description: MySQL is a very fast and reliable SQL database engine. +### END INIT INFO + +# If you install MySQL on some other places than /www/server/mysql, then you +# have to do one of the following things for this script to work: +# +# - Run this script from within the MySQL installation directory +# - Create a /etc/my.cnf file with the following information: +# [mysqld] +# basedir= +# - Add the above to any other configuration file (for example ~/.my.ini) +# and copy my_print_defaults to /usr/bin +# - Add the path to the mysql-installation-directory to the basedir variable +# below. +# +# If you want to affect other MySQL variables, you should make your changes +# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. + +# If you change base dir, you must also change datadir. These may get +# overwritten by settings in the MySQL configuration files. + +basedir= +datadir= + +# Default value, in seconds, afterwhich the script should timeout waiting +# for server start. +# Value here is overriden by value in my.cnf. +# 0 means don't wait at all +# Negative numbers mean to wait indefinitely +service_startup_timeout=900 + +# Lock directory for RedHat / SuSE. +lockdir='/var/lock/subsys' +lock_file_path="$lockdir/mysql" + +# The following variables are only set for letting mysql.server find things. + +# Set some defaults +mysqld_pid_file_path= +if test -z "$basedir" +then + basedir={$SERVER_APP_PATH} + bindir={$SERVER_APP_PATH}/bin + if test -z "$datadir" + then + datadir={$SERVER_APP_PATH}/data + fi + sbindir={$SERVER_APP_PATH}/bin + libexecdir={$SERVER_APP_PATH}/bin +else + bindir="$basedir/bin" + if test -z "$datadir" + then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" +fi + +# datadir_set is used to determine if datadir was set (and so should be +# *not* set inside of the --basedir= handler.) +datadir_set= + +# +# Use LSB init script functions for printing messages, if possible +# +lsb_functions="/lib/lsb/init-functions" +if test -f $lsb_functions ; then + . $lsb_functions +else + log_success_msg() + { + echo " SUCCESS! $@" + } + log_failure_msg() + { + echo " ERROR! $@" + } +fi + +PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" +export PATH + +mode=$1 # start or stop + +[ $# -ge 1 ] && shift + + +other_args=--sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # uncommon, but needed when called from an RPM upgrade action + # Expected: "--skip-networking --skip-grant-tables" + # They are not checked here, intentionally, as it is the resposibility + # of the "spec" file author to give correct arguments only. + +case `echo "testing\c"`,`echo -n testing` in + *c*,-n*) echo_n= echo_c= ;; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c' ;; +esac + +parse_server_arguments() { + for arg do + case "$arg" in + --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` + bindir="$basedir/bin" + if test -z "$datadir_set"; then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" + ;; + --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` + datadir_set=1 + ;; + --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + esac + done +} + +wait_for_pid () { + verb="$1" # created | removed + pid="$2" # process ID of the program operating on the pid-file + pid_file_path="$3" # path to the PID file. + + i=0 + avoid_race_condition="by checking again" + + while test $i -ne $service_startup_timeout ; do + + case "$verb" in + 'created') + # wait for a PID-file to pop into existence. + test -s "$pid_file_path" && i='' && break + ;; + 'removed') + # wait for this PID-file to disappear + test ! -s "$pid_file_path" && i='' && break + ;; + *) + echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" + exit 1 + ;; + esac + + # if server isn't running, then pid-file will never be updated + if test -n "$pid"; then + if kill -0 "$pid" 2>/dev/null; then + : # the server still runs + else + # The server may have exited between the last pid-file check and now. + if test -n "$avoid_race_condition"; then + avoid_race_condition="" + continue # Check again. + fi + + # there's nothing that will affect the file. + log_failure_msg "The server quit without updating PID file ($pid_file_path)." + return 1 # not waiting any more. + fi + fi + + echo $echo_n ".$echo_c" + i=`expr $i + 1` + sleep 1 + + done + + if test -z "$i" ; then + log_success_msg + return 0 + else + log_failure_msg + return 1 + fi +} + +# Get arguments from the my.cnf file, +# the only group, which is read from now on is [mysqld] +if test -x "$bindir/my_print_defaults"; then + print_defaults="$bindir/my_print_defaults" +else + # Try to find basedir in /etc/my.cnf + conf=/etc/my.cnf + print_defaults= + if test -r $conf + then + subpat='^[^=]*basedir[^=]*=\(.*\)$' + dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` + for d in $dirs + do + d=`echo $d | sed -e 's/[ ]//g'` + if test -x "$d/bin/my_print_defaults" + then + print_defaults="$d/bin/my_print_defaults" + break + fi + done + fi + + # Hope it's in the PATH ... but I doubt it + test -z "$print_defaults" && print_defaults="my_print_defaults" +fi + +# +# Read defaults file from 'basedir'. If there is no defaults file there +# check if it's in the old (depricated) place (datadir) and read it from there +# + +extra_args="" +if test -r "$basedir/my.cnf" +then + extra_args="-e $basedir/my.cnf" +else + if test -r "$datadir/my.cnf" + then + extra_args="-e $datadir/my.cnf" + fi +fi + +parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` + +# +# Set pid file if not given +# +if test -z "$mysqld_pid_file_path" +then + mysqld_pid_file_path=$datadir/`hostname`.pid +else + case "$mysqld_pid_file_path" in + /* ) ;; + * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; + esac +fi + +#ulimit -s unlimited +case "$mode" in + 'start') + # Start daemon + + # Safeguard (relative paths, core dumps..) + cd $basedir + + echo $echo_n "Starting MySQL" + if test -x $bindir/mysqld_safe + then + # Give extra arguments to mysqld with the my.cnf file. This script + # may be overwritten at next upgrade. + $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & + wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? + + # Make lock for RedHat / SuSE + if test -w "$lockdir" + then + touch "$lock_file_path" + fi + + exit $return_value + else + log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" + fi + ;; + + 'stop') + # Stop daemon. We use a signal here to avoid having to know the + # root password. + + if test -s "$mysqld_pid_file_path" + then + mysqld_pid=`cat "$mysqld_pid_file_path"` + + if (kill -0 $mysqld_pid 2>/dev/null) + then + echo $echo_n "Shutting down MySQL" + kill $mysqld_pid + # mysqld should remove the pid file when it exits, so wait for it. + wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? + else + log_failure_msg "MySQL server process #$mysqld_pid is not running!" + rm "$mysqld_pid_file_path" + fi + + # Delete lock for RedHat / SuSE + if test -f "$lock_file_path" + then + rm -f "$lock_file_path" + fi + exit $return_value + else + log_failure_msg "MySQL server PID file could not be found!" + fi + ;; + + 'restart') + # Stop the service and regardless of whether it was + # running or not, start it again. + if $0 stop $other_args; then + $0 start $other_args + else + log_failure_msg "Failed to stop running server, so refusing to try to start." + exit 1 + fi + ;; + + 'reload'|'force-reload') + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" + touch "$mysqld_pid_file_path" + else + log_failure_msg "MySQL PID file could not be found!" + exit 1 + fi + ;; + 'status') + # First, check to see if pid file exists + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + if kill -0 $mysqld_pid 2>/dev/null ; then + log_success_msg "MySQL running ($mysqld_pid)" + exit 0 + else + log_failure_msg "MySQL is not running, but PID file exists" + exit 1 + fi + else + # Try to find appropriate mysqld process + mysqld_pid=`pidof $libexecdir/mysqld` + + # test if multiple pids exist + pid_count=`echo $mysqld_pid | wc -w` + if test $pid_count -gt 1 ; then + log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" + exit 5 + elif test -z $mysqld_pid ; then + if test -f "$lock_file_path" ; then + log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" + exit 2 + fi + log_failure_msg "MySQL is not running" + exit 3 + else + log_failure_msg "MySQL is running but PID file could not be found" + exit 4 + fi + fi + ;; + *) + # usage + basename=`basename "$0"` + echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" + exit 1 + ;; +esac + +exit 0 diff --git a/plugins/mariadb/init.d/mysql8.0.tpl b/plugins/mariadb/init.d/mysql8.0.tpl new file mode 100755 index 000000000..c14f5ad3a --- /dev/null +++ b/plugins/mariadb/init.d/mysql8.0.tpl @@ -0,0 +1,376 @@ +#!/bin/sh +# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB +# This file is public domain and comes with NO WARRANTY of any kind + +# MySQL daemon start/stop script. + +# Usually this is put in /etc/init.d (at least on machines SYSV R4 based +# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. +# When this is done the mysql server will be started when the machine is +# started and shut down when the systems goes down. + +# Comments to support chkconfig on RedHat Linux +# chkconfig: 2345 64 36 +# description: A very fast and reliable SQL database engine. + +# Comments to support LSB init script conventions +### BEGIN INIT INFO +# Provides: mysql +# Required-Start: $local_fs $network $remote_fs +# Should-Start: ypbind nscd ldap ntpd xntpd +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop MySQL +# Description: MySQL is a very fast and reliable SQL database engine. +### END INIT INFO + +# If you install MySQL on some other places than /Users/midoks/Desktop/fwww/server/mysql, then you +# have to do one of the following things for this script to work: +# +# - Run this script from within the MySQL installation directory +# - Create a /etc/my.cnf file with the following information: +# [mysqld] +# basedir= +# - Add the above to any other configuration file (for example ~/.my.ini) +# and copy my_print_defaults to /usr/bin +# - Add the path to the mysql-installation-directory to the basedir variable +# below. +# +# If you want to affect other MySQL variables, you should make your changes +# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. + +# If you change base dir, you must also change datadir. These may get +# overwritten by settings in the MySQL configuration files. + +basedir= +datadir= + +# Default value, in seconds, afterwhich the script should timeout waiting +# for server start. +# Value here is overriden by value in my.cnf. +# 0 means don't wait at all +# Negative numbers mean to wait indefinitely +service_startup_timeout=900 + +# Lock directory for RedHat / SuSE. +lockdir='/var/lock/subsys' +lock_file_path="$lockdir/mysql" + +# The following variables are only set for letting mysql.server find things. + +# Set some defaults +mysqld_pid_file_path= +if test -z "$basedir" +then + basedir={$SERVER_APP_PATH} + bindir={$SERVER_APP_PATH}/bin + if test -z "$datadir" + then + datadir={$SERVER_APP_PATH}/data + fi + sbindir={$SERVER_APP_PATH}/bin + libexecdir={$SERVER_APP_PATH}/bin +else + bindir="$basedir/bin" + if test -z "$datadir" + then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" +fi + +# datadir_set is used to determine if datadir was set (and so should be +# *not* set inside of the --basedir= handler.) +datadir_set= + +# +# Use LSB init script functions for printing messages, if possible +# +lsb_functions="/lib/lsb/init-functions" +if test -f $lsb_functions ; then + . $lsb_functions +else + log_success_msg() + { + echo " SUCCESS! $@" + } + log_failure_msg() + { + echo " ERROR! $@" + } +fi + +PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" +export PATH + +mode=$1 # start or stop + +[ $# -ge 1 ] && shift + + +other_args="$*" # uncommon, but needed when called from an RPM upgrade action + # Expected: "--skip-networking --skip-grant-tables" + # They are not checked here, intentionally, as it is the resposibility + # of the "spec" file author to give correct arguments only. + +case `echo "testing\c"`,`echo -n testing` in + *c*,-n*) echo_n= echo_c= ;; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c' ;; +esac + +parse_server_arguments() { + for arg do + case "$arg" in + --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` + bindir="$basedir/bin" + if test -z "$datadir_set"; then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" + ;; + --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` + datadir_set=1 + ;; + --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + esac + done +} + +wait_for_pid () { + verb="$1" # created | removed + pid="$2" # process ID of the program operating on the pid-file + pid_file_path="$3" # path to the PID file. + + i=0 + avoid_race_condition="by checking again" + + while test $i -ne $service_startup_timeout ; do + + case "$verb" in + 'created') + # wait for a PID-file to pop into existence. + test -s "$pid_file_path" && i='' && break + ;; + 'removed') + # wait for this PID-file to disappear + test ! -s "$pid_file_path" && i='' && break + ;; + *) + echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" + exit 1 + ;; + esac + + # if server isn't running, then pid-file will never be updated + if test -n "$pid"; then + if kill -0 "$pid" 2>/dev/null; then + : # the server still runs + else + # The server may have exited between the last pid-file check and now. + if test -n "$avoid_race_condition"; then + avoid_race_condition="" + continue # Check again. + fi + + # there's nothing that will affect the file. + log_failure_msg "The server quit without updating PID file ($pid_file_path)." + return 1 # not waiting any more. + fi + fi + + echo $echo_n ".$echo_c" + i=`expr $i + 1` + sleep 1 + + done + + if test -z "$i" ; then + log_success_msg + return 0 + else + log_failure_msg + return 1 + fi +} + +# Get arguments from the my.cnf file, +# the only group, which is read from now on is [mysqld] +if test -x "$bindir/my_print_defaults"; then + print_defaults="$bindir/my_print_defaults" +else + # Try to find basedir in /etc/my.cnf + conf=/etc/my.cnf + print_defaults= + if test -r $conf + then + subpat='^[^=]*basedir[^=]*=\(.*\)$' + dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` + for d in $dirs + do + d=`echo $d | sed -e 's/[ ]//g'` + if test -x "$d/bin/my_print_defaults" + then + print_defaults="$d/bin/my_print_defaults" + break + fi + done + fi + + # Hope it's in the PATH ... but I doubt it + test -z "$print_defaults" && print_defaults="my_print_defaults" +fi + +# +# Read defaults file from 'basedir'. If there is no defaults file there +# check if it's in the old (depricated) place (datadir) and read it from there +# + +extra_args="" +if test -r "$basedir/my.cnf" +then + extra_args="-e $basedir/my.cnf" +fi + +parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` + +# +# Set pid file if not given +# +if test -z "$mysqld_pid_file_path" +then + mysqld_pid_file_path=$datadir/`hostname`.pid +else + case "$mysqld_pid_file_path" in + /* ) ;; + * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; + esac +fi + +case "$mode" in + 'start') + # Start daemon + + # Safeguard (relative paths, core dumps..) + cd $basedir + + echo $echo_n "Starting MySQL" + if test -x $bindir/mysqld_safe + then + # Give extra arguments to mysqld with the my.cnf file. This script + # may be overwritten at next upgrade. + $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & + wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? + + # Make lock for RedHat / SuSE + if test -w "$lockdir" + then + touch "$lock_file_path" + fi + + exit $return_value + else + log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" + fi + ;; + + 'stop') + # Stop daemon. We use a signal here to avoid having to know the + # root password. + + if test -s "$mysqld_pid_file_path" + then + # signal mysqld_safe that it needs to stop + touch "$mysqld_pid_file_path.shutdown" + + mysqld_pid=`cat "$mysqld_pid_file_path"` + + if (kill -0 $mysqld_pid 2>/dev/null) + then + echo $echo_n "Shutting down MySQL" + kill $mysqld_pid + # mysqld should remove the pid file when it exits, so wait for it. + wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? + else + log_failure_msg "MySQL server process #$mysqld_pid is not running!" + rm "$mysqld_pid_file_path" + fi + + # Delete lock for RedHat / SuSE + if test -f "$lock_file_path" + then + rm -f "$lock_file_path" + fi + exit $return_value + else + log_failure_msg "MySQL server PID file could not be found!" + fi + ;; + + 'restart') + # Stop the service and regardless of whether it was + # running or not, start it again. + if $0 stop $other_args; then + $0 start $other_args + else + log_failure_msg "Failed to stop running server, so refusing to try to start." + exit 1 + fi + ;; + + 'reload'|'force-reload') + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" + touch "$mysqld_pid_file_path" + else + log_failure_msg "MySQL PID file could not be found!" + exit 1 + fi + ;; + 'status') + # First, check to see if pid file exists + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + if kill -0 $mysqld_pid 2>/dev/null ; then + log_success_msg "MySQL running ($mysqld_pid)" + exit 0 + else + log_failure_msg "MySQL is not running, but PID file exists" + exit 1 + fi + else + # Try to find appropriate mysqld process + mysqld_pid=`pgrep -d' ' -f $libexecdir/mysqld` + + # test if multiple pids exist + pid_count=`echo $mysqld_pid | wc -w` + if test $pid_count -gt 1 ; then + log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" + exit 5 + elif test -z $mysqld_pid ; then + if test -f "$lock_file_path" ; then + log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" + exit 2 + fi + log_failure_msg "MySQL is not running" + exit 3 + else + log_failure_msg "MySQL is running but PID file could not be found" + exit 4 + fi + fi + ;; + *) + # usage + basename=`basename "$0"` + echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" + exit 1 + ;; +esac + +exit 0 diff --git a/plugins/mariadb/install.sh b/plugins/mariadb/install.sh new file mode 100755 index 000000000..def4d2865 --- /dev/null +++ b/plugins/mariadb/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + + +install_tmp=${rootPath}/tmp/mw_install.pl + + +action=$1 +type=$2 + +if [ "${2}" == "" ];then + echo '缺少安装脚本...' > $install_tmp + exit 0 +fi + +if [ ! -d $curPath/versions/$2 ];then + echo '缺少安装脚本2...' > $install_tmp + exit 0 +fi + +if [ "${action}" == "uninstall" ];then + + if [ -f /usr/lib/systemd/system/mariadb.service ] || [ -f /lib/systemd/system/mariadb.service ];then + systemctl stop mariadb + systemctl disable mariadb + rm -rf /usr/lib/systemd/system/mariadb.service + rm -rf /lib/systemd/system/mariadb.service + systemctl daemon-reload + fi +fi + +sh -x $curPath/versions/$2/install.sh $1 + +if [ "${action}" == "install" ] && [ -d $serverPath/mariadb ];then + #初始化 + cd ${rootPath} && python3 ${rootPath}/plugins/mariadb/index.py start ${type} + cd ${rootPath} && python3 ${rootPath}/plugins/mariadb/index.py initd_install ${type} +fi diff --git a/plugins/mariadb/js/mariadb.js b/plugins/mariadb/js/mariadb.js new file mode 100755 index 000000000..659a00c5e --- /dev/null +++ b/plugins/mariadb/js/mariadb.js @@ -0,0 +1,1736 @@ +function str2Obj(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; + } + return data; +} + +function myPost(method,args,callback, title){ + + var _args = null; + if (typeof(args) == 'string'){ + _args = JSON.stringify(str2Obj(args)); + } else { + _args = JSON.stringify(args); + } + + var _title = '正在获取...'; + if (typeof(title) != 'undefined'){ + _title = title; + } + + var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'mariadb', func:method, args:_args}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function myPostN(method,args,callback, title){ + + var _args = null; + if (typeof(args) == 'string'){ + _args = JSON.stringify(str2Obj(args)); + } else { + _args = JSON.stringify(args); + } + + var _title = '正在获取...'; + if (typeof(title) != 'undefined'){ + _title = title; + } + $.post('/plugins/run', {name:'mariadb', func:method, args:_args}, function(data) { + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function myAsyncPost(method,args){ + var _args = null; + if (typeof(args) == 'string'){ + _args = JSON.stringify(str2Obj(args)); + } else { + _args = JSON.stringify(args); + } + + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + return syncPost('/plugins/run', {name:'mariadb', func:method, args:_args}); +} + +function runInfo(){ + myPost('run_info','',function(data){ + + var rdata = $.parseJSON(data.data); + if (typeof(rdata['status']) != 'undefined'){ + layer.msg(rdata['msg'],{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + var cache_size = ((parseInt(rdata.Qcache_hits) / (parseInt(rdata.Qcache_hits) + parseInt(rdata.Qcache_inserts))) * 100).toFixed(2) + '%'; + if (cache_size == 'NaN%') cache_size = 'OFF'; + var Con = '
\ + \ + \ + \ + \ + \ + \ +
启动时间' + getLocalTime(rdata.Run) + '每秒查询' + parseInt(rdata.Questions / rdata.Uptime) + '
总连接次数' + rdata.Connections + '每秒事务' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + '
发送' + toSize(rdata.Bytes_sent) + 'File' + rdata.File + '
接收' + toSize(rdata.Bytes_received) + 'Position' + rdata.Position + '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
活动/峰值连接数' + rdata.Threads_running + '/' + rdata.Max_used_connections + '若值过大,增加max_connections
线程缓存命中率' + ((1 - rdata.Threads_created / rdata.Connections) * 100).toFixed(2) + '%若过低,增加thread_cache_size
索引命中率' + ((1 - rdata.Key_reads / rdata.Key_read_requests) * 100).toFixed(2) + '%若过低,增加key_buffer_size
Innodb索引命中率' + ((1 - rdata.Innodb_buffer_pool_reads / rdata.Innodb_buffer_pool_read_requests) * 100).toFixed(2) + '%若过低,增加innodb_buffer_pool_size
查询缓存命中率' + cache_size + '' + lan.soft.mysql_status_ps5 + '
创建临时表到磁盘' + ((rdata.Created_tmp_disk_tables / rdata.Created_tmp_tables) * 100).toFixed(2) + '%若过大,尝试增加tmp_table_size
已打开的表' + rdata.Open_tables + '若过大,增加table_cache_size
没有使用索引的量' + rdata.Select_full_join + '若不为0,请检查数据表的索引是否合理
没有索引的JOIN量' + rdata.Select_range_check + '若不为0,请检查数据表的索引是否合理
排序后的合并次数' + rdata.Sort_merge_passes + '若值过大,增加sort_buffer_size
锁表次数' + rdata.Table_locks_waited + '若值过大,请考虑增加您的数据库性能
'; + $(".soft-man-con").html(Con); + }); +} + + +function myDbPos(){ + myPost('my_db_pos','',function(data){ + var con = '
\ +
\ + \ + \ + \ +
'; + $(".soft-man-con").html(con); + + $('#btn_change_path').click(function(){ + var datadir = $("input[name='datadir']").val(); + myPost('set_db_pos','datadir='+datadir,function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg,{icon:rdata.status ? 1 : 5,time:2000,shade: [0.3, '#000']}); + }); + }); + }); +} + +function myPort(){ + myPost('my_port','',function(data){ + var con = '
\ +
\ + \ + \ +
'; + $(".soft-man-con").html(con); + + $('#btn_change_port').click(function(){ + var port = $("input[name='port']").val(); + myPost('set_my_port','port='+port,function(data){ + var rdata = $.parseJSON(data.data); + if (rdata.status){ + layer.msg('修改成功!',{icon:1,time:2000,shade: [0.3, '#000']}); + } else { + layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']}); + } + }); + }); + }); +} + + +//数据库存储信置 +function changeMySQLDataPath(act) { + if (act != undefined) { + layer.confirm(lan.soft.mysql_to_msg, { closeBtn: 2, icon: 3 }, function() { + var datadir = $("#datadir").val(); + var data = 'datadir=' + datadir; + var loadT = layer.msg(lan.soft.mysql_to_msg1, { icon: 16, time: 0, shade: [0.3, '#000'] }); + $.post('/database?action=SetDataDir', data, function(rdata) { + layer.close(loadT) + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + }); + }); + return; + } + + $.post('/database?action=GetMySQLInfo', '', function(rdata) { + var LimitCon = '

\ + \ + \ +

'; + $(".soft-man-con").html(LimitCon); + }); +} + + + + +//数据库配置状态 +function myPerfOpt() { + //获取MySQL配置 + myPost('db_status','',function(data){ + var rdata = $.parseJSON(data.data); + // console.log(rdata); + var key_buffer_size = toSizeM(rdata.mem.key_buffer_size); + var query_cache_size = toSizeM(rdata.mem.query_cache_size); + var tmp_table_size = toSizeM(rdata.mem.tmp_table_size); + var innodb_buffer_pool_size = toSizeM(rdata.mem.innodb_buffer_pool_size); + var innodb_additional_mem_pool_size = toSizeM(rdata.mem.innodb_additional_mem_pool_size); + var innodb_log_buffer_size = toSizeM(rdata.mem.innodb_log_buffer_size); + + var sort_buffer_size = toSizeM(rdata.mem.sort_buffer_size); + var read_buffer_size = toSizeM(rdata.mem.read_buffer_size); + var read_rnd_buffer_size = toSizeM(rdata.mem.read_rnd_buffer_size); + var join_buffer_size = toSizeM(rdata.mem.join_buffer_size); + var thread_stack = toSizeM(rdata.mem.thread_stack); + var binlog_cache_size = toSizeM(rdata.mem.binlog_cache_size); + + var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size; + var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size; + var memSize = a + rdata.mem.max_connections * b; + + + var memCon = '
\ +
最大使用内存: \ + \ + ' + lan.soft.mysql_set_maxmem + ': MB\ +
\ +

key_buffer_sizeMB, ' + lan.soft.mysql_set_key_buffer_size + '

\ +

query_cache_sizeMB, ' + lan.soft.mysql_set_query_cache_size + '

\ +

tmp_table_sizeMB, ' + lan.soft.mysql_set_tmp_table_size + '

\ +

innodb_buffer_pool_sizeMB, ' + lan.soft.mysql_set_innodb_buffer_pool_size + '

\ +

innodb_log_buffer_sizeMB, ' + lan.soft.mysql_set_innodb_log_buffer_size + '

\ +

innodb_additional_mem_pool_sizeMB

\ +

sort_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_sort_buffer_size + '

\ +

read_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_buffer_size + '

\ +

read_rnd_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_rnd_buffer_size + '

\ +

join_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_join_buffer_size + '

\ +

thread_stackKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_thread_stack + '

\ +

binlog_cache_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_binlog_cache_size + '

\ +

thread_cache_size ' + lan.soft.mysql_set_thread_cache_size + '

\ +

table_open_cache ' + lan.soft.mysql_set_table_open_cache + '

\ +

max_connections ' + lan.soft.mysql_set_max_connections + '

\ +
\ +
' + + $(".soft-man-con").html(memCon); + + $(".conf_p input[name*='size'],.conf_p input[name='max_connections'],.conf_p input[name='thread_stack']").change(function() { + comMySqlMem(); + }); + + $(".conf_p select[name='mysql_set']").change(function() { + mySQLMemOpt($(this).val()); + comMySqlMem(); + }); + }); +} + +function reBootMySqld(){ + pluginOpService('mysql','restart',''); +} + + +//设置MySQL配置参数 +function setMySQLConf() { + $.post('/system/system_total', '', function(memInfo) { + var memSize = memInfo['memTotal']; + var setSize = parseInt($("input[name='memSize']").val()); + + if(memSize < setSize){ + var errMsg = "错误,内存分配过高!

物理内存: {1}MB
最大使用内存: {2}MB
可能造成的后果: 导致数据库不稳定,甚至无法启动MySQLd服务!"; + var msg = errMsg.replace('{1}',memSize).replace('{2}',setSize); + layer.msg(msg,{icon:2,time:5000}); + return; + } + + var query_cache_size = parseInt($("input[name='query_cache_size']").val()); + var query_cache_type = 0; + if (query_cache_size > 0) { + query_cache_type = 1; + } + var data = { + key_buffer_size: parseInt($("input[name='key_buffer_size']").val()), + query_cache_size: query_cache_size, + query_cache_type: query_cache_type, + tmp_table_size: parseInt($("input[name='tmp_table_size']").val()), + max_heap_table_size: parseInt($("input[name='tmp_table_size']").val()), + innodb_buffer_pool_size: parseInt($("input[name='innodb_buffer_pool_size']").val()), + innodb_log_buffer_size: parseInt($("input[name='innodb_log_buffer_size']").val()), + sort_buffer_size: parseInt($("input[name='sort_buffer_size']").val()), + read_buffer_size: parseInt($("input[name='read_buffer_size']").val()), + read_rnd_buffer_size: parseInt($("input[name='read_rnd_buffer_size']").val()), + join_buffer_size: parseInt($("input[name='join_buffer_size']").val()), + thread_stack: parseInt($("input[name='thread_stack']").val()), + binlog_cache_size: parseInt($("input[name='binlog_cache_size']").val()), + thread_cache_size: parseInt($("input[name='thread_cache_size']").val()), + table_open_cache: parseInt($("input[name='table_open_cache']").val()), + max_connections: parseInt($("input[name='max_connections']").val()) + }; + + myPost('set_db_status', data, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + reBootMySqld(); + },{ icon: rdata.status ? 1 : 2 }); + }); + },'json'); +} + + +//MySQL内存优化方案 +function mySQLMemOpt(opt) { + var query_size = parseInt($("input[name='query_cache_size']").val()); + switch (opt) { + case '0': + $("input[name='key_buffer_size']").val(8); + if (query_size) $("input[name='query_cache_size']").val(4); + $("input[name='tmp_table_size']").val(8); + $("input[name='innodb_buffer_pool_size']").val(16); + $("input[name='sort_buffer_size']").val(256); + $("input[name='read_buffer_size']").val(256); + $("input[name='read_rnd_buffer_size']").val(128); + $("input[name='join_buffer_size']").val(128); + $("input[name='thread_stack']").val(256); + $("input[name='binlog_cache_size']").val(32); + $("input[name='thread_cache_size']").val(4); + $("input[name='table_open_cache']").val(32); + $("input[name='max_connections']").val(500); + break; + case '1': + $("input[name='key_buffer_size']").val(128); + if (query_size) $("input[name='query_cache_size']").val(64); + $("input[name='tmp_table_size']").val(64); + $("input[name='innodb_buffer_pool_size']").val(256); + $("input[name='sort_buffer_size']").val(768); + $("input[name='read_buffer_size']").val(768); + $("input[name='read_rnd_buffer_size']").val(512); + $("input[name='join_buffer_size']").val(1024); + $("input[name='thread_stack']").val(256); + $("input[name='binlog_cache_size']").val(64); + $("input[name='thread_cache_size']").val(64); + $("input[name='table_open_cache']").val(128); + $("input[name='max_connections']").val(100); + break; + case '2': + $("input[name='key_buffer_size']").val(256); + if (query_size) $("input[name='query_cache_size']").val(128); + $("input[name='tmp_table_size']").val(384); + $("input[name='innodb_buffer_pool_size']").val(384); + $("input[name='sort_buffer_size']").val(768); + $("input[name='read_buffer_size']").val(768); + $("input[name='read_rnd_buffer_size']").val(512); + $("input[name='join_buffer_size']").val(2048); + $("input[name='thread_stack']").val(256); + $("input[name='binlog_cache_size']").val(64); + $("input[name='thread_cache_size']").val(96); + $("input[name='table_open_cache']").val(192); + $("input[name='max_connections']").val(200); + break; + case '3': + $("input[name='key_buffer_size']").val(384); + if (query_size) $("input[name='query_cache_size']").val(192); + $("input[name='tmp_table_size']").val(512); + $("input[name='innodb_buffer_pool_size']").val(512); + $("input[name='sort_buffer_size']").val(1024); + $("input[name='read_buffer_size']").val(1024); + $("input[name='read_rnd_buffer_size']").val(768); + $("input[name='join_buffer_size']").val(2048); + $("input[name='thread_stack']").val(256); + $("input[name='binlog_cache_size']").val(128); + $("input[name='thread_cache_size']").val(128); + $("input[name='table_open_cache']").val(384); + $("input[name='max_connections']").val(300); + break; + case '4': + $("input[name='key_buffer_size']").val(512); + if (query_size) $("input[name='query_cache_size']").val(256); + $("input[name='tmp_table_size']").val(1024); + $("input[name='innodb_buffer_pool_size']").val(1024); + $("input[name='sort_buffer_size']").val(2048); + $("input[name='read_buffer_size']").val(2048); + $("input[name='read_rnd_buffer_size']").val(1024); + $("input[name='join_buffer_size']").val(4096); + $("input[name='thread_stack']").val(384); + $("input[name='binlog_cache_size']").val(192); + $("input[name='thread_cache_size']").val(192); + $("input[name='table_open_cache']").val(1024); + $("input[name='max_connections']").val(400); + break; + case '5': + $("input[name='key_buffer_size']").val(1024); + if (query_size) $("input[name='query_cache_size']").val(384); + $("input[name='tmp_table_size']").val(2048); + $("input[name='innodb_buffer_pool_size']").val(4096); + $("input[name='sort_buffer_size']").val(4096); + $("input[name='read_buffer_size']").val(4096); + $("input[name='read_rnd_buffer_size']").val(2048); + $("input[name='join_buffer_size']").val(8192); + $("input[name='thread_stack']").val(512); + $("input[name='binlog_cache_size']").val(256); + $("input[name='thread_cache_size']").val(256); + $("input[name='table_open_cache']").val(2048); + $("input[name='max_connections']").val(500); + break; + } +} + +//计算MySQL内存开销 +function comMySqlMem() { + var key_buffer_size = parseInt($("input[name='key_buffer_size']").val()); + var query_cache_size = parseInt($("input[name='query_cache_size']").val()); + var tmp_table_size = parseInt($("input[name='tmp_table_size']").val()); + var innodb_buffer_pool_size = parseInt($("input[name='innodb_buffer_pool_size']").val()); + var innodb_additional_mem_pool_size = parseInt($("input[name='innodb_additional_mem_pool_size']").val()); + var innodb_log_buffer_size = parseInt($("input[name='innodb_log_buffer_size']").val()); + + var sort_buffer_size = $("input[name='sort_buffer_size']").val() / 1024; + var read_buffer_size = $("input[name='read_buffer_size']").val() / 1024; + var read_rnd_buffer_size = $("input[name='read_rnd_buffer_size']").val() / 1024; + var join_buffer_size = $("input[name='join_buffer_size']").val() / 1024; + var thread_stack = $("input[name='thread_stack']").val() / 1024; + var binlog_cache_size = $("input[name='binlog_cache_size']").val() / 1024; + var max_connections = $("input[name='max_connections']").val(); + + var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size + var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size + var memSize = a + max_connections * b + $("input[name='memSize']").val(memSize.toFixed(2)); +} + +function syncGetDatabase(){ + myPost('sync_get_databases', null, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + dbList(); + },{ icon: rdata.status ? 1 : 2 }); + }); +} + +function syncToDatabase(type){ + var data = []; + $('input[type="checkbox"].check:checked').each(function () { + if (!isNaN($(this).val())) data.push($(this).val()); + }); + var postData = 'type='+type+'&ids='+JSON.stringify(data); + myPost('sync_to_databases', postData, function(data){ + var rdata = $.parseJSON(data.data); + // console.log(rdata); + showMsg(rdata.msg,function(){ + dbList(); + },{ icon: rdata.status ? 1 : 2 }); + }); +} + +function setRootPwd(type, pwd){ + if (type==1){ + var data = $("#mod_pwd").serialize(); + myPost('set_root_pwd', data, function(data){ + var rdata = $.parseJSON(data.data); + // console.log(rdata); + showMsg(rdata.msg,function(){ + dbList(); + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2}); + }); + return; + } + + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '修改数据库密码', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "

\ +
\ + root密码\ +
\ +
\ +
\ + \ + \ +
\ +
", + }); + + $('#my_mod_close').click(function(){ + $('.layui-layer-close1').click(); + }); +} + +function showHidePass(obj){ + var a = "glyphicon-eye-open"; + var b = "glyphicon-eye-close"; + + if($(obj).hasClass(a)){ + $(obj).removeClass(a).addClass(b); + $(obj).prev().text($(obj).prev().attr('data-pw')) + } + else{ + $(obj).removeClass(b).addClass(a); + $(obj).prev().text('***'); + } +} + +function copyPass(password){ + var clipboard = new ClipboardJS('#bt_copys'); + clipboard.on('success', function (e) { + layer.msg('复制成功',{icon:1,time:2000}); + }); + + clipboard.on('error', function (e) { + layer.msg('复制失败,浏览器不兼容!',{icon:2,time:2000}); + }); + $("#bt_copys").attr('data-clipboard-text',password); + $("#bt_copys").click(); +} + +function checkSelect(){ + setTimeout(function () { + var num = $('input[type="checkbox"].check:checked').length; + // console.log(num); + if (num == 1) { + $('button[batch="true"]').hide(); + $('button[batch="false"]').show(); + }else if (num>1){ + $('button[batch="true"]').show(); + $('button[batch="false"]').show(); + }else{ + $('button[batch="true"]').hide(); + $('button[batch="false"]').hide(); + } + },5) +} + +function setDbAccess(username){ + myPost('get_db_access','username='+username, function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:2,shade: [0.3, '#000']}); + return; + } + + var index = layer.open({ + type: 1, + area: '500px', + title: '设置数据库权限', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "
\ +
\ + 访问权限\ +
\ + \ +
\ +
\ +
\ + \ + \ +
\ +
", + }); + + layer.ready(function(){ + if (rdata.msg == '127.0.0.1'){ + $('select[name="dataAccess"]').find("option[value='127.0.0.1']").attr("selected",true); + } else if (rdata.msg == '%'){ + $('select[name="dataAccess"]').find('option[value="%"]').attr("selected",true); + } else if ( rdata.msg == 'ip' ){ + $('select[name="dataAccess"]').find('option[value="ip"]').attr("selected",true); + $('select[name="dataAccess"]').after(""); + } else { + $('select[name="dataAccess"]').find('option[value="ip"]').attr("selected",true); + $('select[name="dataAccess"]').after(""); + } + }); + + $('#my_mod_close').click(function(){ + $('.layui-layer-close1').click(); + }); + + + $('select[name="dataAccess"]').change(function(){ + var v = $(this).val(); + if (v == 'ip'){ + $(this).after(""); + } else { + $('#dataAccess_subid').remove(); + } + }); + + $('#my_mod_save').click(function(){ + var data = $("#set_db_access").serialize(); + data = decodeURIComponent(data); + var dataObj = str2Obj(data); + if(!dataObj['access']){ + dataObj['access'] = dataObj['dataAccess']; + if ( dataObj['dataAccess'] == 'ip'){ + if (dataObj['address']==''){ + layer.msg('IP地址不能空!',{icon:2,shade: [0.3, '#000']}); + return; + } + dataObj['access'] = dataObj['address']; + } + } + dataObj['username'] = username; + // console.log(data,dataObj); + myPost('set_db_access', dataObj, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + dbList(); + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2}); + }); + }); + }); +} + +function setDbPass(id, username, password){ + + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '修改数据库密码', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "
\ +
\ + 用户名\ +
\ +
\ +
\ + 密码\ +
\ +
\ + \ +
\ + \ + \ +
\ +
", + }); + + $('#my_mod_close').click(function(){ + $('.layui-layer-close1').click(); + }); + + $('#my_mod_save').click(function(){ + var data = $("#mod_pwd").serialize(); + myPost('set_user_pwd', data, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + dbList(); + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2}); + }); + }); +} + +function addDatabase(type){ + if (type==1){ + var data = $("#add_db").serialize(); + data = decodeURIComponent(data); + var dataObj = str2Obj(data); + if(!dataObj['address']){ + dataObj['address'] = dataObj['dataAccess']; + } + myPost('add_db', dataObj, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + if (rdata.status){ + dbList(); + } + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2},600); + }); + return; + } + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '添加数据库', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "
\ +
\ + 数据库名\ +
\ + \ +
\ +
\ +
用户名
\ +
\ + 密码\ +
\ +
\ +
\ + 访问权限\ +
\ + \ +
\ +
\ + \ +
\ + \ + \ +
\ +
", + }); + + $("input[name='name']").keyup(function(){ + var v = $(this).val(); + $("input[name='db_user']").val(v); + $("input[name='ps']").val(v); + }); + + $('#my_mod_close').click(function(){ + $('.layui-layer-close1').click(); + }); + $('select[name="dataAccess"]').change(function(){ + var v = $(this).val(); + if (v == 'ip'){ + $(this).after(""); + } else { + $('#dataAccess_subid').remove(); + } + }); +} + +function delDb(id, name){ + safeMessage('删除['+name+']','您真的要删除['+name+']吗?',function(){ + var data='id='+id+'&name='+name + myPost('del_db', data, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + dbList(); + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2}, 600); + }); + }); +} + +function delDbBatch(){ + var arr = []; + $('input[type="checkbox"].check:checked').each(function () { + var _val = $(this).val(); + var _name = $(this).parent().next().text(); + if (!isNaN(_val)) { + arr.push({'id':_val,'name':_name}); + } + }); + + safeMessage('批量删除数据库','您共选择了[2]个数据库,删除后将无法恢复,真的要删除吗?',function(){ + var i = 0; + $(arr).each(function(){ + var data = myAsyncPost('del_db', this); + var rdata = $.parseJSON(data.data); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:2,time:2000,shade: [0.3, '#000']}); + } + i++; + }); + + var msg = '成功删除['+i+']个数据库!'; + showMsg(msg,function(){ + dbList(); + },{icon: 1}, 600); + }); +} + + +function setDbPs(id, name, obj) { + var _span = $(obj); + var _input = $(""); + _span.hide().after(_input); + _input.focus(); + _input.blur(function(){ + $(this).remove(); + var ps = _input.val(); + _span.text(ps).show(); + var data = {name:name,id:id,ps:ps}; + myPost('set_db_ps', data, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); + }); + _input.keyup(function(){ + if(event.keyCode == 13){ + _input.trigger('blur'); + } + }); +} + +function openPhpmyadmin(name,username,password){ + + data = syncPost('/plugins/check',{'name':'phpmyadmin'}); + + + if (!data.status){ + layer.msg(data.msg,{icon:2,shade: [0.3, '#000']}); + return; + } + + data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'status'}); + if (data.data != 'start'){ + layer.msg('phpMyAdmin未启动',{icon:2,shade: [0.3, '#000']}); + return; + } + // console.log(data); + data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'get_home_page'}); + var rdata = $.parseJSON(data.data); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:2,shade: [0.3, '#000']}); + return; + } + $("#toPHPMyAdmin").attr('action',rdata.data); + + if($("#toPHPMyAdmin").attr('action').indexOf('phpmyadmin') == -1){ + layer.msg('请先安装phpMyAdmin',{icon:2,shade: [0.3, '#000']}); + setTimeout(function(){ window.location.href = '/soft'; },3000); + return; + } + + //检查版本 + data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'version'}); + bigVer = data.data.split('.')[0] + if (bigVer>=5){ + + setTimeout(function(){ + $("#toPHPMyAdmin").submit(); + },3000); + layer.msg('phpMyAdmin['+data.data+']需要手动登录😭',{icon:16,shade: [0.3, '#000'],time:4000}); + + } else{ + var murl = $("#toPHPMyAdmin").attr('action'); + $("#pma_username").val(username); + $("#pma_password").val(password); + $("#db").val(name); + + layer.msg('正在打开phpMyAdmin',{icon:16,shade: [0.3, '#000'],time:2000}); + + setTimeout(function(){ + $("#toPHPMyAdmin").submit(); + },3000); + } +} + +function delBackup(filename,name){ + myPost('delete_db_backup',{filename:filename},function(){ + layer.msg('执行成功!'); + setTimeout(function(){ + $('.layui-layer-close2').click(); + setBackup(name); + },2000); + }); +} + +function downloadBackup(file){ + window.open('/files/download?filename='+encodeURIComponent(file)); +} + +function importBackup(file,name){ + myPost('import_db_backup',{file:file,name:name}, function(data){ + // console.log(data); + layer.msg('执行成功!'); + }); +} + +function setBackup(db_name,obj){ + myPost('get_db_backup_list', {name:db_name}, function(data){ + + var rdata = $.parseJSON(data.data); + var tbody = ''; + for (var i = 0; i < rdata.data.length; i++) { + tbody += '\ + ' + rdata.data[i]['name'] + '\ + ' + rdata.data[i]['size'] + '\ + ' + rdata.data[i]['time'] + '\ + \ + 导入 | \ + 下载 | \ + 删除\ + \ + '; + } + + var s = layer.open({ + type: 1, + title: "数据库备份详情", + area: ['600px', '280px'], + closeBtn: 2, + shadeClose: false, + content: '
\ +
\ + \ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + ' + tbody + '\ +
文件名称文件大小备份时间操作
\ +
\ +
\ +
' + }); + + $('#btn_backup').click(function(){ + myPost('set_db_backup',{name:db_name}, function(data){ + layer.msg('执行成功!'); + + setTimeout(function(){ + layer.close(s); + setBackup(db_name,obj); + },2000); + }); + }); + }); +} + + +function dbList(page, search){ + var _data = {}; + if (typeof(page) =='undefined'){ + var page = 1; + } + + _data['page'] = page; + _data['page_size'] = 10; + if(typeof(search) != 'undefined'){ + _data['search'] = search; + } + myPost('get_db_list', _data, function(data){ + var rdata = $.parseJSON(data.data); + var list = ''; + for(i in rdata.data){ + list += ''; + list +=''; + list += '' + rdata.data[i]['name'] +''; + list += '' + rdata.data[i]['username'] +''; + list += '' + + '***' + + ''+ + ''+ + ''; + + + list += ''+rdata.data[i]['ps']+''; + list += ''; + + list += ''+(rdata.data[i]['is_backup']?'备份':'未备份') +' | '; + + list += '管理 | ' + + '工具 | ' + + '权限 | ' + + '改密 | ' + + '删除' + + ''; + list += ''; + } + + // + var con = '
\ + \ + \ + \ + \ + \ + \ + \ +
\ +
\ + \ + \ + \ + \ + \ + '+ + // ''+ + '\ + \ + \ + '+ list +'\ +
数据库名用户名密码备份备注操作
\ +
\ +
\ +
\ + 同步选中\ + 同步所有\ + 从服务器获取\ +
\ +
\ +
'; + + con += ''; + + $(".soft-man-con").html(con); + $('#databasePage').html(rdata.page); + + readerTableChecked(); + }); +} + + +function myLogs(){ + + myPost('bin_log', {status:1}, function(data){ + var rdata = $.parseJSON(data.data); + + var limitCon = '

\ + 二进制日志 ' + toSize(rdata.msg) + '\ + \ +

错误日志

\ + \ +

' + $(".soft-man-con").html(limitCon); + + //设置二进制日志 + $(".btn-bin").click(function () { + myPost('bin_log', 'close=change', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + + setTimeout(function(){ + myLogs(); + }, 2000); + }); + }); + + //清空日志 + $(".btn-clear").click(function () { + myPost('error_log', 'close=1', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + + setTimeout(function(){ + myLogs(); + }, 2000); + }); + }) + + myPost('error_log', 'p=1', function(data){ + var rdata = $.parseJSON(data.data); + var error_body = ''; + if (rdata.status){ + error_body = rdata.data; + } else { + error_body = rdata.msg; + } + $("#error_log").text(error_body); + var ob = document.getElementById('error_log'); + ob.scrollTop = ob.scrollHeight; + }); + }); +} + + +function repCheckeds(tables) { + var dbs = [] + if (tables) { + dbs.push(tables) + } else { + var db_tools = $("input[value^='dbtools_']"); + for (var i = 0; i < db_tools.length; i++) { + if (db_tools[i].checked) dbs.push(db_tools[i].value.replace('dbtools_', '')); + } + } + + if (dbs.length < 1) { + layer.msg('请至少选择一张表!', { icon: 2 }); + return false; + } + return dbs; +} + +function repDatabase(db_name, tables) { + dbs = repCheckeds(tables); + + myPost('repair_table', { db_name: db_name, tables: JSON.stringify(dbs) }, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + repTools(db_name, true); + },'已送修复指令,请稍候...'); +} + + +function optDatabase(db_name, tables) { + dbs = repCheckeds(tables); + + myPost('opt_table', { db_name: db_name, tables: JSON.stringify(dbs) }, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + repTools(db_name, true); + },'已送优化指令,请稍候...'); +} + +function toDatabaseType(db_name, tables, type){ + dbs = repCheckeds(tables); + myPost('alter_table', { db_name: db_name, tables: JSON.stringify(dbs),table_type: type }, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + repTools(db_name, true); + }, '已送引擎转换指令,请稍候...'); +} + + +function selectedTools(my_obj, db_name) { + var is_checked = false + + if (my_obj) is_checked = my_obj.checked; + var db_tools = $("input[value^='dbtools_']"); + var n = 0; + for (var i = 0; i < db_tools.length; i++) { + if (my_obj) db_tools[i].checked = is_checked; + if (db_tools[i].checked) n++; + } + if (n > 0) { + var my_btns = '\ + \ + \ + ' + $("#db_tools").html(my_btns); + } else { + $("#db_tools").html(''); + } +} + +function repTools(db_name, res){ + myPost('get_db_info', {name:db_name}, function(data){ + var rdata = $.parseJSON(data.data); + var types = { InnoDB: "MyISAM", MyISAM: "InnoDB" }; + var tbody = ''; + for (var i = 0; i < rdata.tables.length; i++) { + if (!types[rdata.tables[i].type]) continue; + tbody += '\ + \ + ' + rdata.tables[i].table_name + '\ + ' + rdata.tables[i].type + '\ + ' + rdata.tables[i].collation + '\ + ' + rdata.tables[i].rows_count + '\ + ' + rdata.tables[i].data_size + '\ + \ + 修复 |\ + 优化 |\ + 转为' + types[rdata.tables[i].type] + '\ + \ + ' + } + + if (res) { + $(".gztr").html(tbody); + $("#db_tools").html(''); + $("input[type='checkbox']").attr("checked", false); + $(".tools_size").html('大小:' + rdata.data_size); + return; + } + + layer.open({ + type: 1, + title: "MySQL工具箱【" + db_name + "】", + area: ['780px', '580px'], + closeBtn: 2, + shadeClose: false, + content: '
\ + \ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + ' + tbody + '\ +
表名引擎字符集行数大小操作
\ +
\ +
\ +
    \ +
  • 【修复】尝试使用REPAIR命令修复损坏的表,仅能做简单修复,若修复不成功请考虑使用myisamchk工具
  • \ +
  • 【优化】执行OPTIMIZE命令,可回收未释放的磁盘空间,建议每月执行一次
  • \ +
  • 【转为InnoDB/MyISAM】转换数据表引擎,建议将所有表转为InnoDB
  • \ +
' + }); + tableFixed('database_fix'); + }); +} + + +function setDbMaster(name){ + myPost('set_db_master', {name:name}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){ + masterOrSlaveConf(); + }, 2000); + }); +} + + +function setDbSlave(name){ + myPost('set_db_slave', {name:name}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){ + masterOrSlaveConf(); + }, 2000); + }); +} + + +function addMasterRepSlaveUser(){ + + + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '添加同步账户', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "
\ +
用户名
\ +
\ + 密码\ +
\ +
\ + \ +
\ + \ + \ +
\ +
", + }); + + //
\ + // 访问权限\ + //
\ + // \ + //
\ + //
\ + + $("input[name='name']").keyup(function(){ + var v = $(this).val(); + $("input[name='db_user']").val(v); + $("input[name='ps']").val(v); + }); + + $('#my_mod_close').click(function(){ + $('.layui-layer-close1').click(); + }); + $('select[name="dataAccess"]').change(function(){ + var v = $(this).val(); + if (v == 'ip'){ + $(this).after(""); + } else { + $('#dataAccess_subid').remove(); + } + }); + + $('#submit_add_master').click(function(){ + + var data = $("#add_master").serialize(); + data = decodeURIComponent(data); + var dataObj = str2Obj(data); + if(!dataObj['address']){ + dataObj['address'] = dataObj['dataAccess']; + } + // console.log(dataObj); + myPost('add_master_rep_slave_user', dataObj, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + if (rdata.status){ + getMasterRepSlaveList(); + } + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2},600); + }); + }); +} + + + +function updateMasterRepSlaveUser(username){ + + + var index = layer.open({ + type: 1, + skin: 'demo-class', + area: '500px', + title: '更新账户', + closeBtn: 1, + shift: 5, + shadeClose: true, + content: "
\ +
用户名
\ +
\ + 密码\ +
\ +
\ + \ +
\ + \ +
\ +
", + }); + + $('#submit_update_master').click(function(){ + var data = $("#update_master").serialize(); + data = decodeURIComponent(data); + var dataObj = str2Obj(data); + // console.log(dataObj); + myPost('update_master_rep_slave_user', data, function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + if (rdata.status){ + getMasterRepSlaveList(); + } + $('.layui-layer-close1').click(); + },{icon: rdata.status ? 1 : 2},600); + }); + }); +} + +function getMasterRepSlaveUserCmd(username, db=''){ + myPost('get_master_rep_slave_user_cmd', {username:username,db:db}, function(data){ + var rdata = $.parseJSON(data.data); + + if (!rdata['status']){ + layer.msg(rdata['msg']); + return; + } + + + var loadOpen = layer.open({ + type: 1, + title: '同步命令', + area: '500px', + content:"
\ +
"+rdata.data+"
\ +
\ + \ +
\ +
", + }); + + copyPass(rdata.data); + $('.class-copy-cmd').click(function(){ + copyPass(rdata.data); + }); + }); +} + +function delMasterRepSlaveUser(username){ + myPost('del_master_rep_slave_user', {username:username}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg); + + $('.layui-layer-close1').click(); + + setTimeout(function(){ + getMasterRepSlaveList(); + },1000); + }); +} + +function getMasterRepSlaveList(){ + var _data = {}; + if (typeof(page) =='undefined'){ + var page = 1; + } + + _data['page'] = page; + _data['page_size'] = 10; + myPost('get_master_rep_slave_list', _data, function(data){ + // console.log(data); + var rdata = []; + try { + rdata = $.parseJSON(data.data); + } catch(e){ + console.log(e); + } + var list = ''; + // console.log(rdata['data']); + var user_list = rdata['data']; + for (i in user_list) { + // console.log(i); + var name = user_list[i]['username']; + list += ''+name+'\ + '+user_list[i]['password']+'\ + \ + 修改 | \ + 删除 | \ + 从库同步命令\ + \ + '; + } + + var page = '
'; + page += '
添加同步账户
'; + + var loadOpen = layer.open({ + type: 1, + title: '同步账户列表', + area: '500px', + content:"
\ +
\ +
\ + \ + " + list + "\ +
用户民密码操作
\ + "+page +"\ +
\ +
" + }); + + $('.dataTables_paginate_4').html(rdata['page']); + }); +} + + +function deleteSlave(){ + myPost('delete_slave', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata['msg']); + setTimeout(function(){ + masterOrSlaveConf(); + }, 3000); + + }); +} + + +function getFullSyncStatus(db){ + + var btn = '
开始
'; + var loadOpen = layer.open({ + type: 1, + title: '全量同步['+db+']', + area: '500px', + content:"
\ +
\ + \ +
\ +
0%
\ +
\ +
\ + "+btn+"\ +
" + }); + + var timeId = setInterval(function(){ + fullSync(db,0); + }, 1000); + + function fullSync(db,begin){ + + myPostN('full_sync', {db:db,begin:begin}, function(data){ + var rdata = $.parseJSON(data.data); + $('#full_msg').text(rdata['msg']); + $('.progress-bar').css('width',rdata['progress']+'%'); + $('.progress-bar').text(rdata['progress']+'%'); + + if (rdata['code']==6 ||rdata['code']<0){ + layer.msg(rdata['msg']); + clearInterval(timeId); + } + }); + } + + fullSync(db,0); + $('#begin_full_sync').click(function(){ + fullSync(db,1); + + timeId= setTimeout(function(){ + fullSync(db,0); + }, 1000); + }); + + $('.layui-layer-close1').click(function(){ + clearInterval(timeId); + }); +} + +function handlerRun(){ + cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py do_full_sync {"db":"all"}'; + var loadOpen = layer.open({ + type: 1, + title: '手动执行', + area: '500px', + content:"
\ +
"+cmd+"
\ +
\ + \ +
\ +
", + }); + copyPass(cmd); + $('.class-copy-cmd').click(function(){ + copyPass(cmd); + }); +} + +function masterOrSlaveConf(version=''){ + + function getMasterDbList(){ + var _data = {}; + if (typeof(page) =='undefined'){ + var page = 1; + } + + _data['page'] = page; + _data['page_size'] = 10; + + myPost('get_masterdb_list', _data, function(data){ + var rdata = $.parseJSON(data.data); + var list = ''; + for(i in rdata.data){ + list += ''; + list += '' + rdata.data[i]['name'] +''; + list += '' + (rdata.data[i]['master']?'是':'否') +''; + list += '' + + ''+(rdata.data[i]['master']?'退出':'加入')+' | ' + + '同步命令' + + ''; + list += ''; + } + + var con = '
\ +
\ + \ + \ + \ + \ + \ + \ + '+ list +'\ +
数据库名同步操作
\ +
\ +
\ +
\ + 同步账户列表\ +
\ +
'; + + $(".table_master_list").html(con); + $('#databasePage').html(rdata.page); + }); + } + + function getAsyncMasterDbList(){ + var _data = {}; + if (typeof(page) =='undefined'){ + var page = 1; + } + + _data['page'] = page; + _data['page_size'] = 10; + + myPost('get_slave_list', _data, function(data){ + var rdata = $.parseJSON(data.data); + var list = ''; + for(i in rdata.data){ + list += ''; + list += '' + rdata.data[i]['Master_Host'] +''; + list += '' + rdata.data[i]['Master_Port'] +''; + list += '' + rdata.data[i]['Master_User'] +''; + list += '' + rdata.data[i]['Master_Log_File'] +''; + list += '' + rdata.data[i]['Slave_IO_Running'] +''; + list += '' + rdata.data[i]['Slave_SQL_Running'] +''; + list += '' + + '删除' + + ''; + list += ''; + } + + var con = '
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + '+ list +'\ +
主[服务]端口用户日志IOSQL操作
\ +
\ +
'; + + //
\ + //
\ + // 添加\ + //
+ $(".table_slave_status_list").html(con); + }); + } + + function getAsyncDataList(){ + var _data = {}; + if (typeof(page) =='undefined'){ + var page = 1; + } + + _data['page'] = page; + _data['page_size'] = 10; + myPost('get_masterdb_list', _data, function(data){ + var rdata = $.parseJSON(data.data); + var list = ''; + for(i in rdata.data){ + list += ''; + list += '' + rdata.data[i]['name'] +''; + list += '' + + ''+(rdata.data[i]['slave']?'退出':'加入')+' | ' + + '修复' + + ''; + list += ''; + } + + var con = '
\ +
\ + \ + \ + \ + \ + \ + '+ list +'\ +
本地库名操作
\ +
\ +
\ +
\ + 手动命令\ + 全量同步\ +
\ +
'; + + $(".table_slave_list").html(con); + $('#databasePage').html(rdata.page); + }); + } + + function getMasterStatus(){ + myPost('get_master_status', '', function(data){ + var rdata = $.parseJSON(data.data); + var limitCon = '

\ + Master[主]配置\ +


\ +

\ + \ +
\ +
\ +

\ + Slave[从]配置\ +


\ +

\ + \ +
\ + \ +
\ + '; + $(".soft-man-con").html(limitCon); + + //设置主服务器配置 + $(".btn-master").click(function () { + myPost('set_master_status', 'close=change', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){ + getMasterStatus(); + }, 3000); + }); + }); + + $(".btn-slave").click(function () { + myPost('set_slave_status', 'close=change', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){ + getMasterStatus(); + }, 3000); + }); + }); + + if (rdata.status){ + getMasterDbList(); + } + + if (rdata.data.slave_status){ + getAsyncMasterDbList(); + getAsyncDataList() + } + }); + } + getMasterStatus(); +} diff --git a/plugins/mariadb/scripts/tools.py b/plugins/mariadb/scripts/tools.py new file mode 100755 index 000000000..d54330376 --- /dev/null +++ b/plugins/mariadb/scripts/tools.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +import sys +import os +import json +import time + +sys.path.append(os.getcwd() + "/class/core") +import mw +import db + +cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' +info = mw.execShell(cmd) +p = "/usr/local/lib/" + info[0].strip() + "/site-packages" +sys.path.append(p) + + +def set_mysql_root(password): + # 设置MySQL密码 + import db + import os + sql = db.Sql() + + root_mysql = '''#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +pwd=$1 +${server}/init.d/mysql stop +${server}/bin/mysqld_safe --skip-grant-tables& +echo '正在修改密码...'; +echo 'The set password...'; +sleep 6 +m_version=$(cat ${server}/version.pl|grep -E "(5.1.|5.5.|5.6.|mariadb)") +if [ "$m_version" != "" ];then + ${server}/bin/mysql -uroot -e "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('${pwd}'),'127.0.0.1')" + ${server}/bin/mysql -uroot -e "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('${pwd}'),'localhost')" + ${server}/bin/mysql -uroot -e "UPDATE mysql.user SET password=PASSWORD('${pwd}') WHERE user='root'"; +else + ${server}/bin/mysql -uroot -e "UPDATE mysql.user SET authentication_string='' WHERE user='root'"; + ${server}/bin/mysql -uroot -e "FLUSH PRIVILEGES"; + ${server}/bin/mysql -uroot -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${pwd}';"; +fi +${server} -uroot -e "FLUSH PRIVILEGES"; +pkill -9 mysqld_safe +pkill -9 mysqld +sleep 2 +${server}/init.d/mysql start + +echo '===========================================' +echo "root密码成功修改为: ${pwd}" +echo "The root password set ${pwd} successuful"''' + + server = mw.getServerDir() + '/mysql' + root_mysql = root_mysql.replace('${server}', server) + mw.writeFile('mysql_root.sh', root_mysql) + os.system("/bin/bash mysql_root.sh " + password) + os.system("rm -f mysql_root.sh") + + pos = mw.getServerDir() + '/mysql' + result = sql.table('config').dbPos(pos, 'mysql').where( + 'id=?', (1,)).setField('mysql_root', password) + + +def set_panel_pwd(password, ncli=False): + # 设置面板密码 + import db + sql = db.Sql() + result = sql.table('users').where('id=?', (1,)).setField( + 'password', mw.md5(password)) + username = sql.table('users').where('id=?', (1,)).getField('username') + if ncli: + print("|-用户名: " + username) + print("|-新密码: " + password) + else: + print(username) + + +def set_panel_username(username=None): + # 随机面板用户名 + import db + sql = db.Sql() + if username: + if len(username) < 5: + print("|-错误,用户名长度不能少于5位") + return + if username in ['admin', 'root']: + print("|-错误,不能使用过于简单的用户名") + return + + sql.table('users').where('id=?', (1,)).setField('username', username) + print("|-新用户名: %s" % username) + return + + username = sql.table('users').where('id=?', (1,)).getField('username') + if username == 'admin': + username = mw.getRandomString(8).lower() + sql.table('users').where('id=?', (1,)).setField('username', username) + print('username: ' + username) + + +def getServerIp(): + version = sys.argv[2] + ip = mw.execShell( + "curl -{} -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text".format(version)) + print(ip[0]) + + +if __name__ == "__main__": + type = sys.argv[1] + if type == 'root': + set_mysql_root(sys.argv[2]) + elif type == 'panel': + set_panel_pwd(sys.argv[2]) + elif type == 'username': + set_panel_username() + elif type == 'getServerIp': + getServerIp() + else: + print('ERROR: Parameter error') diff --git a/plugins/mariadb/versions/10.6/install.sh b/plugins/mariadb/versions/10.6/install.sh new file mode 100755 index 000000000..a777778e8 --- /dev/null +++ b/plugins/mariadb/versions/10.6/install.sh @@ -0,0 +1,86 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +#https://dev.mysql.com/downloads/mysql/5.5.html#downloads +#https://dev.mysql.com/downloads/file/?id=480541 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +install_tmp=${rootPath}/tmp/mw_install.pl +mariadbDir=${serverPath}/source/mariadb + +MY_VER=10.6.8 + +Install_app() +{ + mkdir -p ${mariadbDir} + echo '正在安装脚本文件...' > $install_tmp + + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + + if [ "$sysName" != "Darwin" ];then + mkdir -p /var/log/mariadb + touch /var/log/mariadb/mariadb.log + fi + + if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then + wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz + fi + + if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then + cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz + fi + + + if [ ! -d $serverPath/mariadb ];then + cd ${mariadbDir}/mariadb-${MY_VER} && cmake \ + -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ + -DMYSQL_USER=mysql \ + -DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_MEMORY_STORAGE_ENGINE=1 \ + -DENABLED_LOCAL_INFILE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DEXTRA_CHARSETS=all \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ + make && make install && make clean + + if [ -d $serverPath/mariadb ];then + echo '10.6' > $serverPath/mariadb/version.pl + echo '安装完成' > $install_tmp + else + rm -rf ${mariadbDir}/mariadb-${MY_VER} + echo '安装失败' > $install_tmp + echo 'install fail'>&2 + exit 1 + fi + fi +} + +Uninstall_app() +{ + rm -rf $serverPath/mariadb + echo '卸载完成' > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_app +else + Uninstall_app +fi From bf9416465de79bc83b815558325ec2baafab3573 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 10:44:15 +0800 Subject: [PATCH 012/173] Update index.py --- plugins/mysql/index.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 3c59f38b4..84e4c1d8c 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -333,6 +333,7 @@ def initMysql57Data(): cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ ' --initialize-insecure --explicit_defaults_for_timestamp' data = mw.execShell(cmd) + # print(data) return False return True @@ -349,7 +350,8 @@ def initMysql8Data(): datadir + ' --initialize-insecure' # print(cmd) - mw.execShell(cmd) + data = mw.execShell(cmd) + # print(data) return False return True @@ -396,7 +398,7 @@ def initMysql8Pwd(): tmp_file = "/tmp/mysql_init_tmp.log" mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql -uroot -p < ' + tmp_file + cmd_pass = serverdir + '/bin/mysql -uroot -p ""< ' + tmp_file data = mw.execShell(cmd_pass) # print(data) From 5f82540390c72269cdbd876507226a95456a719e Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 10:59:40 +0800 Subject: [PATCH 013/173] Update index.py --- plugins/mysql/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 84e4c1d8c..143771810 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -392,13 +392,13 @@ def initMysql8Pwd(): "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" alter_root_pwd = alter_root_pwd + "flush privileges;" - # cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' - # data = mw.execShell(cmd_pass) + cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' + data = mw.execShell(cmd_pass) # print(data) tmp_file = "/tmp/mysql_init_tmp.log" mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql -uroot -p ""< ' + tmp_file + cmd_pass = serverdir + '/bin/mysql -uroot -proot < ' + tmp_file data = mw.execShell(cmd_pass) # print(data) From 971eb133f060cd31d9d1cf3bfdc0e4de80ca8907 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:01:14 +0800 Subject: [PATCH 014/173] Update index.py --- plugins/mysql/index.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 143771810..ca4e80563 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -386,6 +386,9 @@ def initMysql8Pwd(): pwd = mw.getRandomString(16) alter_root_pwd = 'flush privileges;' + + alter_root_pwd = alter_root_pwd + \ + "UPDATE mysql.user SET authentication_string='' WHERE user='root';" alter_root_pwd = alter_root_pwd + \ "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" alter_root_pwd = alter_root_pwd + \ From 43eda00517b6f873dcfc4353f3e2011332242f6d Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:09:01 +0800 Subject: [PATCH 015/173] Update index.py --- plugins/mysql/index.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index ca4e80563..92198e17b 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -389,6 +389,7 @@ def initMysql8Pwd(): alter_root_pwd = alter_root_pwd + \ "UPDATE mysql.user SET authentication_string='' WHERE user='root';" + alter_root_pwd = alter_root_pwd + "flush privileges;" alter_root_pwd = alter_root_pwd + \ "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" alter_root_pwd = alter_root_pwd + \ From 61e26a1bb486f86c0e9f1452b2de9117eb025fce Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:22:14 +0800 Subject: [PATCH 016/173] Update info.json --- plugins/phpmyadmin/info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/phpmyadmin/info.json b/plugins/phpmyadmin/info.json index e810898a6..33307f86c 100755 --- a/plugins/phpmyadmin/info.json +++ b/plugins/phpmyadmin/info.json @@ -5,8 +5,8 @@ "type":"运行环境", "ps":"著名Web端MySQL管理工具", "to_ver":["4.8.4"], - "versions":["4.4.15","5.2.0"], - "updates":["4.4.15","5.2.0"], + "versions":["4.4.15","4.9.10","5.2.0"], + "updates":["4.4.15","4.9.10","5.2.0"], "shell":"install.sh", "checks":"server/phpmyadmin", "path": "server/phpmyadmin", From 0dd1489a329abca539a38d3687ab1c85e1e615c4 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:36:16 +0800 Subject: [PATCH 017/173] up --- .../mariadb/init.d/{mysql.service.tpl => mariadb.service.tpl} | 0 plugins/mariadb/init.d/{mysql8.0.tpl => mariadb.tpl} | 0 plugins/mariadb/versions/10.6/install.sh | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename plugins/mariadb/init.d/{mysql.service.tpl => mariadb.service.tpl} (100%) rename plugins/mariadb/init.d/{mysql8.0.tpl => mariadb.tpl} (100%) diff --git a/plugins/mariadb/init.d/mysql.service.tpl b/plugins/mariadb/init.d/mariadb.service.tpl similarity index 100% rename from plugins/mariadb/init.d/mysql.service.tpl rename to plugins/mariadb/init.d/mariadb.service.tpl diff --git a/plugins/mariadb/init.d/mysql8.0.tpl b/plugins/mariadb/init.d/mariadb.tpl similarity index 100% rename from plugins/mariadb/init.d/mysql8.0.tpl rename to plugins/mariadb/init.d/mariadb.tpl diff --git a/plugins/mariadb/versions/10.6/install.sh b/plugins/mariadb/versions/10.6/install.sh index a777778e8..72036590c 100755 --- a/plugins/mariadb/versions/10.6/install.sh +++ b/plugins/mariadb/versions/10.6/install.sh @@ -64,7 +64,7 @@ Install_app() echo '10.6' > $serverPath/mariadb/version.pl echo '安装完成' > $install_tmp else - rm -rf ${mariadbDir}/mariadb-${MY_VER} + # rm -rf ${mariadbDir}/mariadb-${MY_VER} echo '安装失败' > $install_tmp echo 'install fail'>&2 exit 1 From b06963d763823dceac93c243439dd42cf3529cbd Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:39:56 +0800 Subject: [PATCH 018/173] Update index.py --- plugins/mariadb/index.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index a7bb60bf8..f3d9f3499 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -123,11 +123,11 @@ def contentReplace(content): def pSqliteDb(dbname='databases'): - file = getServerDir() + '/mysql.db' + file = getServerDir() + '/mariadb.db' name = 'mysql' if not os.path.exists(file): conn = mw.M(dbname).dbPos(getServerDir(), name) - csql = mw.readFile(getPluginDir() + '/conf/mysql.sql') + csql = mw.readFile(getPluginDir() + '/conf/mariadb.sql') csql_list = csql.split(';') for index in range(len(csql_list)): conn.execute(csql_list[index], ()) @@ -183,8 +183,8 @@ def initDreplace(version=''): # systemd systemDir = mw.systemdCfgDir() - systemService = systemDir + '/mysql.service' - systemServiceTpl = getPluginDir() + '/init.d/mysql.service.tpl' + systemService = systemDir + '/mariadb.service' + systemServiceTpl = getPluginDir() + '/init.d/mariadb.service.tpl' if os.path.exists(systemDir) and not os.path.exists(systemService): service_path = mw.getServerDir() se_content = mw.readFile(systemServiceTpl) @@ -329,8 +329,7 @@ def initMysql57Data(): user = pGetDbUser() cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ ' --initialize-insecure --explicit_defaults_for_timestamp' - # print(mw.execShell(cmd)) - + mw.execShell(cmd) return False return True @@ -388,13 +387,13 @@ def initMysql8Pwd(): "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" alter_root_pwd = alter_root_pwd + "flush privileges;" - # cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' - # data = mw.execShell(cmd_pass) + cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' + data = mw.execShell(cmd_pass) # print(data) tmp_file = "/tmp/mysql_init_tmp.log" mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql -uroot -p < ' + tmp_file + cmd_pass = serverdir + '/bin/mysql -uroot -proot < ' + tmp_file data = mw.execShell(cmd_pass) # print(data) @@ -411,9 +410,9 @@ def myOp(version, method): try: isInited = initMysqlData() if not isInited: - mw.execShell('systemctl start mysql') + mw.execShell('systemctl start mariadb') initMysqlPwd() - mw.execShell('systemctl stop mysql') + mw.execShell('systemctl stop mariadb') mw.execShell('systemctl ' + method + ' mysql') return 'ok' @@ -440,7 +439,7 @@ def my8cmd(version, method): time.sleep(6) else: - mw.execShell('systemctl start mysql') + mw.execShell('systemctl start mariadb') initMysql8Pwd() @@ -450,14 +449,14 @@ def my8cmd(version, method): bufsize=4096, stderr=subprocess.PIPE) time.sleep(3) else: - mw.execShell('systemctl stop mysql') + mw.execShell('systemctl stop mariadb') if mw.isAppleSystem(): sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, bufsize=4096, stderr=subprocess.PIPE) sub.wait(5) else: - mw.execShell('systemctl ' + method + ' mysql') + mw.execShell('systemctl ' + method + ' mariadb') return 'ok' except Exception as e: return str(e) @@ -489,7 +488,7 @@ def initdStatus(): if mw.isAppleSystem(): return "Apple Computer does not support" - shell_cmd = 'systemctl status mysql | grep loaded | grep "enabled;"' + shell_cmd = 'systemctl status mariadb | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) if data[0] == '': return 'fail' @@ -500,7 +499,7 @@ def initdInstall(): if mw.isAppleSystem(): return "Apple Computer does not support" - mw.execShell('systemctl enable mysql') + mw.execShell('systemctl enable mariadb') return 'ok' @@ -508,7 +507,7 @@ def initdUinstall(): if mw.isAppleSystem(): return "Apple Computer does not support" - mw.execShell('systemctl disable mysql') + mw.execShell('systemctl disable mariadb') return 'ok' From ea93f57c2c2f25807834dd9382ca13fcef23a521 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:41:20 +0800 Subject: [PATCH 019/173] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index f3d9f3499..2fb790159 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -118,7 +118,7 @@ def contentReplace(content): if content.find('{$SERVER_APP_PATH}') != -1: content = content.replace( - '{$SERVER_APP_PATH}', service_path + '/mysql') + '{$SERVER_APP_PATH}', service_path + '/mariadb') return content From 8c92275be07991c89a26aa020ac04dcb47294fb0 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:57:12 +0800 Subject: [PATCH 020/173] Update mysql.js --- plugins/mysql/js/mysql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 78926c7f5..a0b09de37 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -835,7 +835,7 @@ function openPhpmyadmin(name,username,password){ //检查版本 data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'version'}); bigVer = data.data.split('.')[0] - if (bigVer>=5){ + if (bigVer>=4.9){ setTimeout(function(){ $("#toPHPMyAdmin").submit(); From 34fcc31e2d2666bb84c1eb12e0562d6e90151382 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:57:23 +0800 Subject: [PATCH 021/173] Update mysql.js --- plugins/mysql/js/mysql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index a0b09de37..a4d001814 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -835,7 +835,7 @@ function openPhpmyadmin(name,username,password){ //检查版本 data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'version'}); bigVer = data.data.split('.')[0] - if (bigVer>=4.9){ + if (bigVer>=4.4){ setTimeout(function(){ $("#toPHPMyAdmin").submit(); From 0b710912abb559fd3bee9501bfe8902229c3a5f4 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 11:57:34 +0800 Subject: [PATCH 022/173] Update mysql.js --- plugins/mysql/js/mysql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index a4d001814..9f704fb61 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -835,7 +835,7 @@ function openPhpmyadmin(name,username,password){ //检查版本 data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'version'}); bigVer = data.data.split('.')[0] - if (bigVer>=4.4){ + if (bigVer>=4.5){ setTimeout(function(){ $("#toPHPMyAdmin").submit(); From f63f1848557993953320c37c7e350befd528b35c Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:05:48 +0800 Subject: [PATCH 023/173] up --- plugins/mariadb/conf/my.cnf | 1 - plugins/mariadb/conf/my5.7.cnf | 96 --------------------------------- plugins/mariadb/conf/my8.0.cnf | 98 ---------------------------------- plugins/mariadb/index.py | 2 +- plugins/mariadb/info.json | 8 +-- 5 files changed, 5 insertions(+), 200 deletions(-) delete mode 100644 plugins/mariadb/conf/my5.7.cnf delete mode 100644 plugins/mariadb/conf/my8.0.cnf diff --git a/plugins/mariadb/conf/my.cnf b/plugins/mariadb/conf/my.cnf index c699ed3e3..651aff4e5 100644 --- a/plugins/mariadb/conf/my.cnf +++ b/plugins/mariadb/conf/my.cnf @@ -69,7 +69,6 @@ innodb_data_home_dir = {$SERVER_APP_PATH}/data innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = {$SERVER_APP_PATH}/data innodb_buffer_pool_size = 16M -innodb_additional_mem_pool_size = 2M innodb_log_file_size = 5M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 diff --git a/plugins/mariadb/conf/my5.7.cnf b/plugins/mariadb/conf/my5.7.cnf deleted file mode 100644 index b0a71d37f..000000000 --- a/plugins/mariadb/conf/my5.7.cnf +++ /dev/null @@ -1,96 +0,0 @@ -[client] -user = root -#password = your_password -port = 3306 -socket = {$SERVER_APP_PATH}/mysql.sock -default-character-set = UTF8MB4 - -[mysqld] -pid-file = {$SERVER_APP_PATH}/data/mysql.pid -user = mysql -port = 3306 -socket = {$SERVER_APP_PATH}/mysql.sock -basedir = {$SERVER_APP_PATH} -datadir = {$SERVER_APP_PATH}/data -log-error = {$SERVER_APP_PATH}/data/error.log -default_storage_engine = MyISAM - -key_buffer_size = 8M -table_open_cache = 32 -sort_buffer_size = 256K -net_buffer_length = 4K -read_buffer_size = 128K -read_rnd_buffer_size = 256K -myisam_sort_buffer_size = 4M -thread_cache_size = 4 -lower_case_table_names=0 -tmp_table_size = 8M -character-set-server = UTF8MB4 - -max_connections = 500 -max_connect_errors = 100 -open_files_limit = 2560 -max_allowed_packet = 128M - -#skip-external-locking -#skip-grant-tables -#loose-skip-innodb -#skip-networking -#skip-name-resolve - -log-bin=mysql-bin -binlog_format=mixed -server-id = 1 -slow_query_log=1 -slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log -long_query_time=3 -#log_queries_not_using_indexes=on - -relay-log=mdserver -relay-log-index=mdserver - -#master -#binlog-do-db -binlog-ignore-db = test -binlog-ignore-db = mysql -binlog-ignore-db = information_schema -binlog-ignore-db = performance_schema - -#slave -log-slave-updates -#replicate-do-db -replicate-ignore-db = information_schema -replicate-ignore-db = performance_schema -replicate-ignore-db = mysql -replicate-ignore-db = test - -default_storage_engine = InnoDB -innodb_data_home_dir = {$SERVER_APP_PATH}/data -innodb_data_file_path = ibdata1:10M:autoextend -innodb_log_group_home_dir = {$SERVER_APP_PATH}/data -innodb_buffer_pool_size = 16M -innodb_log_file_size = 5M -innodb_log_buffer_size = 8M -innodb_flush_log_at_trx_commit = 1 -innodb_lock_wait_timeout = 120 -innodb_max_dirty_pages_pct = 90 -innodb_read_io_threads = 1 -innodb_write_io_threads = 1 -innodb_file_per_table=1 - -secure-file-priv={$SERVER_APP_PATH}/tmp - -[mysqldump] -quick - -[mysql] -no-auto-rehash - -[myisamchk] -key_buffer_size = 20M -sort_buffer_size = 20M -read_buffer = 2M -write_buffer = 2M - -[mysqlhotcopy] -interactive-timeout \ No newline at end of file diff --git a/plugins/mariadb/conf/my8.0.cnf b/plugins/mariadb/conf/my8.0.cnf deleted file mode 100644 index 7e390ce92..000000000 --- a/plugins/mariadb/conf/my8.0.cnf +++ /dev/null @@ -1,98 +0,0 @@ -[client] -user = root -#password = your_password -port = 3306 -socket = {$SERVER_APP_PATH}/mysql.sock -default-character-set = UTF8MB4 - -[mysqld] -default_authentication_plugin=mysql_native_password -pid-file = {$SERVER_APP_PATH}/data/mysql.pid -user = mysql -port = 3306 -socket = {$SERVER_APP_PATH}/mysql.sock -basedir = {$SERVER_APP_PATH} -datadir = {$SERVER_APP_PATH}/data -log-error = {$SERVER_APP_PATH}/data/error.log -default_storage_engine = MyISAM - -key_buffer_size = 8M -table_open_cache = 32 -sort_buffer_size = 256K -net_buffer_length = 4K -read_buffer_size = 128K -read_rnd_buffer_size = 256K -myisam_sort_buffer_size = 4M -thread_cache_size = 4 -lower_case_table_names=0 -tmp_table_size = 8M -character-set-server = UTF8MB4 - -max_connections = 500 -max_connect_errors = 100 -open_files_limit = 2560 -max_allowed_packet = 128M - -#skip-external-locking -#skip-grant-tables -#loose-skip-innodb -#skip-networking -#skip-name-resolve - -log-bin=mysql-bin -binlog_format=mixed -server-id = 1 -slow_query_log=1 -slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log -long_query_time=3 -#log_queries_not_using_indexes=on - -relay-log=mdserver -relay-log-index=mdserver - -#master -#binlog-do-db -binlog-ignore-db = test -binlog-ignore-db = mysql -binlog-ignore-db = information_schema -binlog-ignore-db = performance_schema - -#slave -log_replica_updates -#replicate-do-db -replicate-ignore-db = information_schema -replicate-ignore-db = performance_schema -replicate-ignore-db = mysql -replicate-ignore-db = test - -default_storage_engine = InnoDB -innodb_data_home_dir = {$SERVER_APP_PATH}/data -innodb_data_file_path = ibdata1:10M:autoextend -innodb_log_group_home_dir = {$SERVER_APP_PATH}/data -innodb_buffer_pool_size = 16M -innodb_log_file_size = 5M -innodb_log_buffer_size = 8M -innodb_flush_log_at_trx_commit = 1 -innodb_lock_wait_timeout = 120 -innodb_max_dirty_pages_pct = 90 -innodb_read_io_threads = 1 -innodb_write_io_threads = 1 -innodb_file_per_table=1 -binlog_expire_logs_seconds=2592000 - -secure-file-priv={$SERVER_APP_PATH}/tmp - -[mysqldump] -quick - -[mysql] -no-auto-rehash - -[myisamchk] -key_buffer_size = 20M -sort_buffer_size = 20M -read_buffer = 2M -write_buffer = 2M - -[mysqlhotcopy] -interactive-timeout \ No newline at end of file diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 2fb790159..d9ff9652c 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -1914,7 +1914,7 @@ def uninstallPreInspection(version): if __name__ == "__main__": func = sys.argv[1] - version = "5.6" + version = "10.6" if (len(sys.argv) > 2): version = sys.argv[2] diff --git a/plugins/mariadb/info.json b/plugins/mariadb/info.json index 65df8cf16..440997690 100755 --- a/plugins/mariadb/info.json +++ b/plugins/mariadb/info.json @@ -5,14 +5,14 @@ "type":"运行环境", "ps":"[DEV]一种关系数据库管理系统!", "uninstall_pre_inspection":true, - "checks": "server/mariadb/VERSION/bin/mysql", - "path": "server/mariadb/VERSION", - "versions":["10.6", "5.6", "5.7","8.0"], + "checks": "server/mariadb", + "path": "server/mariadb", + "versions":["10.6"], "shell":"install.sh", "checks":"server/mariadb", "path":"server/mariadb", "author":"mariadb", - "home":"https://mariadb.com/products/community-server/", + "home":"https://mariadb.org/", "date":"2022-07-12", "pid": "2" } \ No newline at end of file From 1c09b0adcd7744836d14a4364ed631eace42f507 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:17:26 +0800 Subject: [PATCH 024/173] Update public.js --- route/static/app/public.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/route/static/app/public.js b/route/static/app/public.js index 5681b16f7..643a9edd5 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -1107,6 +1107,31 @@ function execLog(){ }); } +/** + * 获取时分秒 + * @param {Number} seconds 总秒数 + * @param {String} dateFormat 返回的日期格式,默认为'H:i:s' + */ +function getSFM(seconds, dateFormat = 'H:i:s') { + var obj = {}; + obj.H = Number.parseInt(seconds / 3600); + obj.i = Number.parseInt((seconds - obj.H * 3600) / 60); + obj.s = Number.parseInt(seconds - obj.H * 3600 - obj.i * 60); + if (obj.H < 10) { + obj.H = '0' + obj.H; + } + if (obj.i < 10) { + obj.i = '0' + obj.i; + } + if (obj.s < 10) { + obj.s = '0' + obj.s; + } + + // 3.解析 + var rs = dateFormat.replace('H', obj.H).replace('i', obj.i).replace('s', obj.s); + return rs; +} + function remind(a){ a = a == undefined ? 1 : a; $.post("/task/list", "table=tasks&result=2,4,6,8&limit=10&p=" + a, function(g) { @@ -1117,9 +1142,9 @@ function remind(a){ for(var d = 0; d < g.data.length; d++) { if(g.data[d].status != '1'){ task_count++; - e += '
'+g.data[d].name+'【'+lan.bt.task_the+'】'+ lan.bt.time + (g.data[d].end - g.data[d].start) + lan.bt.s+'
'+g.data[d].addtime+'' + e += '
'+g.data[d].name+'【'+lan.bt.task_the+'】耗时['+ getSFM(g.data[d].end - g.data[d].start) +']
'+g.data[d].addtime+'' } else{ - e += '
'+g.data[d].name+'【'+lan.bt.task_ok+'】'+ lan.bt.time + (g.data[d].end - g.data[d].start) + lan.bt.s+'
'+g.data[d].addtime+''; + e += '
'+g.data[d].name+'【'+lan.bt.task_ok+'】耗时['+ getSFM(g.data[d].end - g.data[d].start) +']
'+g.data[d].addtime+''; } } var con = '
\ From 8a11e1a5150000238508a1d164de72e90104a2ad Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:21:48 +0800 Subject: [PATCH 025/173] Update task_api.py --- class/core/task_api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/class/core/task_api.py b/class/core/task_api.py index 53b8023a1..83742f3c6 100755 --- a/class/core/task_api.py +++ b/class/core/task_api.py @@ -61,8 +61,7 @@ class task_api: if not len(find): return mw.returnJson(False, '当前没有任务队列在执行-2!') - isTask = os.getcwd() + '/tmp/panelTask.pl' - mw.writeFile(isTask, 'True') + mw.triggerTask() echoMsg = {} echoMsg['name'] = find['name'] From b95bba438a15fe796a5aba880c4a34e5a3247133 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:31:17 +0800 Subject: [PATCH 026/173] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index d9ff9652c..f2c74d2c5 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -414,7 +414,7 @@ def myOp(version, method): initMysqlPwd() mw.execShell('systemctl stop mariadb') - mw.execShell('systemctl ' + method + ' mysql') + mw.execShell('systemctl ' + method + ' mariadb') return 'ok' except Exception as e: return str(e) From ae7ee5da94ee5d76449cc9a9f7a1d28ef70b8521 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:32:03 +0800 Subject: [PATCH 027/173] Update index.py --- plugins/mariadb/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index f2c74d2c5..b1cc27f78 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -463,8 +463,8 @@ def my8cmd(version, method): def appCMD(version, action): - if version == '8.0' or version == '5.7': - return my8cmd(version, action) + # if version == '8.0' or version == '5.7': + # return my8cmd(version, action) return myOp(version, action) From 232f39f8e01f97d9055b4e88f080020c0873d639 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 12:35:12 +0800 Subject: [PATCH 028/173] Update index.py --- plugins/mariadb/index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index b1cc27f78..42080eed1 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -316,7 +316,8 @@ def initMysqlData(): myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --defaults-file=' + myconf - mw.execShell(cmd) + data = mw.execShell(cmd) + # print(data) return False return True From aba7b39962aa00a9f7dcfddfd87a1a99dec5e18c Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 13:06:08 +0800 Subject: [PATCH 029/173] up --- plugins/mariadb/conf/my.cnf | 4 ++-- plugins/mariadb/index.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mariadb/conf/my.cnf b/plugins/mariadb/conf/my.cnf index 651aff4e5..4fd989170 100644 --- a/plugins/mariadb/conf/my.cnf +++ b/plugins/mariadb/conf/my.cnf @@ -1,13 +1,13 @@ [client] user = root #password = your_password -port = 3306 +port = 33106 socket = {$SERVER_APP_PATH}/mysql.sock [mysqld] pid-file = {$SERVER_APP_PATH}/data/mysql.pid user = mysql -port = 3306 +port = 33106 socket = {$SERVER_APP_PATH}/mysql.sock basedir = {$SERVER_APP_PATH} datadir = {$SERVER_APP_PATH}/data diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 42080eed1..30180a866 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -315,7 +315,7 @@ def initMysqlData(): serverdir = getServerDir() myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() - cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --defaults-file=' + myconf + cmd = 'cd ' + serverdir + ' && ./scripts/mariadb-install-db --defaults-file=' + myconf data = mw.execShell(cmd) # print(data) return False From dac46df7a51b25862faeffe64f1061dcdb1c154e Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 14:08:11 +0800 Subject: [PATCH 030/173] up --- plugins/mariadb/index.py | 107 +----- plugins/mariadb/init.d/mariadb.service.tpl | 6 +- plugins/mariadb/init.d/mariadb.tpl | 376 -------------------- plugins/mariadb/init.d/mysql.tpl | 383 --------------------- plugins/mariadb/versions/10.6/install.sh | 1 + 5 files changed, 5 insertions(+), 868 deletions(-) delete mode 100755 plugins/mariadb/init.d/mariadb.tpl delete mode 100644 plugins/mariadb/init.d/mysql.tpl diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 30180a866..bed83d156 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -315,43 +315,14 @@ def initMysqlData(): serverdir = getServerDir() myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() - cmd = 'cd ' + serverdir + ' && ./scripts/mariadb-install-db --defaults-file=' + myconf + cmd = 'cd ' + serverdir + ' && ./scripts/mariadb-install-db ' + \ + ' --defaults-file=' + myconf data = mw.execShell(cmd) # print(data) return False return True -def initMysql57Data(): - datadir = getDataDir() - if not os.path.exists(datadir + '/mysql'): - serverdir = getServerDir() - myconf = serverdir + "/etc/my.cnf" - user = pGetDbUser() - cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ - ' --initialize-insecure --explicit_defaults_for_timestamp' - mw.execShell(cmd) - return False - return True - - -def initMysql8Data(): - datadir = getDataDir() - if not os.path.exists(datadir + '/mysql'): - serverdir = getServerDir() - user = pGetDbUser() - # cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ - # datadir + ' --initialize' - - cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ - datadir + ' --initialize-insecure' - - # print(cmd) - mw.execShell(cmd) - return False - return True - - def initMysqlPwd(): time.sleep(5) @@ -375,36 +346,6 @@ def initMysqlPwd(): return True -def initMysql8Pwd(): - time.sleep(2) - - serverdir = getServerDir() - pwd = mw.getRandomString(16) - - alter_root_pwd = 'flush privileges;' - alter_root_pwd = alter_root_pwd + \ - "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" - alter_root_pwd = alter_root_pwd + \ - "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" - alter_root_pwd = alter_root_pwd + "flush privileges;" - - cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' - data = mw.execShell(cmd_pass) - # print(data) - - tmp_file = "/tmp/mysql_init_tmp.log" - mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql -uroot -proot < ' + tmp_file - - data = mw.execShell(cmd_pass) - # print(data) - os.remove(tmp_file) - - pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) - - return True - - def myOp(version, method): # import commands init_file = initDreplace() @@ -421,51 +362,7 @@ def myOp(version, method): return str(e) -def my8cmd(version, method): - # mysql 8.0 and 5.7 - init_file = initDreplace(version) - cmd = init_file + ' ' + method - try: - if version == '5.7': - isInited = initMysql57Data() - elif version == '8.0': - isInited = initMysql8Data() - - if not isInited: - - if mw.isAppleSystem(): - cmd_init_start = init_file + ' start' - subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, - bufsize=4096, stderr=subprocess.PIPE) - - time.sleep(6) - else: - mw.execShell('systemctl start mariadb') - - initMysql8Pwd() - - if mw.isAppleSystem(): - cmd_init_stop = init_file + ' stop' - subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, - bufsize=4096, stderr=subprocess.PIPE) - time.sleep(3) - else: - mw.execShell('systemctl stop mariadb') - - if mw.isAppleSystem(): - sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, - bufsize=4096, stderr=subprocess.PIPE) - sub.wait(5) - else: - mw.execShell('systemctl ' + method + ' mariadb') - return 'ok' - except Exception as e: - return str(e) - - def appCMD(version, action): - # if version == '8.0' or version == '5.7': - # return my8cmd(version, action) return myOp(version, action) diff --git a/plugins/mariadb/init.d/mariadb.service.tpl b/plugins/mariadb/init.d/mariadb.service.tpl index 765c61ae0..c27e9596c 100644 --- a/plugins/mariadb/init.d/mariadb.service.tpl +++ b/plugins/mariadb/init.d/mariadb.service.tpl @@ -1,7 +1,6 @@ [Unit] -Description=MySQL Community Server -Documentation=man:mysqld(8) -Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html +Description=MariaDB Server: The open source relational database +Documentation=https://mariadb.org/download/?t=mariadb After=network.service After=syslog.target @@ -11,7 +10,6 @@ Group=mysql Type=simple ExecStart={$SERVER_PATH}/mariadb/bin/mysqld --defaults-file={$SERVER_PATH}/mariadb/etc/my.cnf ExecReload=/bin/kill -USR2 $MAINPID -TimeoutSec=0 PermissionsStartOnly=true LimitNOFILE=5000 Restart=on-failure diff --git a/plugins/mariadb/init.d/mariadb.tpl b/plugins/mariadb/init.d/mariadb.tpl deleted file mode 100755 index c14f5ad3a..000000000 --- a/plugins/mariadb/init.d/mariadb.tpl +++ /dev/null @@ -1,376 +0,0 @@ -#!/bin/sh -# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -# This file is public domain and comes with NO WARRANTY of any kind - -# MySQL daemon start/stop script. - -# Usually this is put in /etc/init.d (at least on machines SYSV R4 based -# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. -# When this is done the mysql server will be started when the machine is -# started and shut down when the systems goes down. - -# Comments to support chkconfig on RedHat Linux -# chkconfig: 2345 64 36 -# description: A very fast and reliable SQL database engine. - -# Comments to support LSB init script conventions -### BEGIN INIT INFO -# Provides: mysql -# Required-Start: $local_fs $network $remote_fs -# Should-Start: ypbind nscd ldap ntpd xntpd -# Required-Stop: $local_fs $network $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start and stop MySQL -# Description: MySQL is a very fast and reliable SQL database engine. -### END INIT INFO - -# If you install MySQL on some other places than /Users/midoks/Desktop/fwww/server/mysql, then you -# have to do one of the following things for this script to work: -# -# - Run this script from within the MySQL installation directory -# - Create a /etc/my.cnf file with the following information: -# [mysqld] -# basedir= -# - Add the above to any other configuration file (for example ~/.my.ini) -# and copy my_print_defaults to /usr/bin -# - Add the path to the mysql-installation-directory to the basedir variable -# below. -# -# If you want to affect other MySQL variables, you should make your changes -# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. - -# If you change base dir, you must also change datadir. These may get -# overwritten by settings in the MySQL configuration files. - -basedir= -datadir= - -# Default value, in seconds, afterwhich the script should timeout waiting -# for server start. -# Value here is overriden by value in my.cnf. -# 0 means don't wait at all -# Negative numbers mean to wait indefinitely -service_startup_timeout=900 - -# Lock directory for RedHat / SuSE. -lockdir='/var/lock/subsys' -lock_file_path="$lockdir/mysql" - -# The following variables are only set for letting mysql.server find things. - -# Set some defaults -mysqld_pid_file_path= -if test -z "$basedir" -then - basedir={$SERVER_APP_PATH} - bindir={$SERVER_APP_PATH}/bin - if test -z "$datadir" - then - datadir={$SERVER_APP_PATH}/data - fi - sbindir={$SERVER_APP_PATH}/bin - libexecdir={$SERVER_APP_PATH}/bin -else - bindir="$basedir/bin" - if test -z "$datadir" - then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - libexecdir="$basedir/libexec" -fi - -# datadir_set is used to determine if datadir was set (and so should be -# *not* set inside of the --basedir= handler.) -datadir_set= - -# -# Use LSB init script functions for printing messages, if possible -# -lsb_functions="/lib/lsb/init-functions" -if test -f $lsb_functions ; then - . $lsb_functions -else - log_success_msg() - { - echo " SUCCESS! $@" - } - log_failure_msg() - { - echo " ERROR! $@" - } -fi - -PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" -export PATH - -mode=$1 # start or stop - -[ $# -ge 1 ] && shift - - -other_args="$*" # uncommon, but needed when called from an RPM upgrade action - # Expected: "--skip-networking --skip-grant-tables" - # They are not checked here, intentionally, as it is the resposibility - # of the "spec" file author to give correct arguments only. - -case `echo "testing\c"`,`echo -n testing` in - *c*,-n*) echo_n= echo_c= ;; - *c*,*) echo_n=-n echo_c= ;; - *) echo_n= echo_c='\c' ;; -esac - -parse_server_arguments() { - for arg do - case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` - bindir="$basedir/bin" - if test -z "$datadir_set"; then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - libexecdir="$basedir/libexec" - ;; - --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` - datadir_set=1 - ;; - --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - esac - done -} - -wait_for_pid () { - verb="$1" # created | removed - pid="$2" # process ID of the program operating on the pid-file - pid_file_path="$3" # path to the PID file. - - i=0 - avoid_race_condition="by checking again" - - while test $i -ne $service_startup_timeout ; do - - case "$verb" in - 'created') - # wait for a PID-file to pop into existence. - test -s "$pid_file_path" && i='' && break - ;; - 'removed') - # wait for this PID-file to disappear - test ! -s "$pid_file_path" && i='' && break - ;; - *) - echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" - exit 1 - ;; - esac - - # if server isn't running, then pid-file will never be updated - if test -n "$pid"; then - if kill -0 "$pid" 2>/dev/null; then - : # the server still runs - else - # The server may have exited between the last pid-file check and now. - if test -n "$avoid_race_condition"; then - avoid_race_condition="" - continue # Check again. - fi - - # there's nothing that will affect the file. - log_failure_msg "The server quit without updating PID file ($pid_file_path)." - return 1 # not waiting any more. - fi - fi - - echo $echo_n ".$echo_c" - i=`expr $i + 1` - sleep 1 - - done - - if test -z "$i" ; then - log_success_msg - return 0 - else - log_failure_msg - return 1 - fi -} - -# Get arguments from the my.cnf file, -# the only group, which is read from now on is [mysqld] -if test -x "$bindir/my_print_defaults"; then - print_defaults="$bindir/my_print_defaults" -else - # Try to find basedir in /etc/my.cnf - conf=/etc/my.cnf - print_defaults= - if test -r $conf - then - subpat='^[^=]*basedir[^=]*=\(.*\)$' - dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` - for d in $dirs - do - d=`echo $d | sed -e 's/[ ]//g'` - if test -x "$d/bin/my_print_defaults" - then - print_defaults="$d/bin/my_print_defaults" - break - fi - done - fi - - # Hope it's in the PATH ... but I doubt it - test -z "$print_defaults" && print_defaults="my_print_defaults" -fi - -# -# Read defaults file from 'basedir'. If there is no defaults file there -# check if it's in the old (depricated) place (datadir) and read it from there -# - -extra_args="" -if test -r "$basedir/my.cnf" -then - extra_args="-e $basedir/my.cnf" -fi - -parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` - -# -# Set pid file if not given -# -if test -z "$mysqld_pid_file_path" -then - mysqld_pid_file_path=$datadir/`hostname`.pid -else - case "$mysqld_pid_file_path" in - /* ) ;; - * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; - esac -fi - -case "$mode" in - 'start') - # Start daemon - - # Safeguard (relative paths, core dumps..) - cd $basedir - - echo $echo_n "Starting MySQL" - if test -x $bindir/mysqld_safe - then - # Give extra arguments to mysqld with the my.cnf file. This script - # may be overwritten at next upgrade. - $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & - wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? - - # Make lock for RedHat / SuSE - if test -w "$lockdir" - then - touch "$lock_file_path" - fi - - exit $return_value - else - log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" - fi - ;; - - 'stop') - # Stop daemon. We use a signal here to avoid having to know the - # root password. - - if test -s "$mysqld_pid_file_path" - then - # signal mysqld_safe that it needs to stop - touch "$mysqld_pid_file_path.shutdown" - - mysqld_pid=`cat "$mysqld_pid_file_path"` - - if (kill -0 $mysqld_pid 2>/dev/null) - then - echo $echo_n "Shutting down MySQL" - kill $mysqld_pid - # mysqld should remove the pid file when it exits, so wait for it. - wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? - else - log_failure_msg "MySQL server process #$mysqld_pid is not running!" - rm "$mysqld_pid_file_path" - fi - - # Delete lock for RedHat / SuSE - if test -f "$lock_file_path" - then - rm -f "$lock_file_path" - fi - exit $return_value - else - log_failure_msg "MySQL server PID file could not be found!" - fi - ;; - - 'restart') - # Stop the service and regardless of whether it was - # running or not, start it again. - if $0 stop $other_args; then - $0 start $other_args - else - log_failure_msg "Failed to stop running server, so refusing to try to start." - exit 1 - fi - ;; - - 'reload'|'force-reload') - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" - touch "$mysqld_pid_file_path" - else - log_failure_msg "MySQL PID file could not be found!" - exit 1 - fi - ;; - 'status') - # First, check to see if pid file exists - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - if kill -0 $mysqld_pid 2>/dev/null ; then - log_success_msg "MySQL running ($mysqld_pid)" - exit 0 - else - log_failure_msg "MySQL is not running, but PID file exists" - exit 1 - fi - else - # Try to find appropriate mysqld process - mysqld_pid=`pgrep -d' ' -f $libexecdir/mysqld` - - # test if multiple pids exist - pid_count=`echo $mysqld_pid | wc -w` - if test $pid_count -gt 1 ; then - log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" - exit 5 - elif test -z $mysqld_pid ; then - if test -f "$lock_file_path" ; then - log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" - exit 2 - fi - log_failure_msg "MySQL is not running" - exit 3 - else - log_failure_msg "MySQL is running but PID file could not be found" - exit 4 - fi - fi - ;; - *) - # usage - basename=`basename "$0"` - echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" - exit 1 - ;; -esac - -exit 0 diff --git a/plugins/mariadb/init.d/mysql.tpl b/plugins/mariadb/init.d/mysql.tpl deleted file mode 100644 index ef861da5a..000000000 --- a/plugins/mariadb/init.d/mysql.tpl +++ /dev/null @@ -1,383 +0,0 @@ -#!/bin/sh -# chkconfig: 2345 55 25 -# Description: mysql service -# distro. For CentOS/Redhat run: 'chkconfig --add mysql' - -# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB -# This file is public domain and comes with NO WARRANTY of any kind - -# MySQL daemon start/stop script. - -# Usually this is put in /etc/init.d (at least on machines SYSV R4 based -# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. -# When this is done the mysql server will be started when the machine is -# started and shut down when the systems goes down. - -# Comments to support chkconfig on RedHat Linux -# chkconfig: 2345 64 36 -# description: A very fast and reliable SQL database engine. - -# Comments to support LSB init script conventions -### BEGIN INIT INFO -# Provides: mysql -# Required-Start: $local_fs $network $remote_fs -# Should-Start: ypbind nscd ldap ntpd xntpd -# Required-Stop: $local_fs $network $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: start and stop MySQL -# Description: MySQL is a very fast and reliable SQL database engine. -### END INIT INFO - -# If you install MySQL on some other places than /www/server/mysql, then you -# have to do one of the following things for this script to work: -# -# - Run this script from within the MySQL installation directory -# - Create a /etc/my.cnf file with the following information: -# [mysqld] -# basedir= -# - Add the above to any other configuration file (for example ~/.my.ini) -# and copy my_print_defaults to /usr/bin -# - Add the path to the mysql-installation-directory to the basedir variable -# below. -# -# If you want to affect other MySQL variables, you should make your changes -# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. - -# If you change base dir, you must also change datadir. These may get -# overwritten by settings in the MySQL configuration files. - -basedir= -datadir= - -# Default value, in seconds, afterwhich the script should timeout waiting -# for server start. -# Value here is overriden by value in my.cnf. -# 0 means don't wait at all -# Negative numbers mean to wait indefinitely -service_startup_timeout=900 - -# Lock directory for RedHat / SuSE. -lockdir='/var/lock/subsys' -lock_file_path="$lockdir/mysql" - -# The following variables are only set for letting mysql.server find things. - -# Set some defaults -mysqld_pid_file_path= -if test -z "$basedir" -then - basedir={$SERVER_APP_PATH} - bindir={$SERVER_APP_PATH}/bin - if test -z "$datadir" - then - datadir={$SERVER_APP_PATH}/data - fi - sbindir={$SERVER_APP_PATH}/bin - libexecdir={$SERVER_APP_PATH}/bin -else - bindir="$basedir/bin" - if test -z "$datadir" - then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - libexecdir="$basedir/libexec" -fi - -# datadir_set is used to determine if datadir was set (and so should be -# *not* set inside of the --basedir= handler.) -datadir_set= - -# -# Use LSB init script functions for printing messages, if possible -# -lsb_functions="/lib/lsb/init-functions" -if test -f $lsb_functions ; then - . $lsb_functions -else - log_success_msg() - { - echo " SUCCESS! $@" - } - log_failure_msg() - { - echo " ERROR! $@" - } -fi - -PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" -export PATH - -mode=$1 # start or stop - -[ $# -ge 1 ] && shift - - -other_args=--sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" # uncommon, but needed when called from an RPM upgrade action - # Expected: "--skip-networking --skip-grant-tables" - # They are not checked here, intentionally, as it is the resposibility - # of the "spec" file author to give correct arguments only. - -case `echo "testing\c"`,`echo -n testing` in - *c*,-n*) echo_n= echo_c= ;; - *c*,*) echo_n=-n echo_c= ;; - *) echo_n= echo_c='\c' ;; -esac - -parse_server_arguments() { - for arg do - case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` - bindir="$basedir/bin" - if test -z "$datadir_set"; then - datadir="$basedir/data" - fi - sbindir="$basedir/sbin" - libexecdir="$basedir/libexec" - ;; - --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` - datadir_set=1 - ;; - --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - esac - done -} - -wait_for_pid () { - verb="$1" # created | removed - pid="$2" # process ID of the program operating on the pid-file - pid_file_path="$3" # path to the PID file. - - i=0 - avoid_race_condition="by checking again" - - while test $i -ne $service_startup_timeout ; do - - case "$verb" in - 'created') - # wait for a PID-file to pop into existence. - test -s "$pid_file_path" && i='' && break - ;; - 'removed') - # wait for this PID-file to disappear - test ! -s "$pid_file_path" && i='' && break - ;; - *) - echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" - exit 1 - ;; - esac - - # if server isn't running, then pid-file will never be updated - if test -n "$pid"; then - if kill -0 "$pid" 2>/dev/null; then - : # the server still runs - else - # The server may have exited between the last pid-file check and now. - if test -n "$avoid_race_condition"; then - avoid_race_condition="" - continue # Check again. - fi - - # there's nothing that will affect the file. - log_failure_msg "The server quit without updating PID file ($pid_file_path)." - return 1 # not waiting any more. - fi - fi - - echo $echo_n ".$echo_c" - i=`expr $i + 1` - sleep 1 - - done - - if test -z "$i" ; then - log_success_msg - return 0 - else - log_failure_msg - return 1 - fi -} - -# Get arguments from the my.cnf file, -# the only group, which is read from now on is [mysqld] -if test -x "$bindir/my_print_defaults"; then - print_defaults="$bindir/my_print_defaults" -else - # Try to find basedir in /etc/my.cnf - conf=/etc/my.cnf - print_defaults= - if test -r $conf - then - subpat='^[^=]*basedir[^=]*=\(.*\)$' - dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` - for d in $dirs - do - d=`echo $d | sed -e 's/[ ]//g'` - if test -x "$d/bin/my_print_defaults" - then - print_defaults="$d/bin/my_print_defaults" - break - fi - done - fi - - # Hope it's in the PATH ... but I doubt it - test -z "$print_defaults" && print_defaults="my_print_defaults" -fi - -# -# Read defaults file from 'basedir'. If there is no defaults file there -# check if it's in the old (depricated) place (datadir) and read it from there -# - -extra_args="" -if test -r "$basedir/my.cnf" -then - extra_args="-e $basedir/my.cnf" -else - if test -r "$datadir/my.cnf" - then - extra_args="-e $datadir/my.cnf" - fi -fi - -parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` - -# -# Set pid file if not given -# -if test -z "$mysqld_pid_file_path" -then - mysqld_pid_file_path=$datadir/`hostname`.pid -else - case "$mysqld_pid_file_path" in - /* ) ;; - * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; - esac -fi - -#ulimit -s unlimited -case "$mode" in - 'start') - # Start daemon - - # Safeguard (relative paths, core dumps..) - cd $basedir - - echo $echo_n "Starting MySQL" - if test -x $bindir/mysqld_safe - then - # Give extra arguments to mysqld with the my.cnf file. This script - # may be overwritten at next upgrade. - $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & - wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? - - # Make lock for RedHat / SuSE - if test -w "$lockdir" - then - touch "$lock_file_path" - fi - - exit $return_value - else - log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" - fi - ;; - - 'stop') - # Stop daemon. We use a signal here to avoid having to know the - # root password. - - if test -s "$mysqld_pid_file_path" - then - mysqld_pid=`cat "$mysqld_pid_file_path"` - - if (kill -0 $mysqld_pid 2>/dev/null) - then - echo $echo_n "Shutting down MySQL" - kill $mysqld_pid - # mysqld should remove the pid file when it exits, so wait for it. - wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? - else - log_failure_msg "MySQL server process #$mysqld_pid is not running!" - rm "$mysqld_pid_file_path" - fi - - # Delete lock for RedHat / SuSE - if test -f "$lock_file_path" - then - rm -f "$lock_file_path" - fi - exit $return_value - else - log_failure_msg "MySQL server PID file could not be found!" - fi - ;; - - 'restart') - # Stop the service and regardless of whether it was - # running or not, start it again. - if $0 stop $other_args; then - $0 start $other_args - else - log_failure_msg "Failed to stop running server, so refusing to try to start." - exit 1 - fi - ;; - - 'reload'|'force-reload') - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" - touch "$mysqld_pid_file_path" - else - log_failure_msg "MySQL PID file could not be found!" - exit 1 - fi - ;; - 'status') - # First, check to see if pid file exists - if test -s "$mysqld_pid_file_path" ; then - read mysqld_pid < "$mysqld_pid_file_path" - if kill -0 $mysqld_pid 2>/dev/null ; then - log_success_msg "MySQL running ($mysqld_pid)" - exit 0 - else - log_failure_msg "MySQL is not running, but PID file exists" - exit 1 - fi - else - # Try to find appropriate mysqld process - mysqld_pid=`pidof $libexecdir/mysqld` - - # test if multiple pids exist - pid_count=`echo $mysqld_pid | wc -w` - if test $pid_count -gt 1 ; then - log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" - exit 5 - elif test -z $mysqld_pid ; then - if test -f "$lock_file_path" ; then - log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" - exit 2 - fi - log_failure_msg "MySQL is not running" - exit 3 - else - log_failure_msg "MySQL is running but PID file could not be found" - exit 4 - fi - fi - ;; - *) - # usage - basename=`basename "$0"` - echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" - exit 1 - ;; -esac - -exit 0 diff --git a/plugins/mariadb/versions/10.6/install.sh b/plugins/mariadb/versions/10.6/install.sh index 72036590c..8c092355a 100755 --- a/plugins/mariadb/versions/10.6/install.sh +++ b/plugins/mariadb/versions/10.6/install.sh @@ -46,6 +46,7 @@ Install_app() if [ ! -d $serverPath/mariadb ];then cd ${mariadbDir}/mariadb-${MY_VER} && cmake \ -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ + -DMYSQL_DATADIR=$serverPath/mariadb/data/ -DMYSQL_USER=mysql \ -DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ From c1d6566f08ff9fbd67f326b7907070b9cdb706fc Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 14:09:02 +0800 Subject: [PATCH 031/173] up --- plugins/mariadb/conf/{mysql.sql => mariadb.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/mariadb/conf/{mysql.sql => mariadb.sql} (100%) diff --git a/plugins/mariadb/conf/mysql.sql b/plugins/mariadb/conf/mariadb.sql similarity index 100% rename from plugins/mariadb/conf/mysql.sql rename to plugins/mariadb/conf/mariadb.sql From 5b7538e962b42cb3cea2090645b74c6ea2e42e97 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 14:22:19 +0800 Subject: [PATCH 032/173] Update install.sh --- plugins/mariadb/versions/10.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/versions/10.6/install.sh b/plugins/mariadb/versions/10.6/install.sh index 8c092355a..ee0b9c49d 100755 --- a/plugins/mariadb/versions/10.6/install.sh +++ b/plugins/mariadb/versions/10.6/install.sh @@ -46,7 +46,7 @@ Install_app() if [ ! -d $serverPath/mariadb ];then cd ${mariadbDir}/mariadb-${MY_VER} && cmake \ -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ - -DMYSQL_DATADIR=$serverPath/mariadb/data/ + -DMYSQL_DATADIR=$serverPath/mariadb/data/ \ -DMYSQL_USER=mysql \ -DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ From 13a90e5d5536d6634e95f13f5bf0f318e95239df Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 14:28:13 +0800 Subject: [PATCH 033/173] up --- plugins/mariadb/index.py | 5 ----- plugins/mysql/index.py | 5 ----- 2 files changed, 10 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index bed83d156..cbe8b5181 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -198,11 +198,6 @@ def initDreplace(version=''): def status(version=''): - data = mw.execShell( - "ps -ef|grep mysqld |grep -v grep | grep -v python | awk '{print $2}'") - if data[0] == '': - return 'stop' - pid = getPidFile() if not os.path.exists(pid): return 'stop' diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 92198e17b..8a4898ae2 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -198,11 +198,6 @@ def initDreplace(version=''): def status(version=''): - data = mw.execShell( - "ps -ef|grep mysqld |grep -v grep | grep -v python | awk '{print $2}'") - if data[0] == '': - return 'stop' - pid = getPidFile() if not os.path.exists(pid): return 'stop' From 69eefd8b37be88e4c651594feed3422bc9a71e5c Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 14:58:21 +0800 Subject: [PATCH 034/173] Update index.py --- plugins/mariadb/index.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index cbe8b5181..e2ad096dd 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -567,20 +567,22 @@ def setDbStatus(): def isSqlError(mysqlMsg): # 检测数据库执行错误 - mysqlMsg = str(mysqlMsg) - if "MySQLdb" in mysqlMsg: + errMsg = str(mysqlMsg) + if "MySQLdb" in errMsg: return mw.returnJson(False, 'MySQLdb组件缺失!
进入SSH命令行输入: pip install mysql-python | pip install mysqlclient==2.0.3') - if "2002," in mysqlMsg: + if "2002," in errMsg: return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') - if "2003," in mysqlMsg: + if "2003," in errMsg: return mw.returnJson(False, "Can't connect to MySQL server on '127.0.0.1' (61)") - if "using password:" in mysqlMsg: + if "1698," in errMsg: + return mw.returnJson(False, data[1]) + if "using password:" in errMsg: return mw.returnJson(False, '数据库管理密码错误!') - if "Connection refused" in mysqlMsg: + if "Connection refused" in errMsg: return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') - if "1133" in mysqlMsg: + if "1133" in errMsg: return mw.returnJson(False, '数据库用户不存在!') - if "1007" in mysqlMsg: + if "1007" in errMsg: return mw.returnJson(False, '数据库已经存在!') return None From 1252efdae1549aa305ec859ccf2f635ca4638c8f Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:00:28 +0800 Subject: [PATCH 035/173] Update index.py --- plugins/mariadb/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index e2ad096dd..44814dc2f 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -565,9 +565,9 @@ def setDbStatus(): return mw.returnJson(True, '设置成功!') -def isSqlError(mysqlMsg): +def isSqlError(data): # 检测数据库执行错误 - errMsg = str(mysqlMsg) + errMsg = str(data) if "MySQLdb" in errMsg: return mw.returnJson(False, 'MySQLdb组件缺失!
进入SSH命令行输入: pip install mysql-python | pip install mysqlclient==2.0.3') if "2002," in errMsg: From 6b04a06d9c550f8ad4b36779a6df9522c88ac0bd Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:05:31 +0800 Subject: [PATCH 036/173] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 44814dc2f..1f100292c 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -575,7 +575,7 @@ def isSqlError(data): if "2003," in errMsg: return mw.returnJson(False, "Can't connect to MySQL server on '127.0.0.1' (61)") if "1698," in errMsg: - return mw.returnJson(False, data[1]) + return mw.returnJson(False, "Access denied for user 'root'@'localhost'") if "using password:" in errMsg: return mw.returnJson(False, '数据库管理密码错误!') if "Connection refused" in errMsg: From 7a0f93bcb686acb9b5f1438027c50a3697b01a7a Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:14:11 +0800 Subject: [PATCH 037/173] Update index.py --- plugins/mariadb/index.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 1f100292c..f0172d068 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -49,31 +49,9 @@ def getInitDFile(): return '/etc/init.d/' + getPluginName() -def is_number(s): - try: - float(s) - return True - except ValueError: - pass - - try: - import unicodedata - unicodedata.numeric(s) - return True - except (TypeError, ValueError): - pass - - return False - - def getArgs(): args = sys.argv[2:] - # print(args) - - # if is_number(args): - # args = sys.argv[3:] - tmp = {} args_len = len(args) From 0f6cadb14617c94eef4095a2d4c7742a73aa98fd Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:27:34 +0800 Subject: [PATCH 038/173] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index f0172d068..e3812f859 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -154,7 +154,7 @@ def initDreplace(version=''): mysql_conf = mysql_conf_dir + '/my.cnf' if not os.path.exists(mysql_conf): - mysql_conf_tpl = getPluginDir() + '/conf/my' + version + '.cnf' + mysql_conf_tpl = getPluginDir() + '/conf/my.cnf' content = mw.readFile(mysql_conf_tpl) content = contentReplace(content) mw.writeFile(mysql_conf, content) From ac65bbcc1bc69f167d61db84feb86da2bed15098 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:30:58 +0800 Subject: [PATCH 039/173] Update install.sh --- plugins/mariadb/versions/10.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/versions/10.6/install.sh b/plugins/mariadb/versions/10.6/install.sh index ee0b9c49d..857815354 100755 --- a/plugins/mariadb/versions/10.6/install.sh +++ b/plugins/mariadb/versions/10.6/install.sh @@ -48,7 +48,7 @@ Install_app() -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ -DMYSQL_DATADIR=$serverPath/mariadb/data/ \ -DMYSQL_USER=mysql \ - -DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \ + -DMYSQL_UNIX_ADDR=$serverPath/mariadb/mysql.sock \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ From e8b9c5c33dfca4e152390f6f50527cc88827eed6 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:50:03 +0800 Subject: [PATCH 040/173] Update index.py --- plugins/mariadb/index.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index e3812f859..55b0f92b7 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -310,9 +310,10 @@ def initMysqlPwd(): # "UPDATE mysql.user SET password=PASSWORD('" + \ # pwd + "') WHERE user='root'" cmd_pass = serverdir + '/bin/mysql -uroot -e' - cmd_pass = cmd_pass + "\"UPDATE mysql.user SET password=PASSWORD('" + \ - pwd + "') WHERE user='root';" + cmd_pass = cmd_pass + \ + "\"grant all privileges on *.* to 'root'@'localhost' identified by '" + pwd + "';" cmd_pass = cmd_pass + "flush privileges;\"" + data = mw.execShell(cmd_pass) # print(data) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) From 44f71ed823efe2dbe6c5936f4f5679c0ce93034d Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 15:52:09 +0800 Subject: [PATCH 041/173] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 55b0f92b7..066062b23 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -309,7 +309,7 @@ def initMysqlPwd(): # cmd_pass = cmd_pass + \ # "UPDATE mysql.user SET password=PASSWORD('" + \ # pwd + "') WHERE user='root'" - cmd_pass = serverdir + '/bin/mysql -uroot -e' + cmd_pass = serverdir + '/bin/mysql -S ' + serverdir + '/mysql.sock -uroot -e' cmd_pass = cmd_pass + \ "\"grant all privileges on *.* to 'root'@'localhost' identified by '" + pwd + "';" cmd_pass = cmd_pass + "flush privileges;\"" From 676fee62d7ea731ee4baca83485f54254c69bdfd Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 16:00:53 +0800 Subject: [PATCH 042/173] Update index.py --- plugins/mariadb/index.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 066062b23..59bc2b741 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -301,14 +301,7 @@ def initMysqlPwd(): serverdir = getServerDir() pwd = mw.getRandomString(16) - # cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd - # cmd_pass = "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'127.0.0.1')" - # cmd_pass = cmd_pass + \ - # "insert into mysql.user(Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Show_db_priv,Super_priv,Create_tmp_table_priv,Lock_tables_priv,Execute_priv,Repl_slave_priv,Repl_client_priv,Create_view_priv,Show_view_priv,Create_routine_priv,Alter_routine_priv,Create_user_priv,Event_priv,Trigger_priv,Create_tablespace_priv,User,Password,host)values('Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','root',password('" + pwd + "'),'localhost')" - # cmd_pass = cmd_pass + \ - # "UPDATE mysql.user SET password=PASSWORD('" + \ - # pwd + "') WHERE user='root'" cmd_pass = serverdir + '/bin/mysql -S ' + serverdir + '/mysql.sock -uroot -e' cmd_pass = cmd_pass + \ "\"grant all privileges on *.* to 'root'@'localhost' identified by '" + pwd + "';" From 5f8c0e1a8deb387bee6b1b9902678cb54998289d Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 21:57:48 +0800 Subject: [PATCH 043/173] up --- route/static/app/config.js | 2 +- route/static/language/Simplified_Chinese/lan.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/route/static/app/config.js b/route/static/app/config.js index 226707a3e..0b546395c 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -281,7 +281,7 @@ function getPanelSSL(){ \ \
    \ -
  • 粘贴您的*.key以及*.pem内容,然后保存即可[帮助]。
  • \ +
  • 粘贴您的*.key以及*.pem内容,然后保存即可。
  • \
  • 如果浏览器提示证书链不完整,请检查是否正确拼接PEM证书
  • PEM格式证书 = 域名证书.crt + 根证书(root_bundle).crt
  • \
\ ' diff --git a/route/static/language/Simplified_Chinese/lan.js b/route/static/language/Simplified_Chinese/lan.js index aabb15abb..2cbed3d03 100755 --- a/route/static/language/Simplified_Chinese/lan.js +++ b/route/static/language/Simplified_Chinese/lan.js @@ -917,7 +917,7 @@ var lan = { "bt_ssl_help_7":"有效期1年,不支持续签,到期后需要重新申请", "bt_ssl_help_8":"Let\'s Encrypt免费证书,有效期3个月,支持多域名。默认会自动续签", "bt_ssl_help_9":"若您的站点使用了CDN或301重定向会导致续签失败", - "bt_ssl_help_10":"粘贴您的*.key以及*.pem内容,然后保存即可[帮助]。", + "bt_ssl_help_10":"粘贴您的*.key以及*.pem内容,然后保存即可。", "phone_input":"请输入手机号码", "ssl_apply_1":"正在提交订单,请稍后..", "ssl_apply_2":"正在校验域名,请稍后..", From c8fc610c1642436000b3ea9ca234d1ca5b9aabe2 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 21:59:56 +0800 Subject: [PATCH 044/173] Update lan.js --- .../static/language/Simplified_Chinese/lan.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/route/static/language/Simplified_Chinese/lan.js b/route/static/language/Simplified_Chinese/lan.js index 2cbed3d03..bcc28814c 100755 --- a/route/static/language/Simplified_Chinese/lan.js +++ b/route/static/language/Simplified_Chinese/lan.js @@ -108,17 +108,17 @@ var lan = { }, "config":{ - "close_panel_msg":"关闭面板会导致您无法访问面板 ,您真的要关闭宝塔Linux面板吗?", + "close_panel_msg":"关闭面板会导致您无法访问面板 ,您真的要关闭Linux面板吗?", "close_panel_title":"关闭面板", "config_save":"正在保存配置...", "config_sync":"正在同步时间...", - "config_user_binding":"绑定宝塔帐号", - "config_user_edit":"修改绑定宝塔账号", + "config_user_binding":"绑定帐号", + "config_user_edit":"修改绑定账号", "binding":"绑定", "token_get":"正在获取密钥...", - "user_bt":"宝塔官网账户", - "pass_bt":"宝塔官网密码", - "binding_un_msg":"您确定要解除绑定宝塔帐号码?", + "user_bt":"官网账户", + "pass_bt":"官网密码", + "binding_un_msg":"您确定要解除绑定帐号码?", "binding_un_title":"解除绑定", "binding_un":"解绑", "ssl_close_msg":"关闭SSL后,必需使用http协议访问面板,继续吗?", @@ -333,7 +333,7 @@ var lan = { "install_ok":"已将安装请求添加到安装器", "task_add":"已添加到队列", "panel_open":"正在打开面板...", - "panel_add":"关联宝塔面板", + "panel_add":"关联面板", "panel_edit":"修改关联", "panel_err_format":"面板地址格式不正确,示例:", "panel_err_empty":"面板资料不能为空", @@ -890,7 +890,7 @@ var lan = { "enable_301":"启用301", "to301_help_1":"选择[整站]时请不要将目标URL设为同一站点下的域名.", "to301_help_2":"取消301重定向后,需清空浏览器缓存才能看到生效结果.", - "bt_ssl":"宝塔SSL", + "bt_ssl":"SSL", "lets_ssl":"Let\'s Encrypt免费证书", "other":"其它", "other_ssl":"其他证书", @@ -901,19 +901,19 @@ var lan = { "ssl_key":"密钥(KEY)", "ssl_crt":"证书(PEM格式)", "ssl_close":"关闭SSL", - "bt_bind_no":"未绑定宝塔账号,请注册绑定,绑定宝塔账号(非论坛账号)可实现一键部署SSL", - "bt_user":"宝塔账号", + "bt_bind_no":"未绑定账号,请注册绑定,绑定账号(非论坛账号)可实现一键部署SSL", + "bt_user":"账号", "login":"登录", - "bt_reg":"注册宝塔账号", - "bt_ssl_help_1":"宝塔SSL证书为亚洲诚信证书,需要实名认证才能申请使用", - "bt_ssl_help_2":"已有宝塔账号请登录绑定", - "bt_ssl_help_3":"宝塔SSL申请的是TrustAsia DV SSL CA - G5 原价:1900元/1年,宝塔用户免费!", + "bt_reg":"注册账号", + "bt_ssl_help_1":"SSL证书为亚洲诚信证书,需要实名认证才能申请使用", + "bt_ssl_help_2":"已有账号请登录绑定", + "bt_ssl_help_3":"SSL申请的是TrustAsia DV SSL CA - G5 原价:1900元/1年,用户免费!", "bt_ssl_help_4":"一年满期后免费颁发。", "btapply":"申请", "endtime":"到期时间", "status":"状态", "bt_ssl_help_5":"申请之前,请确保域名已解析,如未解析会导致审核失败", - "bt_ssl_help_6":"宝塔SSL申请的是免费版TrustAsia DV SSL CA - G5证书,仅支持单个域名申请", + "bt_ssl_help_6":"SSL申请的是免费版TrustAsia DV SSL CA - G5证书,仅支持单个域名申请", "bt_ssl_help_7":"有效期1年,不支持续签,到期后需要重新申请", "bt_ssl_help_8":"Let\'s Encrypt免费证书,有效期3个月,支持多域名。默认会自动续签", "bt_ssl_help_9":"若您的站点使用了CDN或301重定向会导致续签失败", From d551f96a40e90ef5143ceaa38af022e941eb78b9 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 22:43:01 +0800 Subject: [PATCH 045/173] up --- plugins/mongodb/index.py | 4 ++-- plugins/mongodb/install.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index ee80ea48e..7e551167a 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -238,8 +238,8 @@ def installPreInspection(version): sysName = sys[0].strip().lower() sysId = sys_id[0].strip() - if not sysName in ('centos', 'ubuntu', 'debian'): - return '暂时仅支持centos,ubuntu,debian' + if not sysName in ('centos', 'fedora', 'ubuntu', 'debian'): + return '暂时仅不支持{}'.format(sysName) if sysName == 'debian': if version > 10: diff --git a/plugins/mongodb/install.sh b/plugins/mongodb/install.sh index c94b2506a..88ea41ba6 100755 --- a/plugins/mongodb/install.sh +++ b/plugins/mongodb/install.sh @@ -208,7 +208,7 @@ Install_app_linux() Install_Linux_Ubuntu elif [ "$OSNAME" == "debian" ];then Install_Linux_Debian - elif [ "$OSNAME" == "centos" ];then + elif [ "$OSNAME" == "centos" ] || [ "$OSNAME" == "fedora" ];then Install_Linux_CentOS elif [ "$OSNAME" == "opensuse" ];then Install_Linux_Opensuse @@ -250,7 +250,7 @@ if [ "$OSNAME" == "ubuntu" ];then Uninstall_Linux_Ubuntu elif [ "$OSNAME" == "debian" ];then Uninstall_Linux_Debian -elif [ "$OSNAME" == "centos" ];then +elif [ "$OSNAME" == "centos" ] || [ "$OSNAME" == "fedora" ];then Uninstall_Linux_CentOS elif [ "$OSNAME" == "opensuse" ];then Uninstall_Linux_Opensuse From 38ec3721cd5b582bc2a8915d4b282439e356c5a7 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 22:58:34 +0800 Subject: [PATCH 046/173] Update all_test.sh --- plugins/php/versions/all_test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/php/versions/all_test.sh b/plugins/php/versions/all_test.sh index 8b0af6dd7..24db485d4 100644 --- a/plugins/php/versions/all_test.sh +++ b/plugins/php/versions/all_test.sh @@ -49,6 +49,11 @@ PHP_EXT_LIST=(ioncube ZendGuardLoader pdo mysqlnd sqlite3 openssl pcntl opcache for PHP_VER in ${PHP_VER_LIST[@]}; do echo "php${PHP_VER} -- start" + if [ ! -d /www/server/php/${PHP_VER} ];then + echo "php{$PHP_VER} is not install!" + break; + fi + NON_ZTS_FILENAME=`ls /www/server/php/${PHP_VER}/lib/php/extensions | grep no-debug-non-zts` for EXT in ${PHP_EXT_LIST[@]}; do extFile=/www/server/php/${PHP_VER}/lib/php/extensions/${NON_ZTS_FILENAME}/${EXT}.so From febbe2c2c9c040f72e748b6a66595e1abb4865d8 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:10:07 +0800 Subject: [PATCH 047/173] Update seaslog.sh --- plugins/php/versions/common/seaslog.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/common/seaslog.sh b/plugins/php/versions/common/seaslog.sh index b31603e48..58921c749 100755 --- a/plugins/php/versions/common/seaslog.sh +++ b/plugins/php/versions/common/seaslog.sh @@ -24,7 +24,8 @@ if [ "$version" -lt "72" ];then fi NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extDir=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/ +extDir=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME} +extFile=$extDir/${_LIBNAME}.so if [ "$sysName" == "Darwin" ];then BAK='_bak' @@ -40,7 +41,7 @@ Install_lib() return fi - extFile=$extDir${_LIBNAME}.so + if [ ! -f "$extFile" ];then OPTIONS='' @@ -85,12 +86,12 @@ Uninstall_lib() return fi - extFile=$extDir${_LIBNAME}.so if [ ! -f "$extFile" ];then echo "php-$version 未安装${LIBNAME},请选择其它版本!" echo "php-$version not install ${LIBNAME}, Plese select other version!" return fi + _LIBNAME=$(echo $LIBNAME | tr '[A-Z]' '[a-z]') sed -i $BAK "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini sed -i $BAK "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini From 435a1679bd81c122ec4ee1771e30d7331218134e Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:10:44 +0800 Subject: [PATCH 048/173] Update seaslog.sh --- plugins/php/versions/common/seaslog.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/common/seaslog.sh b/plugins/php/versions/common/seaslog.sh index 58921c749..7b429bab9 100755 --- a/plugins/php/versions/common/seaslog.sh +++ b/plugins/php/versions/common/seaslog.sh @@ -24,8 +24,7 @@ if [ "$version" -lt "72" ];then fi NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extDir=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME} -extFile=$extDir/${_LIBNAME}.so +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${_LIBNAME}.so if [ "$sysName" == "Darwin" ];then BAK='_bak' @@ -91,7 +90,7 @@ Uninstall_lib() echo "php-$version not install ${LIBNAME}, Plese select other version!" return fi - + _LIBNAME=$(echo $LIBNAME | tr '[A-Z]' '[a-z]') sed -i $BAK "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini sed -i $BAK "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini From c349684d1c435204f86e4ba4cfe63d478cf4c302 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:15:27 +0800 Subject: [PATCH 049/173] Update install.sh --- plugins/varnish/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index 671e4adea..95e5365d8 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -36,7 +36,7 @@ Install_varnish() if [ "${OSNAME}" == "macos" ]; then brew install varnish - elif [ "${OSNAME}" == "centos" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ]; then yum install varnish -y elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then apt install varnish -y From 8b85ef108f5ed3da8d6775dcc7d42784ea291219 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:16:20 +0800 Subject: [PATCH 050/173] Update install.sh --- plugins/varnish/install.sh | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index 95e5365d8..afb5471c2 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -7,27 +7,14 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") - install_tmp=${rootPath}/tmp/mw_install.pl - VERSION=$2 -_os=`uname` -if [ ${_os} == "Darwin" ]; then - OSNAME='macos' -elif grep -Eq "openSUSE" /etc/*-release; then - OSNAME='opensuse' -elif grep -Eq "CentOS" /etc/*-release; then - OSNAME='centos' -elif grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' -elif grep -Eq "Debian" /etc/*-release; then - OSNAME='debian' -elif grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='ubuntu' -else - OSNAME='unknow' -fi + +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + Install_varnish() { From c7648ef6ed851a63fb20e33256709706da2567b6 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:16:39 +0800 Subject: [PATCH 051/173] Update install.sh --- plugins/varnish/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index afb5471c2..a0fdb5d37 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -51,7 +51,7 @@ Uninstall_varnish() brew uninstall varnish elif [ "${OSNAME}" == "centos" ]; then yum remove varnish -y - elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ]; then apt remove varnish -y elif [ "${OSNAME}" == "opensuse" ];then zypper remove -y varnish From c71bc2d9e3165699c6fdbd11aa79d3fc65dfff25 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:18:30 +0800 Subject: [PATCH 052/173] Update redis.sh --- plugins/php/versions/common/redis.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/php/versions/common/redis.sh b/plugins/php/versions/common/redis.sh index 97511276e..18977503b 100755 --- a/plugins/php/versions/common/redis.sh +++ b/plugins/php/versions/common/redis.sh @@ -27,7 +27,7 @@ fi NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extDir=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/ +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so if [ "$sysName" == "Darwin" ];then BAK='_bak' @@ -37,13 +37,13 @@ fi Install_lib() { - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + isInstall=`cat $serverPath/php/${version}/etc/php.ini|grep "${LIBNAME}.so"` if [ "${isInstall}" != "" ];then echo "php-$version 已安装${LIBNAME},请选择其它版本!" return fi - extFile=$extDir${LIBNAME}.so + if [ ! -f "$extFile" ];then php_lib=$sourcePath/php_lib @@ -80,8 +80,7 @@ Uninstall_lib() echo "php-$version 未安装,请选择其它版本!" return fi - - extFile=$extDir${LIBNAME}.so + if [ ! -f "$extFile" ];then echo "php-$version 未安装${LIBNAME},请选择其它版本!" echo "php-$version not install memcache, Plese select other version!" From ea3106c9f31ec63bdf7cdc4b5b96e8660fe48695 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:19:22 +0800 Subject: [PATCH 053/173] Update xdebug.sh --- plugins/php/versions/common/xdebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/xdebug.sh b/plugins/php/versions/common/xdebug.sh index 5911fcf7a..47a30921a 100755 --- a/plugins/php/versions/common/xdebug.sh +++ b/plugins/php/versions/common/xdebug.sh @@ -36,7 +36,7 @@ fi Install_lib() { - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + isInstall=`cat $serverPath/php/${version}/etc/php.ini|grep "${LIBNAME}.so"` if [ "${isInstall}" != "" ];then echo "php-$version 已安装${LIBNAME},请选择其它版本!" return From 2e1d19fedc48a9d0ffcec7b11797476c41a16821 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:20:42 +0800 Subject: [PATCH 054/173] Update all_test.sh --- plugins/php/versions/all_test.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugins/php/versions/all_test.sh b/plugins/php/versions/all_test.sh index 24db485d4..aa8c9d635 100644 --- a/plugins/php/versions/all_test.sh +++ b/plugins/php/versions/all_test.sh @@ -6,13 +6,7 @@ ROOT_DIR=$(cd "$(dirname "$0")"; pwd) # cd /www/server/mdserver-web/scripts/quick && bash debug.sh # cd /www/server/mdserver-web/plugins/php/versions && /bin/bash all_test.sh - -# cd /www/server/mdserver-web/plugins/php && bash install.sh install 71 -# cd /www/server/mdserver-web/plugins/php/versions/52/ && bash gd.sh install 52 - -# cd /www/server/mdserver-web/plugins/php/versions/52/ && bash openssl.sh install 52 -# cd /www/server/mdserver-web/plugins/php/versions/81/ && bash imagemagick.sh install 81 -# cd /www/server/mdserver-web/plugins/php/versions/70/ && bash imagemagick.sh install 70 +# cd /www/server/mdserver-web/plugins/php/versions/common && bash swoole.sh install 72 # PHP_VER=52 From 0b9c152ebbc9176fae18b0c809d0b73f9a333d14 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:21:26 +0800 Subject: [PATCH 055/173] Update all_test.sh --- plugins/php/versions/all_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/all_test.sh b/plugins/php/versions/all_test.sh index aa8c9d635..98a29ebd0 100644 --- a/plugins/php/versions/all_test.sh +++ b/plugins/php/versions/all_test.sh @@ -6,7 +6,7 @@ ROOT_DIR=$(cd "$(dirname "$0")"; pwd) # cd /www/server/mdserver-web/scripts/quick && bash debug.sh # cd /www/server/mdserver-web/plugins/php/versions && /bin/bash all_test.sh -# cd /www/server/mdserver-web/plugins/php/versions/common && bash swoole.sh install 72 +# cd /www/server/mdserver-web/plugins/php/versions/common && bash swoole.sh install 81 # PHP_VER=52 From 75aa6a35e64a5bfbcd064c49f8965eaea7fae49f Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 12 Jul 2022 23:59:16 +0800 Subject: [PATCH 056/173] Update fedora.sh --- scripts/install/fedora.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index fbba069c6..f76968118 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -71,7 +71,7 @@ yum -y install epel-release yum install -y libevent libevent-devel libxslt* libjpeg* libpng* gd* zip libmcrypt libmcrypt-devel yum install -y gcc libffi-devel python-devel openssl-devel -yum -y install wget python-devel python-imaging libicu-devel unzip bzip2-devel gcc libxml2 libxml2-dev libjpeg-devel libpng-devel libwebp libwebp-devel lsof pcre pcre-devel vixie-cron crontabs +yum -y install wget python-devel python-imaging libicu-devel unzip bzip2-devel gcc libxml2 libxml2-devel libjpeg-devel libpng-devel libwebp libwebp-devel lsof pcre pcre-devel crontabs yum -y install net-tools yum -y install ncurses-devel mysql-devel cmake yum -y install python-devel From fa127227b736f194be92247bc59f52d0bdcb192d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 00:29:05 +0800 Subject: [PATCH 057/173] Update install.sh --- plugins/mongodb/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mongodb/install.sh b/plugins/mongodb/install.sh index 88ea41ba6..c94b2506a 100755 --- a/plugins/mongodb/install.sh +++ b/plugins/mongodb/install.sh @@ -208,7 +208,7 @@ Install_app_linux() Install_Linux_Ubuntu elif [ "$OSNAME" == "debian" ];then Install_Linux_Debian - elif [ "$OSNAME" == "centos" ] || [ "$OSNAME" == "fedora" ];then + elif [ "$OSNAME" == "centos" ];then Install_Linux_CentOS elif [ "$OSNAME" == "opensuse" ];then Install_Linux_Opensuse @@ -250,7 +250,7 @@ if [ "$OSNAME" == "ubuntu" ];then Uninstall_Linux_Ubuntu elif [ "$OSNAME" == "debian" ];then Uninstall_Linux_Debian -elif [ "$OSNAME" == "centos" ] || [ "$OSNAME" == "fedora" ];then +elif [ "$OSNAME" == "centos" ];then Uninstall_Linux_CentOS elif [ "$OSNAME" == "opensuse" ];then Uninstall_Linux_Opensuse From e02cb62771d8a0159fc65864251783b63b06e076 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 00:34:41 +0800 Subject: [PATCH 058/173] Update install.sh --- plugins/pureftp/install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/pureftp/install.sh b/plugins/pureftp/install.sh index 83860e62c..1a00473be 100755 --- a/plugins/pureftp/install.sh +++ b/plugins/pureftp/install.sh @@ -51,8 +51,10 @@ Install_pureftp() VER=$1 DOWNLOAD=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${VER}.tar.gz + # curl -sSLo pure-ftpd-1.0.49.tar.gz https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz if [ ! -f $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz ];then - wget --no-check-certificate -O $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD + # wget --no-check-certificate -O $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD + curl -sSLo $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD fi #检测文件是否损坏. From 9e26a30c7fdb93e7792ffa0f234231e346f04df7 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 00:34:59 +0800 Subject: [PATCH 059/173] Update install.sh --- plugins/pureftp/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pureftp/install.sh b/plugins/pureftp/install.sh index 1a00473be..9c8607d71 100755 --- a/plugins/pureftp/install.sh +++ b/plugins/pureftp/install.sh @@ -66,7 +66,7 @@ Install_pureftp() else # 重新下载 rm -rf $serverPath/source/pureftp/pure-ftpd-${VER} - wget --no-check-certificate -O $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD + curl -sSLo $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD fi fi From e7eb176c348f03b7b66e44ef01834b2831c7341e Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:04:53 +0800 Subject: [PATCH 060/173] up --- plugins/php-yum/install.sh | 19 +++++++++++++++++++ plugins/php-yum/versions/74/install.sh | 6 +----- plugins/php-yum/versions/80/install.sh | 5 +---- plugins/php-yum/versions/81/install.sh | 7 +------ plugins/php-yum/versions/82/install.sh | 11 ----------- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/plugins/php-yum/install.sh b/plugins/php-yum/install.sh index 0412dffc1..4e3aa257f 100755 --- a/plugins/php-yum/install.sh +++ b/plugins/php-yum/install.sh @@ -32,6 +32,25 @@ if [ ! -d $curPath/versions/$2 ];then fi + +#获取信息和版本 +# bash /www/server/mdsever-web/scripts/getos.sh +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + + +if [ "$OSNAME" == "centos" ];then + rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm +fi + + +if [ "$OSNAME" == "fedora" ];then + rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-${VERSION_ID}.rpm +fi + + + if [ "${action}" == "uninstall" ] && [ -d ${serverPath}/php-yum/${type} ];then #初始化 cd ${rootPath} && python3 ${rootPath}/plugins/php-yum/index.py stop ${type} diff --git a/plugins/php-yum/versions/74/install.sh b/plugins/php-yum/versions/74/install.sh index ef8f50566..0bca5bd88 100755 --- a/plugins/php-yum/versions/74/install.sh +++ b/plugins/php-yum/versions/74/install.sh @@ -25,11 +25,7 @@ Install_php() { #------------------------ install start ------------------------------------# -### centos start ################ -rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm -yum install -y php74 php74-php-fpm -### centos start ################ - +yum install -y php74 php74-php-fpm if [ "$?" == "0" ];then mkdir -p $serverPath/php-yum/${PHP_VER} fi diff --git a/plugins/php-yum/versions/80/install.sh b/plugins/php-yum/versions/80/install.sh index 99361224b..da3c3d5c3 100755 --- a/plugins/php-yum/versions/80/install.sh +++ b/plugins/php-yum/versions/80/install.sh @@ -25,11 +25,8 @@ Install_php() { #------------------------ install start ------------------------------------# -### centos start ################ -rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm -yum install -y php80 php80-php-fpm -### centos start ################ +yum install -y php80 php80-php-fpm if [ "$?" == "0" ];then mkdir -p $serverPath/php-yum/${PHP_VER} fi diff --git a/plugins/php-yum/versions/81/install.sh b/plugins/php-yum/versions/81/install.sh index f60ec2b71..c8793a83b 100755 --- a/plugins/php-yum/versions/81/install.sh +++ b/plugins/php-yum/versions/81/install.sh @@ -24,12 +24,7 @@ PHP_VER=81 Install_php() { #------------------------ install start ------------------------------------# - -### centos start ################ -rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm -yum install -y php81 php81-php-fpm -### centos start ################ - +yum install -y php81 php81-php-fpm if [ "$?" == "0" ];then mkdir -p $serverPath/php-yum/${PHP_VER} fi diff --git a/plugins/php-yum/versions/82/install.sh b/plugins/php-yum/versions/82/install.sh index 100542c2b..514b3db7e 100755 --- a/plugins/php-yum/versions/82/install.sh +++ b/plugins/php-yum/versions/82/install.sh @@ -11,12 +11,6 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -#获取信息和版本 -# bash /www/server/mdsever-web/scripts/getos.sh -bash ${rootPath}/scripts/getos.sh -OSNAME=`cat ${rootPath}/data/osname.pl` -VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - version=8.2.x PHP_VER=82 @@ -24,12 +18,7 @@ PHP_VER=82 Install_php() { #------------------------ install start ------------------------------------# - -### centos start ################ -rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-${VERSION_ID}.rpm yum install -y php82 php82-php-fpm -### centos start ################ - if [ "$?" == "0" ];then mkdir -p $serverPath/php-yum/${PHP_VER} fi From 1b548cec2cc420c4245661341f7da27a98a8c125 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:06:04 +0800 Subject: [PATCH 061/173] up --- plugins/php-yum/versions/74/install.sh | 7 ------- plugins/php-yum/versions/80/install.sh | 6 ------ plugins/php-yum/versions/81/install.sh | 6 ------ plugins/php-yum/versions/82/install.sh | 2 +- 4 files changed, 1 insertion(+), 20 deletions(-) diff --git a/plugins/php-yum/versions/74/install.sh b/plugins/php-yum/versions/74/install.sh index 0bca5bd88..87abd097b 100755 --- a/plugins/php-yum/versions/74/install.sh +++ b/plugins/php-yum/versions/74/install.sh @@ -10,13 +10,6 @@ sourcePath=${serverPath}/source sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl - -#获取信息和版本 -# bash /www/server/mdsever-web/scripts/getos.sh -bash ${rootPath}/scripts/getos.sh -OSNAME=`cat ${rootPath}/data/osname.pl` -VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - version=7.4.x PHP_VER=74 diff --git a/plugins/php-yum/versions/80/install.sh b/plugins/php-yum/versions/80/install.sh index da3c3d5c3..c3e0b37f0 100755 --- a/plugins/php-yum/versions/80/install.sh +++ b/plugins/php-yum/versions/80/install.sh @@ -11,12 +11,6 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -#获取信息和版本 -# bash /www/server/mdsever-web/scripts/getos.sh -bash ${rootPath}/scripts/getos.sh -OSNAME=`cat ${rootPath}/data/osname.pl` -VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - version=8.0.x PHP_VER=80 diff --git a/plugins/php-yum/versions/81/install.sh b/plugins/php-yum/versions/81/install.sh index c8793a83b..2e6236c0a 100755 --- a/plugins/php-yum/versions/81/install.sh +++ b/plugins/php-yum/versions/81/install.sh @@ -11,12 +11,6 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -#获取信息和版本 -# bash /www/server/mdsever-web/scripts/getos.sh -bash ${rootPath}/scripts/getos.sh -OSNAME=`cat ${rootPath}/data/osname.pl` -VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - version=8.1.x PHP_VER=81 diff --git a/plugins/php-yum/versions/82/install.sh b/plugins/php-yum/versions/82/install.sh index 514b3db7e..fdb66d5a0 100755 --- a/plugins/php-yum/versions/82/install.sh +++ b/plugins/php-yum/versions/82/install.sh @@ -28,7 +28,7 @@ fi Uninstall_php() { - # $serverPath/php-ya/init.d/php${PHP_VER} stop + # $serverPath/php-yum/init.d/php${PHP_VER} stop rm -rf $serverPath/php-yum/${PHP_VER} echo "卸载php-${version}..." > $install_tmp } From a6ca051e11799a4fb83e3bd3e9cbf28829807574 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:13:16 +0800 Subject: [PATCH 062/173] Update install.sh --- plugins/php-yum/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/php-yum/install.sh b/plugins/php-yum/install.sh index 4e3aa257f..8d30ca522 100755 --- a/plugins/php-yum/install.sh +++ b/plugins/php-yum/install.sh @@ -45,6 +45,7 @@ if [ "$OSNAME" == "centos" ];then fi +# rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-31.rpm if [ "$OSNAME" == "fedora" ];then rpm -Uvh http://rpms.remirepo.net/fedora/remi-release-${VERSION_ID}.rpm fi From 2ba0333a785ef9de4962a09ac60068a7a18bae64 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:22:34 +0800 Subject: [PATCH 063/173] cache --- plugins/php/versions/53/gd.sh | 115 +++++++++++++++++++++++++++++ plugins/php/versions/53/install.sh | 6 +- 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100755 plugins/php/versions/53/gd.sh diff --git a/plugins/php/versions/53/gd.sh b/plugins/php/versions/53/gd.sh new file mode 100755 index 000000000..8b14a819a --- /dev/null +++ b/plugins/php/versions/53/gd.sh @@ -0,0 +1,115 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" +Install_lib() +{ + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-xpm \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/53/install.sh b/plugins/php/versions/53/install.sh index aad347ab3..a57969bea 100755 --- a/plugins/php/versions/53/install.sh +++ b/plugins/php/versions/53/install.sh @@ -39,6 +39,9 @@ if [ -f $serverPath/php/53/bin/php ];then return fi +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS='' if [ $sysName == 'Darwin' ]; then OPTIONS='--without-iconv' @@ -46,9 +49,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi From 38851e019f23f3fae9f5ec9b81e96fbc9eeab3da Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:34:01 +0800 Subject: [PATCH 064/173] up --- plugins/php/versions/53/gd.sh | 7 +++++-- plugins/php/versions/53/install.sh | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/53/gd.sh b/plugins/php/versions/53/gd.sh index 8b14a819a..2fa077065 100755 --- a/plugins/php/versions/53/gd.sh +++ b/plugins/php/versions/53/gd.sh @@ -38,8 +38,11 @@ fi # OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" # OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" # OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + Install_lib() { + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` if [ "${isInstall}" != "" ];then @@ -56,15 +59,15 @@ Install_lib() cd $sourcePath/php${version}/ext/${LIBNAME} $serverPath/php/$version/bin/phpize + + #--with-xpm ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ --enable-gd --enable-gd-native-ttf \ --with-webp \ - --with-xpm \ --with-jpeg \ --with-jpeg-dir=/usr/lib \ --with-freetype-dir=${serverPath}/lib/freetype_old \ --with-freetype - make clean && make && make install && make clean fi diff --git a/plugins/php/versions/53/install.sh b/plugins/php/versions/53/install.sh index a57969bea..e81cb2edc 100755 --- a/plugins/php/versions/53/install.sh +++ b/plugins/php/versions/53/install.sh @@ -21,7 +21,6 @@ echo "安装php-5.3.29 ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh From 97bd611ee7bd5d911638317df5e411715f0d4680 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 01:37:06 +0800 Subject: [PATCH 065/173] up --- plugins/php/versions/54/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/54/install.sh | 5 +- plugins/php/versions/55/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/55/install.sh | 3 - plugins/php/versions/56/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/56/install.sh | 3 - plugins/php/versions/70/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/70/install.sh | 3 - plugins/php/versions/71/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/71/install.sh | 3 - plugins/php/versions/72/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/72/install.sh | 3 - plugins/php/versions/73/gd.sh | 118 +++++++++++++++++++++++++++++ plugins/php/versions/73/install.sh | 3 - 14 files changed, 827 insertions(+), 22 deletions(-) create mode 100755 plugins/php/versions/54/gd.sh create mode 100755 plugins/php/versions/55/gd.sh create mode 100755 plugins/php/versions/56/gd.sh create mode 100755 plugins/php/versions/70/gd.sh create mode 100755 plugins/php/versions/71/gd.sh create mode 100755 plugins/php/versions/72/gd.sh create mode 100755 plugins/php/versions/73/gd.sh diff --git a/plugins/php/versions/54/gd.sh b/plugins/php/versions/54/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/54/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/54/install.sh b/plugins/php/versions/54/install.sh index 5cff9c5c6..1fc23cfce 100755 --- a/plugins/php/versions/54/install.sh +++ b/plugins/php/versions/54/install.sh @@ -20,7 +20,7 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh @@ -40,9 +40,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/55/gd.sh b/plugins/php/versions/55/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/55/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/55/install.sh b/plugins/php/versions/55/install.sh index 2025cf53c..1d171d275 100755 --- a/plugins/php/versions/55/install.sh +++ b/plugins/php/versions/55/install.sh @@ -39,9 +39,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/56/gd.sh b/plugins/php/versions/56/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/56/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/56/install.sh b/plugins/php/versions/56/install.sh index 0a86dd34f..cadfffe39 100755 --- a/plugins/php/versions/56/install.sh +++ b/plugins/php/versions/56/install.sh @@ -39,9 +39,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/70/gd.sh b/plugins/php/versions/70/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/70/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/70/install.sh b/plugins/php/versions/70/install.sh index 21a772193..8ab98b059 100755 --- a/plugins/php/versions/70/install.sh +++ b/plugins/php/versions/70/install.sh @@ -39,9 +39,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/71/gd.sh b/plugins/php/versions/71/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/71/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/71/install.sh b/plugins/php/versions/71/install.sh index d1d690fa8..d9fc1d99f 100755 --- a/plugins/php/versions/71/install.sh +++ b/plugins/php/versions/71/install.sh @@ -38,9 +38,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/72/gd.sh b/plugins/php/versions/72/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/72/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/72/install.sh b/plugins/php/versions/72/install.sh index 796eb83a4..1d358ec7a 100755 --- a/plugins/php/versions/72/install.sh +++ b/plugins/php/versions/72/install.sh @@ -39,9 +39,6 @@ if [ $sysName == 'Darwin' ]; then OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" fi diff --git a/plugins/php/versions/73/gd.sh b/plugins/php/versions/73/gd.sh new file mode 100755 index 000000000..2fa077065 --- /dev/null +++ b/plugins/php/versions/73/gd.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` + +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source/php + +actionType=$1 +version=$2 + +LIBNAME=gd +LIBV=0 + + +# if [ "$version" -lt "74" ];then +# echo "not need!" +# exit 1 +# fi + + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so + +sysName=`uname` +if [ "$sysName" == "Darwin" ];then + BAK='_bak' +else + BAK='' +fi + + +# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" +# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" +# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" + + +Install_lib() +{ + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + + isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` + if [ "${isInstall}" != "" ];then + echo "php-$version 已安装${LIBNAME},请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + + if [ ! -d $sourcePath/php${version}/ext ];then + cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + fi + + cd $sourcePath/php${version}/ext/${LIBNAME} + + $serverPath/php/$version/bin/phpize + + #--with-xpm + ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ + --enable-gd --enable-gd-native-ttf \ + --with-webp \ + --with-jpeg \ + --with-jpeg-dir=/usr/lib \ + --with-freetype-dir=${serverPath}/lib/freetype_old \ + --with-freetype + make clean && make && make install && make clean + + fi + + if [ ! -f "$extFile" ];then + echo "ERROR!" + return + fi + + echo "" >> $serverPath/php/$version/etc/php.ini + echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini + echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini + + $serverPath/php/init.d/php${version} restart + echo '===========================================================' + echo 'successful!' +} + + +Uninstall_lib() +{ + if [ ! -f "$serverPath/php/$version/bin/php-config" ];then + echo "php-$version 未安装,请选择其它版本!" + return + fi + + if [ ! -f "$extFile" ];then + echo "php-$version 未安装${LIBNAME},请选择其它版本!" + return + fi + + echo $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini + sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini + + rm -f $extFile + bash ${rootPath}/plugins/php/versions/lib.sh $version restart + echo '===============================================' + echo 'successful!' +} + + + +if [ "$actionType" == 'install' ];then + Install_lib +elif [ "$actionType" == 'uninstall' ];then + Uninstall_lib +fi \ No newline at end of file diff --git a/plugins/php/versions/73/install.sh b/plugins/php/versions/73/install.sh index ee80cff87..21f742e8d 100755 --- a/plugins/php/versions/73/install.sh +++ b/plugins/php/versions/73/install.sh @@ -43,9 +43,6 @@ if [ $sysName == 'Darwin' ]; then # OPTIONS="${OPTIONS} --enable-zip" else OPTIONS="--with-iconv=${serverPath}/lib/libiconv" - OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" - OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" - OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" OPTIONS="${OPTIONS} --with-curl" OPTIONS="${OPTIONS} --with-libzip=${serverPath}/lib/libzip" fi From 88c20d2516cb8f58cc7366ea35b3acddf8b9b4f2 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 02:00:14 +0800 Subject: [PATCH 066/173] Update phplib.conf --- plugins/php/versions/phplib.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/php/versions/phplib.conf b/plugins/php/versions/phplib.conf index 2f99083b6..eac4b8284 100755 --- a/plugins/php/versions/phplib.conf +++ b/plugins/php/versions/phplib.conf @@ -157,6 +157,14 @@ "name": "gd", "versions": [ "52", + "53", + "54", + "55", + "56", + "70", + "71", + "72", + "73", "74", "80", "81" From 3aa81a794cd27d2d628b1eec01d1c818671e9834 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 02:26:05 +0800 Subject: [PATCH 067/173] up --- plugins/mariadb/class/{mysqlDb.py => orm.py} | 29 ++++++-------------- plugins/mariadb/index.py | 2 +- 2 files changed, 10 insertions(+), 21 deletions(-) rename plugins/mariadb/class/{mysqlDb.py => orm.py} (63%) diff --git a/plugins/mariadb/class/mysqlDb.py b/plugins/mariadb/class/orm.py similarity index 63% rename from plugins/mariadb/class/mysqlDb.py rename to plugins/mariadb/class/orm.py index 867d3f3d7..358309240 100755 --- a/plugins/mariadb/class/mysqlDb.py +++ b/plugins/mariadb/class/orm.py @@ -4,7 +4,8 @@ import re import os import sys -# sys.path.append("/usr/local/lib/python3.9/site-packages") + +from mysql import connector sys.path.append(os.getcwd() + "/class/core") import mw @@ -16,7 +17,7 @@ import mw # sys.path.append(p) -class mysqlDb: +class ORM: __DB_PASS = None __DB_USER = 'root' __DB_PORT = 3306 @@ -29,32 +30,20 @@ class mysqlDb: def __Conn(self): '''连接MYSQL数据库''' try: - import mw - socket = '/www/server/mysql/mysql.sock' - try: - import MySQLdb - except Exception as ex: - # print('dd') - self.__DB_ERR = ex - return False + socket = '/www/server/mariadb/mysql.sock' try: myconf = mw.readFile(self.__DB_CNF) rep = "port\s*=\s*([0-9]+)" self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) except: self.__DB_PORT = 3306 - # print self.__DB_PASS - #self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root') - try: - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except MySQLdb.Error as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + self.__DB_CUR = self.__DB_CONN.cursor() return True - except MySQLdb.Error as e: + except Exception as e: self.__DB_ERR = e return False diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 59bc2b741..a848e4924 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -121,7 +121,7 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mysqlDb.mysqlDb() + db = orm.ORM() db.__DB_CNF = getConf() db.setDbConf(getConf()) db.setPwd(pSqliteDb('config').where( From 2d6de15db1a60cae9829a918d7b20e78154be0ba Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 02:29:48 +0800 Subject: [PATCH 068/173] Update tools.py --- plugins/mariadb/scripts/tools.py | 54 ++------------------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/plugins/mariadb/scripts/tools.py b/plugins/mariadb/scripts/tools.py index d54330376..025cef105 100755 --- a/plugins/mariadb/scripts/tools.py +++ b/plugins/mariadb/scripts/tools.py @@ -50,70 +50,20 @@ echo '===========================================' echo "root密码成功修改为: ${pwd}" echo "The root password set ${pwd} successuful"''' - server = mw.getServerDir() + '/mysql' + server = mw.getServerDir() + '/mariadb' root_mysql = root_mysql.replace('${server}', server) mw.writeFile('mysql_root.sh', root_mysql) os.system("/bin/bash mysql_root.sh " + password) os.system("rm -f mysql_root.sh") - pos = mw.getServerDir() + '/mysql' + pos = mw.getServerDir() + '/mariadb' result = sql.table('config').dbPos(pos, 'mysql').where( 'id=?', (1,)).setField('mysql_root', password) -def set_panel_pwd(password, ncli=False): - # 设置面板密码 - import db - sql = db.Sql() - result = sql.table('users').where('id=?', (1,)).setField( - 'password', mw.md5(password)) - username = sql.table('users').where('id=?', (1,)).getField('username') - if ncli: - print("|-用户名: " + username) - print("|-新密码: " + password) - else: - print(username) - - -def set_panel_username(username=None): - # 随机面板用户名 - import db - sql = db.Sql() - if username: - if len(username) < 5: - print("|-错误,用户名长度不能少于5位") - return - if username in ['admin', 'root']: - print("|-错误,不能使用过于简单的用户名") - return - - sql.table('users').where('id=?', (1,)).setField('username', username) - print("|-新用户名: %s" % username) - return - - username = sql.table('users').where('id=?', (1,)).getField('username') - if username == 'admin': - username = mw.getRandomString(8).lower() - sql.table('users').where('id=?', (1,)).setField('username', username) - print('username: ' + username) - - -def getServerIp(): - version = sys.argv[2] - ip = mw.execShell( - "curl -{} -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text".format(version)) - print(ip[0]) - - if __name__ == "__main__": type = sys.argv[1] if type == 'root': set_mysql_root(sys.argv[2]) - elif type == 'panel': - set_panel_pwd(sys.argv[2]) - elif type == 'username': - set_panel_username() - elif type == 'getServerIp': - getServerIp() else: print('ERROR: Parameter error') From 83a95717af34e7ee27795c9b31d858185fe3e33e Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:02:53 +0800 Subject: [PATCH 069/173] Update gd.sh --- plugins/php/versions/53/gd.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/php/versions/53/gd.sh b/plugins/php/versions/53/gd.sh index 2fa077065..0df6b9d73 100755 --- a/plugins/php/versions/53/gd.sh +++ b/plugins/php/versions/53/gd.sh @@ -35,6 +35,7 @@ else fi +# cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh # OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" # OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" # OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" @@ -42,7 +43,6 @@ fi Install_lib() { - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` if [ "${isInstall}" != "" ];then @@ -62,12 +62,12 @@ Install_lib() #--with-xpm ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ + --with-gd \ --with-webp \ --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype + --with-freetype \ + --enable-gd-jis-conv \ + --enable-gd-native-ttf make clean && make && make install && make clean fi From a4a35ccd87ad066d35c2844844e2756ee9a5ee35 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:07:58 +0800 Subject: [PATCH 070/173] up --- plugins/php/versions/54/gd.sh | 118 ------------------ plugins/php/versions/55/gd.sh | 118 ------------------ plugins/php/versions/56/gd.sh | 118 ------------------ plugins/php/versions/70/gd.sh | 118 ------------------ plugins/php/versions/71/gd.sh | 118 ------------------ plugins/php/versions/72/gd.sh | 118 ------------------ plugins/php/versions/73/gd.sh | 118 ------------------ plugins/php/versions/common/gd.sh | 4 +- .../versions/{53/gd.sh => common/gd_old.sh} | 0 9 files changed, 2 insertions(+), 828 deletions(-) delete mode 100755 plugins/php/versions/54/gd.sh delete mode 100755 plugins/php/versions/55/gd.sh delete mode 100755 plugins/php/versions/56/gd.sh delete mode 100755 plugins/php/versions/70/gd.sh delete mode 100755 plugins/php/versions/71/gd.sh delete mode 100755 plugins/php/versions/72/gd.sh delete mode 100755 plugins/php/versions/73/gd.sh rename plugins/php/versions/{53/gd.sh => common/gd_old.sh} (100%) diff --git a/plugins/php/versions/54/gd.sh b/plugins/php/versions/54/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/54/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/55/gd.sh b/plugins/php/versions/55/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/55/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/56/gd.sh b/plugins/php/versions/56/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/56/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/70/gd.sh b/plugins/php/versions/70/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/70/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/71/gd.sh b/plugins/php/versions/71/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/71/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/72/gd.sh b/plugins/php/versions/72/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/72/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/73/gd.sh b/plugins/php/versions/73/gd.sh deleted file mode 100755 index 2fa077065..000000000 --- a/plugins/php/versions/73/gd.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` - -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") -sourcePath=${serverPath}/source/php - -actionType=$1 -version=$2 - -LIBNAME=gd -LIBV=0 - - -# if [ "$version" -lt "74" ];then -# echo "not need!" -# exit 1 -# fi - - -NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` -extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so - -sysName=`uname` -if [ "$sysName" == "Darwin" ];then - BAK='_bak' -else - BAK='' -fi - - -# OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" -# OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" -# OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" - - -Install_lib() -{ - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh - - isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"` - if [ "${isInstall}" != "" ];then - echo "php-$version 已安装${LIBNAME},请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - - if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} - fi - - cd $sourcePath/php${version}/ext/${LIBNAME} - - $serverPath/php/$version/bin/phpize - - #--with-xpm - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - --enable-gd --enable-gd-native-ttf \ - --with-webp \ - --with-jpeg \ - --with-jpeg-dir=/usr/lib \ - --with-freetype-dir=${serverPath}/lib/freetype_old \ - --with-freetype - make clean && make && make install && make clean - - fi - - if [ ! -f "$extFile" ];then - echo "ERROR!" - return - fi - - echo "" >> $serverPath/php/$version/etc/php.ini - echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini - echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini - - $serverPath/php/init.d/php${version} restart - echo '===========================================================' - echo 'successful!' -} - - -Uninstall_lib() -{ - if [ ! -f "$serverPath/php/$version/bin/php-config" ];then - echo "php-$version 未安装,请选择其它版本!" - return - fi - - if [ ! -f "$extFile" ];then - echo "php-$version 未安装${LIBNAME},请选择其它版本!" - return - fi - - echo $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini - sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini - - rm -f $extFile - bash ${rootPath}/plugins/php/versions/lib.sh $version restart - echo '===============================================' - echo 'successful!' -} - - - -if [ "$actionType" == 'install' ];then - Install_lib -elif [ "$actionType" == 'uninstall' ];then - Uninstall_lib -fi \ No newline at end of file diff --git a/plugins/php/versions/common/gd.sh b/plugins/php/versions/common/gd.sh index 38fcf30ea..79862e1fe 100755 --- a/plugins/php/versions/common/gd.sh +++ b/plugins/php/versions/common/gd.sh @@ -19,8 +19,8 @@ LIBV=0 if [ "$version" -lt "74" ];then - echo "not need!" - exit 1 + bash $curPath/gd_old.sh $1 $2 + exit 0 fi diff --git a/plugins/php/versions/53/gd.sh b/plugins/php/versions/common/gd_old.sh similarity index 100% rename from plugins/php/versions/53/gd.sh rename to plugins/php/versions/common/gd_old.sh From 3dcc35ec0982718e58738f275a9ea2358d7ee902 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:17:10 +0800 Subject: [PATCH 071/173] Update gd_old.sh --- plugins/php/versions/common/gd_old.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/php/versions/common/gd_old.sh b/plugins/php/versions/common/gd_old.sh index 0df6b9d73..7754151e1 100755 --- a/plugins/php/versions/common/gd_old.sh +++ b/plugins/php/versions/common/gd_old.sh @@ -63,7 +63,6 @@ Install_lib() #--with-xpm ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ --with-gd \ - --with-webp \ --with-jpeg \ --with-freetype \ --enable-gd-jis-conv \ From bc83fd389c73aac444a21a7cac1e072a2759e589 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:21:34 +0800 Subject: [PATCH 072/173] Update yaf.sh --- plugins/php/versions/common/yaf.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/php/versions/common/yaf.sh b/plugins/php/versions/common/yaf.sh index 7a8ace7d1..cf3c14192 100755 --- a/plugins/php/versions/common/yaf.sh +++ b/plugins/php/versions/common/yaf.sh @@ -23,6 +23,10 @@ if [ "$version" -lt "70" ];then LIBV=2.3.5 fi +if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then + LIBV=3.2.5 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so From de30501f20da6fbfc82fb00ea8935f83716424a4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:31:06 +0800 Subject: [PATCH 073/173] Update yaf.sh --- plugins/php/versions/common/yaf.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/php/versions/common/yaf.sh b/plugins/php/versions/common/yaf.sh index cf3c14192..8598e90b1 100755 --- a/plugins/php/versions/common/yaf.sh +++ b/plugins/php/versions/common/yaf.sh @@ -27,6 +27,10 @@ if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then LIBV=3.2.5 fi +if [ "$version" -eq "72" ] || [ "$version" -eq "73" ];then + LIBV=3.2.5 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so From 266111d8f4ec1ee025d65fd7e3698178b8adf77c Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:35:42 +0800 Subject: [PATCH 074/173] up --- plugins/php/versions/common/redis.sh | 2 +- plugins/php/versions/common/yac.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/versions/common/redis.sh b/plugins/php/versions/common/redis.sh index 18977503b..15c497ade 100755 --- a/plugins/php/versions/common/redis.sh +++ b/plugins/php/versions/common/redis.sh @@ -56,7 +56,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/yac.sh b/plugins/php/versions/common/yac.sh index cadcacc3e..e0038d2bc 100755 --- a/plugins/php/versions/common/yac.sh +++ b/plugins/php/versions/common/yac.sh @@ -56,7 +56,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean cd .. fi From b6b618b0609044a035148920612fe314368d72eb Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 09:54:09 +0800 Subject: [PATCH 075/173] Update yar.sh --- plugins/php/versions/common/yar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/yar.sh b/plugins/php/versions/common/yar.sh index 961ac0fd5..e387d6462 100755 --- a/plugins/php/versions/common/yar.sh +++ b/plugins/php/versions/common/yar.sh @@ -54,7 +54,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ --with-curl=$serverPath/lib/curl - make && make install && make clean + make clean && make && make install && make clean fi From 0607323d1b1f774fbd5fc94e60085867fe8407c1 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 10:15:58 +0800 Subject: [PATCH 076/173] Update gd.sh --- plugins/php/versions/52/gd.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/52/gd.sh b/plugins/php/versions/52/gd.sh index 56564ca6a..aab4f988b 100755 --- a/plugins/php/versions/52/gd.sh +++ b/plugins/php/versions/52/gd.sh @@ -57,10 +57,17 @@ Install_lib() fi - if [ "$OSNAME" == "debian" ] && [ "$OSNAME" == "ubuntu" ];then + # cp -frp /usr/lib64/libldap* /usr/lib/ + + # ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so + # ln -s /usr/lib64/libpng.so /usr/lib/libpng.so + + if [ ! -f /usr/lib/libjpeg.so ];then ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so - ln -s /usr/lib64/libpng.so /usr/lib/ - cp -frp /usr/lib64/libldap* /usr/lib/ + fi + + if [ ! -f /usr/lib/libpng.so ];then + ln -s /usr/lib64/libpng.so /usr/lib/libpng.so fi From 3ae2f0db68b5337a22f2d55a0f6d23a430ab0f1a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 11:03:32 +0800 Subject: [PATCH 077/173] Update index.py --- plugins/mariadb/index.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index a848e4924..27201a517 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -122,7 +122,6 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): db = orm.ORM() - db.__DB_CNF = getConf() db.setDbConf(getConf()) db.setPwd(pSqliteDb('config').where( 'id=?', (1,)).getField('mysql_root')) @@ -176,11 +175,13 @@ def initDreplace(version=''): def status(version=''): - pid = getPidFile() - if not os.path.exists(pid): + try: + pid = getPidFile() + if os.path.exists(pid): + return 'start' + except Exception as e: return 'stop' - - return 'start' + return 'stop' def getDataDir(): From c6f3fae7b565cfeea1a456e251b919521ba97ea4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 11:04:46 +0800 Subject: [PATCH 078/173] Update index.py --- plugins/mariadb/index.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 27201a517..4579c7af9 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -399,7 +399,6 @@ def setMyDbPos(): if not os.path.exists(t_datadir): mw.execShell('mkdir -p ' + t_datadir) - # mw.execShell('/etc/init.d/mysqld stop') stop() mw.execShell('cp -rf ' + s_datadir + '/* ' + t_datadir + '/') mw.execShell('chown -R mysql mysql ' + t_datadir) @@ -468,7 +467,7 @@ def runInfo(): # print data if data[0] == 1045 or data[0] == 2003: pwd = db.getPwd() - return mw.returnJson(False, 'mysql password error:' + pwd + '!') + return mw.returnJson(False, 'mariadb password error:' + pwd + '!') except Exception as e: pass From b1b5dcda11858fcd4061e9171a37e8f278764da4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 11:15:37 +0800 Subject: [PATCH 079/173] up --- plugins/mariadb/index.py | 51 +--- plugins/mariadb/js/mariadb.js | 515 ---------------------------------- 2 files changed, 3 insertions(+), 563 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 4579c7af9..40cf93958 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -607,9 +607,9 @@ def setDbBackup(): if not data[0]: return data[1] - scDir = mw.getRunDir() + '/scripts/backup.py' + scDir = getPluginDir() + '/scripts/backup.py' - cmd = 'python ' + scDir + ' database ' + args['name'] + ' 3' + cmd = 'python3 ' + scDir + ' database ' + args['name'] + ' 3' os.system(cmd) return mw.returnJson(True, 'ok') @@ -632,7 +632,7 @@ def importDbBackup(): pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') - mysql_cmd = mw.getRootDir() + '/server/mysql/bin/mysql -uroot -p' + pwd + \ + mysql_cmd = mw.getRootDir() + '/server/mariadb/bin/mysql -uroot -p' + pwd + \ ' ' + name + ' < ' + file_path_sql # print(mysql_cmd) @@ -1034,19 +1034,6 @@ def getDbAccess(): return mw.returnJson(True, userStr) -def toSize(size): - d = ('b', 'KB', 'MB', 'GB', 'TB') - s = d[0] - for b in d: - if size < 1024: - return str(size) + ' ' + b - size = size / 1024 - s = b - _size = round(size, 2) - # print(size, _size) - return str(size) + ' ' + b - - def setDbAccess(): args = getArgs() data = checkArgs(args, ['username', 'access']) @@ -1865,37 +1852,5 @@ if __name__ == "__main__": print(alterTable()) elif func == 'get_total_statistics': print(getTotalStatistics()) - elif func == 'get_masterdb_list': - print(getMasterDbList(version)) - elif func == 'get_master_status': - print(getMasterStatus(version)) - elif func == 'set_master_status': - print(setMasterStatus(version)) - elif func == 'set_db_master': - print(setDbMaster(version)) - elif func == 'set_db_slave': - print(setDbSlave(version)) - elif func == 'get_master_rep_slave_list': - print(getMasterRepSlaveList(version)) - elif func == 'add_master_rep_slave_user': - print(addMasterRepSlaveUser(version)) - elif func == 'del_master_rep_slave_user': - print(delMasterRepSlaveUser(version)) - elif func == 'update_master_rep_slave_user': - print(updateMasterRepSlaveUser(version)) - elif func == 'get_master_rep_slave_user_cmd': - print(getMasterRepSlaveUserCmd(version)) - elif func == 'get_slave_list': - print(getSlaveList(version)) - elif func == 'set_slave_status': - print(setSlaveStatus(version)) - elif func == 'delete_slave': - print(deleteSlave(version)) - elif func == 'full_sync': - print(fullSync(version)) - elif func == 'do_full_sync': - print(doFullSync()) - elif func == 'dump_mysql_data': - print(dumpMysqlData(version)) else: print('error') diff --git a/plugins/mariadb/js/mariadb.js b/plugins/mariadb/js/mariadb.js index 659a00c5e..6873ffe08 100755 --- a/plugins/mariadb/js/mariadb.js +++ b/plugins/mariadb/js/mariadb.js @@ -1219,518 +1219,3 @@ function repTools(db_name, res){ }); } - -function setDbMaster(name){ - myPost('set_db_master', {name:name}, function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - setTimeout(function(){ - masterOrSlaveConf(); - }, 2000); - }); -} - - -function setDbSlave(name){ - myPost('set_db_slave', {name:name}, function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - setTimeout(function(){ - masterOrSlaveConf(); - }, 2000); - }); -} - - -function addMasterRepSlaveUser(){ - - - var index = layer.open({ - type: 1, - skin: 'demo-class', - area: '500px', - title: '添加同步账户', - closeBtn: 1, - shift: 5, - shadeClose: true, - content: "
\ -
用户名
\ -
\ - 密码\ -
\ -
\ - \ -
\ - \ - \ -
\ - ", - }); - - //
\ - // 访问权限\ - //
\ - // \ - //
\ - //
\ - - $("input[name='name']").keyup(function(){ - var v = $(this).val(); - $("input[name='db_user']").val(v); - $("input[name='ps']").val(v); - }); - - $('#my_mod_close').click(function(){ - $('.layui-layer-close1').click(); - }); - $('select[name="dataAccess"]').change(function(){ - var v = $(this).val(); - if (v == 'ip'){ - $(this).after(""); - } else { - $('#dataAccess_subid').remove(); - } - }); - - $('#submit_add_master').click(function(){ - - var data = $("#add_master").serialize(); - data = decodeURIComponent(data); - var dataObj = str2Obj(data); - if(!dataObj['address']){ - dataObj['address'] = dataObj['dataAccess']; - } - // console.log(dataObj); - myPost('add_master_rep_slave_user', dataObj, function(data){ - var rdata = $.parseJSON(data.data); - showMsg(rdata.msg,function(){ - if (rdata.status){ - getMasterRepSlaveList(); - } - $('.layui-layer-close1').click(); - },{icon: rdata.status ? 1 : 2},600); - }); - }); -} - - - -function updateMasterRepSlaveUser(username){ - - - var index = layer.open({ - type: 1, - skin: 'demo-class', - area: '500px', - title: '更新账户', - closeBtn: 1, - shift: 5, - shadeClose: true, - content: "
\ -
用户名
\ -
\ - 密码\ -
\ -
\ - \ -
\ - \ -
\ - ", - }); - - $('#submit_update_master').click(function(){ - var data = $("#update_master").serialize(); - data = decodeURIComponent(data); - var dataObj = str2Obj(data); - // console.log(dataObj); - myPost('update_master_rep_slave_user', data, function(data){ - var rdata = $.parseJSON(data.data); - showMsg(rdata.msg,function(){ - if (rdata.status){ - getMasterRepSlaveList(); - } - $('.layui-layer-close1').click(); - },{icon: rdata.status ? 1 : 2},600); - }); - }); -} - -function getMasterRepSlaveUserCmd(username, db=''){ - myPost('get_master_rep_slave_user_cmd', {username:username,db:db}, function(data){ - var rdata = $.parseJSON(data.data); - - if (!rdata['status']){ - layer.msg(rdata['msg']); - return; - } - - - var loadOpen = layer.open({ - type: 1, - title: '同步命令', - area: '500px', - content:"
\ -
"+rdata.data+"
\ -
\ - \ -
\ - ", - }); - - copyPass(rdata.data); - $('.class-copy-cmd').click(function(){ - copyPass(rdata.data); - }); - }); -} - -function delMasterRepSlaveUser(username){ - myPost('del_master_rep_slave_user', {username:username}, function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg); - - $('.layui-layer-close1').click(); - - setTimeout(function(){ - getMasterRepSlaveList(); - },1000); - }); -} - -function getMasterRepSlaveList(){ - var _data = {}; - if (typeof(page) =='undefined'){ - var page = 1; - } - - _data['page'] = page; - _data['page_size'] = 10; - myPost('get_master_rep_slave_list', _data, function(data){ - // console.log(data); - var rdata = []; - try { - rdata = $.parseJSON(data.data); - } catch(e){ - console.log(e); - } - var list = ''; - // console.log(rdata['data']); - var user_list = rdata['data']; - for (i in user_list) { - // console.log(i); - var name = user_list[i]['username']; - list += '
\ - \ - \ - '; - } - - var page = '
'; - page += '
添加同步账户
'; - - var loadOpen = layer.open({ - type: 1, - title: '同步账户列表', - area: '500px', - content:"
\ -
\ -
'+name+''+user_list[i]['password']+'\ - 修改 | \ - 删除 | \ - 从库同步命令\ -
\ - \ - " + list + "\ -
用户民密码操作
\ - "+page +"\ - \ - " - }); - - $('.dataTables_paginate_4').html(rdata['page']); - }); -} - - -function deleteSlave(){ - myPost('delete_slave', {}, function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata['msg']); - setTimeout(function(){ - masterOrSlaveConf(); - }, 3000); - - }); -} - - -function getFullSyncStatus(db){ - - var btn = '
开始
'; - var loadOpen = layer.open({ - type: 1, - title: '全量同步['+db+']', - area: '500px', - content:"
\ -
\ - \ -
\ -
0%
\ -
\ -
\ - "+btn+"\ -
" - }); - - var timeId = setInterval(function(){ - fullSync(db,0); - }, 1000); - - function fullSync(db,begin){ - - myPostN('full_sync', {db:db,begin:begin}, function(data){ - var rdata = $.parseJSON(data.data); - $('#full_msg').text(rdata['msg']); - $('.progress-bar').css('width',rdata['progress']+'%'); - $('.progress-bar').text(rdata['progress']+'%'); - - if (rdata['code']==6 ||rdata['code']<0){ - layer.msg(rdata['msg']); - clearInterval(timeId); - } - }); - } - - fullSync(db,0); - $('#begin_full_sync').click(function(){ - fullSync(db,1); - - timeId= setTimeout(function(){ - fullSync(db,0); - }, 1000); - }); - - $('.layui-layer-close1').click(function(){ - clearInterval(timeId); - }); -} - -function handlerRun(){ - cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py do_full_sync {"db":"all"}'; - var loadOpen = layer.open({ - type: 1, - title: '手动执行', - area: '500px', - content:"
\ -
"+cmd+"
\ -
\ - \ -
\ -
", - }); - copyPass(cmd); - $('.class-copy-cmd').click(function(){ - copyPass(cmd); - }); -} - -function masterOrSlaveConf(version=''){ - - function getMasterDbList(){ - var _data = {}; - if (typeof(page) =='undefined'){ - var page = 1; - } - - _data['page'] = page; - _data['page_size'] = 10; - - myPost('get_masterdb_list', _data, function(data){ - var rdata = $.parseJSON(data.data); - var list = ''; - for(i in rdata.data){ - list += ''; - list += '' + rdata.data[i]['name'] +''; - list += '' + (rdata.data[i]['master']?'是':'否') +''; - list += '' + - ''+(rdata.data[i]['master']?'退出':'加入')+' | ' + - '同步命令' + - ''; - list += ''; - } - - var con = '
\ -
\ - \ - \ - \ - \ - \ - \ - '+ list +'\ -
数据库名同步操作
\ -
\ -
\ -
\ - 同步账户列表\ -
\ -
'; - - $(".table_master_list").html(con); - $('#databasePage').html(rdata.page); - }); - } - - function getAsyncMasterDbList(){ - var _data = {}; - if (typeof(page) =='undefined'){ - var page = 1; - } - - _data['page'] = page; - _data['page_size'] = 10; - - myPost('get_slave_list', _data, function(data){ - var rdata = $.parseJSON(data.data); - var list = ''; - for(i in rdata.data){ - list += ''; - list += '' + rdata.data[i]['Master_Host'] +''; - list += '' + rdata.data[i]['Master_Port'] +''; - list += '' + rdata.data[i]['Master_User'] +''; - list += '' + rdata.data[i]['Master_Log_File'] +''; - list += '' + rdata.data[i]['Slave_IO_Running'] +''; - list += '' + rdata.data[i]['Slave_SQL_Running'] +''; - list += '' + - '删除' + - ''; - list += ''; - } - - var con = '
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - '+ list +'\ -
主[服务]端口用户日志IOSQL操作
\ -
\ -
'; - - //
\ - //
\ - // 添加\ - //
- $(".table_slave_status_list").html(con); - }); - } - - function getAsyncDataList(){ - var _data = {}; - if (typeof(page) =='undefined'){ - var page = 1; - } - - _data['page'] = page; - _data['page_size'] = 10; - myPost('get_masterdb_list', _data, function(data){ - var rdata = $.parseJSON(data.data); - var list = ''; - for(i in rdata.data){ - list += ''; - list += '' + rdata.data[i]['name'] +''; - list += '' + - ''+(rdata.data[i]['slave']?'退出':'加入')+' | ' + - '修复' + - ''; - list += ''; - } - - var con = '
\ -
\ - \ - \ - \ - \ - \ - '+ list +'\ -
本地库名操作
\ -
\ -
\ -
\ - 手动命令\ - 全量同步\ -
\ -
'; - - $(".table_slave_list").html(con); - $('#databasePage').html(rdata.page); - }); - } - - function getMasterStatus(){ - myPost('get_master_status', '', function(data){ - var rdata = $.parseJSON(data.data); - var limitCon = '

\ - Master[主]配置\ -


\ -

\ - \ -
\ -
\ -

\ - Slave[从]配置\ -


\ -

\ - \ -
\ - \ -
\ - '; - $(".soft-man-con").html(limitCon); - - //设置主服务器配置 - $(".btn-master").click(function () { - myPost('set_master_status', 'close=change', function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - setTimeout(function(){ - getMasterStatus(); - }, 3000); - }); - }); - - $(".btn-slave").click(function () { - myPost('set_slave_status', 'close=change', function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - setTimeout(function(){ - getMasterStatus(); - }, 3000); - }); - }); - - if (rdata.status){ - getMasterDbList(); - } - - if (rdata.data.slave_status){ - getAsyncMasterDbList(); - getAsyncDataList() - } - }); - } - getMasterStatus(); -} From dd99bff1ba8ed81cc2e98888cbb1491efc0c6462 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 11:18:42 +0800 Subject: [PATCH 080/173] Update index.py --- plugins/mariadb/index.py | 528 --------------------------------------- 1 file changed, 528 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 40cf93958..825eecb3f 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -1209,389 +1209,6 @@ def getTotalStatistics(): return mw.returnJson(False, 'fail', data) -def findBinlogDoDb(): - conf = getConf() - con = mw.readFile(conf) - rep = r"binlog-do-db\s*?=\s*?(.*)" - dodb = re.findall(rep, con, re.M) - return dodb - - -def findBinlogSlaveDoDb(): - conf = getConf() - con = mw.readFile(conf) - rep = r"replicate-do-db\s*?=\s*?(.*)" - dodb = re.findall(rep, con, re.M) - return dodb - - -def getMasterDbList(version=''): - args = getArgs() - page = 1 - page_size = 10 - search = '' - data = {} - if 'page' in args: - page = int(args['page']) - - if 'page_size' in args: - page_size = int(args['page_size']) - - if 'search' in args: - search = args['search'] - - conn = pSqliteDb('databases') - limit = str((page - 1) * page_size) + ',' + str(page_size) - condition = '' - dodb = findBinlogDoDb() - data['dodb'] = dodb - - slave_dodb = findBinlogSlaveDoDb() - - if not search == '': - condition = "name like '%" + search + "%'" - field = 'id,pid,name,username,password,accept,ps,addtime' - clist = conn.where(condition, ()).field( - field).limit(limit).order('id desc').select() - count = conn.where(condition, ()).count() - - for x in range(0, len(clist)): - if clist[x]['name'] in dodb: - clist[x]['master'] = 1 - else: - clist[x]['master'] = 0 - - if clist[x]['name'] in slave_dodb: - clist[x]['slave'] = 1 - else: - clist[x]['slave'] = 0 - - _page = {} - _page['count'] = count - _page['p'] = page - _page['row'] = page_size - _page['tojs'] = 'dbList' - data['page'] = mw.getPage(_page) - data['data'] = clist - - return mw.getJson(data) - - -def setDbMaster(version): - args = getArgs() - data = checkArgs(args, ['name']) - if not data[0]: - return data[1] - - conf = getConf() - con = mw.readFile(conf) - rep = r"(binlog-do-db\s*?=\s*?(.*))" - dodb = re.findall(rep, con, re.M) - - isHas = False - for x in range(0, len(dodb)): - - if dodb[x][1] == args['name']: - isHas = True - - con = con.replace(dodb[x][0] + "\n", '') - mw.writeFile(conf, con) - - if not isHas: - prefix = '#binlog-do-db' - con = con.replace( - prefix, prefix + "\nbinlog-do-db=" + args['name']) - mw.writeFile(conf, con) - - restart(version) - time.sleep(4) - return mw.returnJson(True, '设置成功', [args, dodb]) - - -def setDbSlave(version): - args = getArgs() - data = checkArgs(args, ['name']) - if not data[0]: - return data[1] - - conf = getConf() - con = mw.readFile(conf) - rep = r"(replicate-do-db\s*?=\s*?(.*))" - dodb = re.findall(rep, con, re.M) - - isHas = False - for x in range(0, len(dodb)): - if dodb[x][1] == args['name']: - isHas = True - - con = con.replace(dodb[x][0] + "\n", '') - mw.writeFile(conf, con) - - if not isHas: - prefix = '#replicate-do-db' - con = con.replace( - prefix, prefix + "\nreplicate-do-db=" + args['name']) - mw.writeFile(conf, con) - - restart(version) - time.sleep(4) - return mw.returnJson(True, '设置成功', [args, dodb]) - - -def getMasterStatus(version=''): - - if status(version) == 'stop': - return mw.returnJson(False, 'MySQL未启动,或正在启动中...!', []) - - conf = getConf() - con = mw.readFile(conf) - master_status = False - if con.find('#log-bin') == -1 and con.find('log-bin') > 1: - dodb = findBinlogDoDb() - if len(dodb) > 0: - master_status = True - data = {} - data['status'] = master_status - - db = pMysqlDb() - dlist = db.query('show slave status') - # print(dlist, len(dlist)) - if len(dlist) > 0 and (dlist[0][10] == 'Yes' or dlist[0][11] == 'Yes'): - data['slave_status'] = True - - return mw.returnJson(master_status, '设置成功', data) - - -def setMasterStatus(version=''): - - conf = getConf() - con = mw.readFile(conf) - - if con.find('#log-bin') != -1: - return mw.returnJson(False, '必须开启二进制日志') - - sign = 'mdserver_ms_open' - - dodb = findBinlogDoDb() - if not sign in dodb: - prefix = '#binlog-do-db' - con = con.replace(prefix, prefix + "\nbinlog-do-db=" + sign) - mw.writeFile(conf, con) - else: - con = con.replace("binlog-do-db=" + sign + "\n", '') - rep = r"(binlog-do-db\s*?=\s*?(.*))" - dodb = re.findall(rep, con, re.M) - for x in range(0, len(dodb)): - con = con.replace(dodb[x][0] + "\n", '') - mw.writeFile(conf, con) - - restart(version) - return mw.returnJson(True, '设置成功') - - -def getMasterRepSlaveList(version=''): - args = getArgs() - page = 1 - page_size = 10 - search = '' - data = {} - if 'page' in args: - page = int(args['page']) - - if 'page_size' in args: - page_size = int(args['page_size']) - - if 'search' in args: - search = args['search'] - - conn = pSqliteDb('master_replication_user') - limit = str((page - 1) * page_size) + ',' + str(page_size) - condition = '' - - if not search == '': - condition = "name like '%" + search + "%'" - field = 'id,username,password,accept,ps,addtime' - clist = conn.where(condition, ()).field( - field).limit(limit).order('id desc').select() - count = conn.where(condition, ()).count() - - _page = {} - _page['count'] = count - _page['p'] = page - _page['row'] = page_size - _page['tojs'] = 'getMasterRepSlaveList' - data['page'] = mw.getPage(_page) - data['data'] = clist - - return mw.getJson(data) - - -def addMasterRepSlaveUser(version=''): - args = getArgs() - data = checkArgs(args, - ['username', 'password']) - if not data[0]: - return data[1] - - if not 'address' in args: - address = '' - else: - address = args['address'].strip() - - username = args['username'].strip() - password = args['password'].strip() - # ps = args['ps'].strip() - # address = args['address'].strip() - # dataAccess = args['dataAccess'].strip() - - reg = "^[\w\.-]+$" - if not re.match(reg, username): - return mw.returnJson(False, '用户名不能带有特殊符号!') - checks = ['root', 'mysql', 'test', 'sys', 'panel_logs'] - if username in checks or len(username) < 1: - return mw.returnJson(False, '用户名不合法!') - if password in checks or len(password) < 1: - return mw.returnJson(False, '密码不合法!') - - if len(password) < 1: - password = mw.md5(time.time())[0:8] - - pdb = pMysqlDb() - psdb = pSqliteDb('master_replication_user') - - if psdb.where("username=?", (username)).count(): - return mw.returnJson(False, '用户已存在!') - - result = pdb.execute("GRANT REPLICATION SLAVE ON *.* TO '" + - username + "'@'%' identified by '" + password + "';FLUSH PRIVILEGES;") - # print result - isError = isSqlError(result) - if isError != None: - return isError - - addTime = time.strftime('%Y-%m-%d %X', time.localtime()) - psdb.add('username,password,accept,ps,addtime', - (username, password, '%', '', addTime)) - return mw.returnJson(True, '添加成功!') - - -def getMasterRepSlaveUserCmd(version): - args = getArgs() - data = checkArgs(args, ['username', 'db']) - if not data[0]: - return data[1] - - psdb = pSqliteDb('master_replication_user') - f = 'username,password' - if args['username'] == '': - - count = psdb.count() - - if count == 0: - return mw.returnJson(False, '请添加同步账户!') - - clist = psdb.field(f).limit('1').order('id desc').select() - else: - clist = psdb.field(f).where("username=?", (args['username'],)).limit( - '1').order('id desc').select() - - ip = mw.getLocalIp() - port = getMyPort() - - db = pMysqlDb() - tmp = db.query('show master status') - - if len(tmp) == 0: - return mw.returnJson(False, '未开启!') - - sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \ - clist[0]['username'] + "', MASTER_PASSWORD='" + \ - clist[0]['password'] + \ - "', MASTER_LOG_FILE='" + tmp[0][0] + \ - "',MASTER_LOG_POS=" + str(tmp[0][1]) + "" - - # if args['db'] != '': - # replicate-do-table - - return mw.returnJson(True, 'OK!', sql) - - -def delMasterRepSlaveUser(version=''): - args = getArgs() - data = checkArgs(args, ['username']) - if not data[0]: - return data[1] - - pdb = pMysqlDb() - psdb = pSqliteDb('master_replication_user') - pdb.execute("drop user '" + args['username'] + "'@'%'") - psdb.where("username=?", (args['username'],)).delete() - - return mw.returnJson(True, '删除成功!') - - -def updateMasterRepSlaveUser(version=''): - args = getArgs() - data = checkArgs(args, ['username', 'password']) - if not data[0]: - return data[1] - - pdb = pMysqlDb() - psdb = pSqliteDb('master_replication_user') - pdb.execute("drop user '" + args['username'] + "'@'%'") - - pdb.execute("GRANT REPLICATION SLAVE ON *.* TO '" + - args['username'] + "'@'%' identified by '" + args['password'] + "'") - - psdb.where("username=?", (args['username'],)).save( - 'password', args['password']) - - return mw.returnJson(True, '更新成功!') - - -def getSlaveList(version=''): - - db = pMysqlDb() - dlist = db.query('show slave status') - - # print(dlist) - ret = [] - for x in range(0, len(dlist)): - tmp = {} - tmp['Master_User'] = dlist[x][2] - tmp['Master_Host'] = dlist[x][1] - tmp['Master_Port'] = dlist[x][3] - tmp['Master_Log_File'] = dlist[x][5] - tmp['Slave_IO_Running'] = dlist[x][10] - tmp['Slave_SQL_Running'] = dlist[x][11] - ret.append(tmp) - data = {} - data['data'] = ret - - return mw.getJson(data) - - -def setSlaveStatus(version=''): - db = pMysqlDb() - dlist = db.query('show slave status') - - if len(dlist) == 0: - return mw.returnJson(False, '需要手动添加主服务同步命令!') - - if len(dlist) > 0 and (dlist[0][10] == 'Yes' or dlist[0][11] == 'Yes'): - db.query('stop slave') - else: - db.query('start slave') - - return mw.returnJson(True, '设置成功!') - - -def deleteSlave(version=''): - db = pMysqlDb() - dlist = db.query('stop slave;reset slave all') - return mw.returnJson(True, '删除成功!') - - def dumpMysqlData(version): args = getArgs() @@ -1616,151 +1233,6 @@ def dumpMysqlData(version): return 'fail' -from threading import Thread -from time import sleep - - -def mw_async(f): - def wrapper(*args, **kwargs): - thr = Thread(target=f, args=args, kwargs=kwargs) - thr.start() - return wrapper - - -def doFullSync(): - - args = getArgs() - data = checkArgs(args, ['db']) - if not data[0]: - return data[1] - - status_data = {} - status_data['progress'] = 5 - - db = pMysqlDb() - - dlist = db.query('show slave status') - if len(dlist) == 0: - status_data['code'] = -1 - status_data['msg'] = '没有启动...' - - ip = dlist[0][1] - print(ip) - - status_file = '/tmp/db_async_status.txt' - - status_data['code'] = 0 - status_data['msg'] = '运行中...' - mw.writeFile(status_file, json.dumps(status_data)) - - import paramiko - paramiko.util.log_to_file('paramiko.log') - ssh = paramiko.SSHClient() - - SSH_PRIVATE_KEY = '/root/.ssh/id_rsa' - - if mw.getOs() == 'darwin': - user = mw.execShell( - "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() - SSH_PRIVATE_KEY = '/Users/' + user + '/.ssh/id_rsa' - - print(SSH_PRIVATE_KEY) - if not os.path.exists(SSH_PRIVATE_KEY): - status_data['code'] = 0 - status_data['msg'] = '需要配置免登录...' - mw.writeFile(status_file, json.dumps(status_data)) - return - - try: - key = paramiko.RSAKey.from_private_key_file(SSH_PRIVATE_KEY) - # ssh.load_system_host_keys() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(hostname=ip, port=22, username='root', pkey=key) - except Exception as e: - status_data['code'] = 0 - status_data['msg'] = '需要配置免登录....' - mw.writeFile(status_file, json.dumps(status_data)) - return - - cmd = "cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py dump_mysql_data {\"db\":'" + args[ - 'db'] + "'}" - stdin, stdout, stderr = ssh.exec_command(cmd) - result = stdout.read() - result_err = stderr.read() - - if result == 'ok': - status_data['code'] = 1 - status_data['msg'] = '主服务器备份完成...' - status_data['progress'] = 30 - mw.writeFile(status_file, json.dumps(status_data)) - - r = mw.execShell('scp root@' + ip + ':/tmp/dump.sql /tmp') - if r[0] == '': - status_data['code'] = 2 - status_data['msg'] = '数据同步本地完成...' - status_data['progress'] = 40 - mw.writeFile(status_file, json.dumps(status_data)) - - cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"","db":""}' - stdin, stdout, stderr = ssh.exec_command(cmd) - result = stdout.read() - result_err = stderr.read() - cmd_data = json.loads(result) - - db.query('stop slave') - status_data['code'] = 3 - status_data['msg'] = '停止从库完成...' - status_data['progress'] = 45 - mw.writeFile(status_file, json.dumps(status_data)) - - dlist = db.query(cmd_data['data']) - status_data['code'] = 4 - status_data['msg'] = '刷新库信息完成...' - status_data['progress'] = 50 - mw.writeFile(status_file, json.dumps(status_data)) - - pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') - cmd = getServerDir() + "/bin/mysql -uroot -p" + pwd + " < /tmp/dump.sql" - print(mw.execShell(cmd)) - status_data['code'] = 5 - status_data['msg'] = '同步数据完成...' - status_data['progress'] = 90 - mw.writeFile(status_file, json.dumps(status_data)) - - db.query('start slave') - status_data['code'] = 6 - status_data['msg'] = '从库重启完成...' - status_data['progress'] = 100 - mw.writeFile(status_file, json.dumps(status_data)) - - return True - - -def fullSync(version=''): - args = getArgs() - data = checkArgs(args, ['db', 'begin']) - if not data[0]: - return data[1] - - status_file = '/tmp/db_async_status.txt' - if args['begin'] == '1': - cmd = 'cd ' + mw.getRunDir() + ' && python ' + \ - getPluginDir() + \ - '/index.py do_full_sync {"db":"' + args['db'] + '"} &' - mw.execShell(cmd) - return json.dumps({'code': 0, 'msg': '同步数据中!', 'progress': 0}) - - if os.path.exists(status_file): - c = mw.readFile(status_file) - d = json.loads(c) - - if d['code'] == 6: - os.remove(status_file) - return c - - return json.dumps({'code': 0, 'msg': '点击开始,开始同步!', 'progress': 0}) - - def uninstallPreInspection(version): # return "请手动删除MySQL[{}]".format(version) return 'ok' From 8e23e302721b394a97622a25e069b45b8c3a3678 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 11:57:24 +0800 Subject: [PATCH 081/173] debug --- plugins/mariadb/scripts/test.py | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/mariadb/scripts/test.py diff --git a/plugins/mariadb/scripts/test.py b/plugins/mariadb/scripts/test.py new file mode 100644 index 000000000..c32da0405 --- /dev/null +++ b/plugins/mariadb/scripts/test.py @@ -0,0 +1,64 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import subprocess +import re +import json + +cur_dir = os.getcwd() +plugin_dir = os.path.dirname(cur_dir) + +# print(plugin_dir) +root_dir = os.path.dirname(os.path.dirname(plugin_dir)) +# print(root_dir) + +sys.path.append(root_dir + "/class/core") +import mw + +sys.path.append(plugin_dir + "/class") +import orm + + +def getPluginName(): + return 'mariadb' + + +def getPluginDir(): + return root_dir + '/plugins/' + getPluginName() + + +def getServerDir(): + return os.path.dirname(root_dir) + '/' + getPluginName() + + +def pSqliteDb(dbname='databases'): + file = getServerDir() + '/mariadb.db' + name = 'mysql' + if not os.path.exists(file): + conn = mw.M(dbname).dbPos(getServerDir(), name) + csql = mw.readFile(getPluginDir() + '/conf/mariadb.sql') + csql_list = csql.split(';') + for index in range(len(csql_list)): + conn.execute(csql_list[index], ()) + else: + conn = mw.M(dbname).dbPos(getServerDir(), name) + return conn + + +def getConf(): + path = getServerDir() + '/etc/my.cnf' + return path + + +def pMysqlDb(): + db = orm.ORM() + db.setDbConf(getConf()) + db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) + return db + +if __name__ == '__main__': + p = pMysqlDb() + print(p.query("select User,Host from mysql.user where User!='root' AND Host!='localhost' AND Host!=''")) From 41fbff6c25577e0e599f85bb8390dc8811eb08d4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:07:10 +0800 Subject: [PATCH 082/173] Create mysql.tpl --- plugins/mariadb/init.d/mysql.tpl | 376 +++++++++++++++++++++++++++++++ 1 file changed, 376 insertions(+) create mode 100755 plugins/mariadb/init.d/mysql.tpl diff --git a/plugins/mariadb/init.d/mysql.tpl b/plugins/mariadb/init.d/mysql.tpl new file mode 100755 index 000000000..c14f5ad3a --- /dev/null +++ b/plugins/mariadb/init.d/mysql.tpl @@ -0,0 +1,376 @@ +#!/bin/sh +# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB +# This file is public domain and comes with NO WARRANTY of any kind + +# MySQL daemon start/stop script. + +# Usually this is put in /etc/init.d (at least on machines SYSV R4 based +# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. +# When this is done the mysql server will be started when the machine is +# started and shut down when the systems goes down. + +# Comments to support chkconfig on RedHat Linux +# chkconfig: 2345 64 36 +# description: A very fast and reliable SQL database engine. + +# Comments to support LSB init script conventions +### BEGIN INIT INFO +# Provides: mysql +# Required-Start: $local_fs $network $remote_fs +# Should-Start: ypbind nscd ldap ntpd xntpd +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop MySQL +# Description: MySQL is a very fast and reliable SQL database engine. +### END INIT INFO + +# If you install MySQL on some other places than /Users/midoks/Desktop/fwww/server/mysql, then you +# have to do one of the following things for this script to work: +# +# - Run this script from within the MySQL installation directory +# - Create a /etc/my.cnf file with the following information: +# [mysqld] +# basedir= +# - Add the above to any other configuration file (for example ~/.my.ini) +# and copy my_print_defaults to /usr/bin +# - Add the path to the mysql-installation-directory to the basedir variable +# below. +# +# If you want to affect other MySQL variables, you should make your changes +# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. + +# If you change base dir, you must also change datadir. These may get +# overwritten by settings in the MySQL configuration files. + +basedir= +datadir= + +# Default value, in seconds, afterwhich the script should timeout waiting +# for server start. +# Value here is overriden by value in my.cnf. +# 0 means don't wait at all +# Negative numbers mean to wait indefinitely +service_startup_timeout=900 + +# Lock directory for RedHat / SuSE. +lockdir='/var/lock/subsys' +lock_file_path="$lockdir/mysql" + +# The following variables are only set for letting mysql.server find things. + +# Set some defaults +mysqld_pid_file_path= +if test -z "$basedir" +then + basedir={$SERVER_APP_PATH} + bindir={$SERVER_APP_PATH}/bin + if test -z "$datadir" + then + datadir={$SERVER_APP_PATH}/data + fi + sbindir={$SERVER_APP_PATH}/bin + libexecdir={$SERVER_APP_PATH}/bin +else + bindir="$basedir/bin" + if test -z "$datadir" + then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" +fi + +# datadir_set is used to determine if datadir was set (and so should be +# *not* set inside of the --basedir= handler.) +datadir_set= + +# +# Use LSB init script functions for printing messages, if possible +# +lsb_functions="/lib/lsb/init-functions" +if test -f $lsb_functions ; then + . $lsb_functions +else + log_success_msg() + { + echo " SUCCESS! $@" + } + log_failure_msg() + { + echo " ERROR! $@" + } +fi + +PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" +export PATH + +mode=$1 # start or stop + +[ $# -ge 1 ] && shift + + +other_args="$*" # uncommon, but needed when called from an RPM upgrade action + # Expected: "--skip-networking --skip-grant-tables" + # They are not checked here, intentionally, as it is the resposibility + # of the "spec" file author to give correct arguments only. + +case `echo "testing\c"`,`echo -n testing` in + *c*,-n*) echo_n= echo_c= ;; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c' ;; +esac + +parse_server_arguments() { + for arg do + case "$arg" in + --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` + bindir="$basedir/bin" + if test -z "$datadir_set"; then + datadir="$basedir/data" + fi + sbindir="$basedir/sbin" + libexecdir="$basedir/libexec" + ;; + --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` + datadir_set=1 + ;; + --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + esac + done +} + +wait_for_pid () { + verb="$1" # created | removed + pid="$2" # process ID of the program operating on the pid-file + pid_file_path="$3" # path to the PID file. + + i=0 + avoid_race_condition="by checking again" + + while test $i -ne $service_startup_timeout ; do + + case "$verb" in + 'created') + # wait for a PID-file to pop into existence. + test -s "$pid_file_path" && i='' && break + ;; + 'removed') + # wait for this PID-file to disappear + test ! -s "$pid_file_path" && i='' && break + ;; + *) + echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" + exit 1 + ;; + esac + + # if server isn't running, then pid-file will never be updated + if test -n "$pid"; then + if kill -0 "$pid" 2>/dev/null; then + : # the server still runs + else + # The server may have exited between the last pid-file check and now. + if test -n "$avoid_race_condition"; then + avoid_race_condition="" + continue # Check again. + fi + + # there's nothing that will affect the file. + log_failure_msg "The server quit without updating PID file ($pid_file_path)." + return 1 # not waiting any more. + fi + fi + + echo $echo_n ".$echo_c" + i=`expr $i + 1` + sleep 1 + + done + + if test -z "$i" ; then + log_success_msg + return 0 + else + log_failure_msg + return 1 + fi +} + +# Get arguments from the my.cnf file, +# the only group, which is read from now on is [mysqld] +if test -x "$bindir/my_print_defaults"; then + print_defaults="$bindir/my_print_defaults" +else + # Try to find basedir in /etc/my.cnf + conf=/etc/my.cnf + print_defaults= + if test -r $conf + then + subpat='^[^=]*basedir[^=]*=\(.*\)$' + dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` + for d in $dirs + do + d=`echo $d | sed -e 's/[ ]//g'` + if test -x "$d/bin/my_print_defaults" + then + print_defaults="$d/bin/my_print_defaults" + break + fi + done + fi + + # Hope it's in the PATH ... but I doubt it + test -z "$print_defaults" && print_defaults="my_print_defaults" +fi + +# +# Read defaults file from 'basedir'. If there is no defaults file there +# check if it's in the old (depricated) place (datadir) and read it from there +# + +extra_args="" +if test -r "$basedir/my.cnf" +then + extra_args="-e $basedir/my.cnf" +fi + +parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` + +# +# Set pid file if not given +# +if test -z "$mysqld_pid_file_path" +then + mysqld_pid_file_path=$datadir/`hostname`.pid +else + case "$mysqld_pid_file_path" in + /* ) ;; + * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; + esac +fi + +case "$mode" in + 'start') + # Start daemon + + # Safeguard (relative paths, core dumps..) + cd $basedir + + echo $echo_n "Starting MySQL" + if test -x $bindir/mysqld_safe + then + # Give extra arguments to mysqld with the my.cnf file. This script + # may be overwritten at next upgrade. + $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & + wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? + + # Make lock for RedHat / SuSE + if test -w "$lockdir" + then + touch "$lock_file_path" + fi + + exit $return_value + else + log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" + fi + ;; + + 'stop') + # Stop daemon. We use a signal here to avoid having to know the + # root password. + + if test -s "$mysqld_pid_file_path" + then + # signal mysqld_safe that it needs to stop + touch "$mysqld_pid_file_path.shutdown" + + mysqld_pid=`cat "$mysqld_pid_file_path"` + + if (kill -0 $mysqld_pid 2>/dev/null) + then + echo $echo_n "Shutting down MySQL" + kill $mysqld_pid + # mysqld should remove the pid file when it exits, so wait for it. + wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? + else + log_failure_msg "MySQL server process #$mysqld_pid is not running!" + rm "$mysqld_pid_file_path" + fi + + # Delete lock for RedHat / SuSE + if test -f "$lock_file_path" + then + rm -f "$lock_file_path" + fi + exit $return_value + else + log_failure_msg "MySQL server PID file could not be found!" + fi + ;; + + 'restart') + # Stop the service and regardless of whether it was + # running or not, start it again. + if $0 stop $other_args; then + $0 start $other_args + else + log_failure_msg "Failed to stop running server, so refusing to try to start." + exit 1 + fi + ;; + + 'reload'|'force-reload') + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" + touch "$mysqld_pid_file_path" + else + log_failure_msg "MySQL PID file could not be found!" + exit 1 + fi + ;; + 'status') + # First, check to see if pid file exists + if test -s "$mysqld_pid_file_path" ; then + read mysqld_pid < "$mysqld_pid_file_path" + if kill -0 $mysqld_pid 2>/dev/null ; then + log_success_msg "MySQL running ($mysqld_pid)" + exit 0 + else + log_failure_msg "MySQL is not running, but PID file exists" + exit 1 + fi + else + # Try to find appropriate mysqld process + mysqld_pid=`pgrep -d' ' -f $libexecdir/mysqld` + + # test if multiple pids exist + pid_count=`echo $mysqld_pid | wc -w` + if test $pid_count -gt 1 ; then + log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" + exit 5 + elif test -z $mysqld_pid ; then + if test -f "$lock_file_path" ; then + log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" + exit 2 + fi + log_failure_msg "MySQL is not running" + exit 3 + else + log_failure_msg "MySQL is running but PID file could not be found" + exit 4 + fi + fi + ;; + *) + # usage + basename=`basename "$0"` + echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" + exit 1 + ;; +esac + +exit 0 From 9570ab1c21c7ed8696215b359d159e4a0d512d62 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:12:40 +0800 Subject: [PATCH 083/173] Update index.py --- plugins/mariadb/index.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 825eecb3f..6069ba4a6 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -80,9 +80,9 @@ def getConf(): def getInitdTpl(version=''): - path = getPluginDir() + '/init.d/mysql' + version + '.tpl' + path = getPluginDir() + '/init.d/mariadb' + version + '.tpl' if not os.path.exists(path): - path = getPluginDir() + '/init.d/mysql.tpl' + path = getPluginDir() + '/init.d/mariadb.tpl' return path @@ -121,6 +121,9 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): + sys.path.append(getPluginDir() + "/class") + import orm + db = orm.ORM() db.setDbConf(getConf()) db.setPwd(pSqliteDb('config').where( From fe47c64abb7a6ded5af2f628c4bbdc6db8f7f81d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:21:27 +0800 Subject: [PATCH 084/173] Update orm.py --- plugins/mariadb/class/orm.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/class/orm.py b/plugins/mariadb/class/orm.py index 358309240..5e61ea39e 100755 --- a/plugins/mariadb/class/orm.py +++ b/plugins/mariadb/class/orm.py @@ -38,8 +38,13 @@ class ORM: except: self.__DB_PORT = 3306 - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) self.__DB_CUR = self.__DB_CONN.cursor() return True From 62166638313b4bd13884ee76c6e38c0f2092bb42 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:25:19 +0800 Subject: [PATCH 085/173] Update orm.py --- plugins/mariadb/class/orm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/class/orm.py b/plugins/mariadb/class/orm.py index 5e61ea39e..2c615c743 100755 --- a/plugins/mariadb/class/orm.py +++ b/plugins/mariadb/class/orm.py @@ -87,7 +87,7 @@ class ORM: except Exception as ex: return ex - # 关闭连接 def __Close(self): + # 关闭连接 self.__DB_CUR.close() self.__DB_CONN.close() From ba85f5729867a819499f210bbf4f399f98d8948a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:37:15 +0800 Subject: [PATCH 086/173] Update info.json --- plugins/mysql-yum/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mysql-yum/info.json b/plugins/mysql-yum/info.json index ae5fda0f6..10a6b391c 100755 --- a/plugins/mysql-yum/info.json +++ b/plugins/mysql-yum/info.json @@ -3,7 +3,7 @@ "tip":"soft", "name":"mysql-yum", "type":"运行环境", - "ps":"[开发中..不要使用]一种关系数据库管理系统(极速安装)[YUM]!", + "ps":"一种关系数据库管理系统(极速安装)[YUM]!", "todo_versions":["5.7","8.0"], "versions":["5.7","8.0"], "shell":"install.sh", From 58038944b5bdc6480025dfd4e24bca2996b39fcd Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:44:19 +0800 Subject: [PATCH 087/173] up --- plugins/mysql/class/mysqlDb.py | 3 +- plugins/mysql/class/orm.py | 93 ++++++++++++++++++++++++++++++++++ plugins/mysql/index.py | 30 ++--------- 3 files changed, 99 insertions(+), 27 deletions(-) create mode 100755 plugins/mysql/class/orm.py diff --git a/plugins/mysql/class/mysqlDb.py b/plugins/mysql/class/mysqlDb.py index 867d3f3d7..0f27e56e9 100755 --- a/plugins/mysql/class/mysqlDb.py +++ b/plugins/mysql/class/mysqlDb.py @@ -43,8 +43,7 @@ class mysqlDb: self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) except: self.__DB_PORT = 3306 - # print self.__DB_PASS - #self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root') + try: self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) diff --git a/plugins/mysql/class/orm.py b/plugins/mysql/class/orm.py new file mode 100755 index 000000000..2c615c743 --- /dev/null +++ b/plugins/mysql/class/orm.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +import re +import os +import sys + + +from mysql import connector + +sys.path.append(os.getcwd() + "/class/core") +import mw + +# if mw.isAppleSystem(): +# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' +# info = mw.execShell(cmd) +# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" +# sys.path.append(p) + + +class ORM: + __DB_PASS = None + __DB_USER = 'root' + __DB_PORT = 3306 + __DB_HOST = 'localhost' + __DB_CONN = None + __DB_CUR = None + __DB_ERR = None + __DB_CNF = '/etc/my.cnf' + + def __Conn(self): + '''连接MYSQL数据库''' + try: + socket = '/www/server/mariadb/mysql.sock' + try: + myconf = mw.readFile(self.__DB_CNF) + rep = "port\s*=\s*([0-9]+)" + self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) + except: + self.__DB_PORT = 3306 + + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + + self.__DB_CUR = self.__DB_CONN.cursor() + return True + except Exception as e: + self.__DB_ERR = e + return False + + def setDbConf(self, conf): + self.__DB_CNF = conf + + def setPwd(self, pwd): + self.__DB_PASS = pwd + + def getPwd(self): + return self.__DB_PASS + + def execute(self, sql): + # 执行SQL语句返回受影响行 + if not self.__Conn(): + return self.__DB_ERR + try: + result = self.__DB_CUR.execute(sql) + self.__DB_CONN.commit() + self.__Close() + return result + except Exception as ex: + return ex + + def query(self, sql): + # 执行SQL语句返回数据集 + if not self.__Conn(): + return self.__DB_ERR + try: + self.__DB_CUR.execute(sql) + result = self.__DB_CUR.fetchall() + # 将元组转换成列表 + # data = list(map(list, result)) + self.__Close() + return result + except Exception as ex: + return ex + + def __Close(self): + # 关闭连接 + self.__DB_CUR.close() + self.__DB_CONN.close() diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 8a4898ae2..310babef6 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -49,31 +49,9 @@ def getInitDFile(): return '/etc/init.d/' + getPluginName() -def is_number(s): - try: - float(s) - return True - except ValueError: - pass - - try: - import unicodedata - unicodedata.numeric(s) - return True - except (TypeError, ValueError): - pass - - return False - - def getArgs(): args = sys.argv[2:] - # print(args) - - # if is_number(args): - # args = sys.argv[3:] - tmp = {} args_len = len(args) @@ -143,11 +121,13 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mysqlDb.mysqlDb() + sys.path.append(getPluginDir() + "/class") + import orm + + db = orm.ORM() db.__DB_CNF = getConf() db.setDbConf(getConf()) - db.setPwd(pSqliteDb('config').where( - 'id=?', (1,)).getField('mysql_root')) + db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From 8aeb5c660362759f3158f125e73c70730f417553 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 12:46:22 +0800 Subject: [PATCH 088/173] up --- plugins/mysql-yum/class/orm.py | 93 ++++++++++++++++++++++++++++++++++ plugins/mysql-yum/index.py | 8 +-- 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100755 plugins/mysql-yum/class/orm.py diff --git a/plugins/mysql-yum/class/orm.py b/plugins/mysql-yum/class/orm.py new file mode 100755 index 000000000..2c615c743 --- /dev/null +++ b/plugins/mysql-yum/class/orm.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +import re +import os +import sys + + +from mysql import connector + +sys.path.append(os.getcwd() + "/class/core") +import mw + +# if mw.isAppleSystem(): +# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' +# info = mw.execShell(cmd) +# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" +# sys.path.append(p) + + +class ORM: + __DB_PASS = None + __DB_USER = 'root' + __DB_PORT = 3306 + __DB_HOST = 'localhost' + __DB_CONN = None + __DB_CUR = None + __DB_ERR = None + __DB_CNF = '/etc/my.cnf' + + def __Conn(self): + '''连接MYSQL数据库''' + try: + socket = '/www/server/mariadb/mysql.sock' + try: + myconf = mw.readFile(self.__DB_CNF) + rep = "port\s*=\s*([0-9]+)" + self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) + except: + self.__DB_PORT = 3306 + + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + + self.__DB_CUR = self.__DB_CONN.cursor() + return True + except Exception as e: + self.__DB_ERR = e + return False + + def setDbConf(self, conf): + self.__DB_CNF = conf + + def setPwd(self, pwd): + self.__DB_PASS = pwd + + def getPwd(self): + return self.__DB_PASS + + def execute(self, sql): + # 执行SQL语句返回受影响行 + if not self.__Conn(): + return self.__DB_ERR + try: + result = self.__DB_CUR.execute(sql) + self.__DB_CONN.commit() + self.__Close() + return result + except Exception as ex: + return ex + + def query(self, sql): + # 执行SQL语句返回数据集 + if not self.__Conn(): + return self.__DB_ERR + try: + self.__DB_CUR.execute(sql) + result = self.__DB_CUR.fetchall() + # 将元组转换成列表 + # data = list(map(list, result)) + self.__Close() + return result + except Exception as ex: + return ex + + def __Close(self): + # 关闭连接 + self.__DB_CUR.close() + self.__DB_CONN.close() diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index cbcbae301..148e2fc20 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -125,11 +125,13 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - db = mysqlDb.mysqlDb() + sys.path.append(getPluginDir() + "/class") + import orm + + db = orm.ORM() db.__DB_CNF = getConf() db.setDbConf(getConf()) - db.setPwd(pSqliteDb('config').where( - 'id=?', (1,)).getField('mysql_root')) + db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From 8a63b081344a4bfd7114b3d75d09d0a2cc3b216f Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 13:37:10 +0800 Subject: [PATCH 089/173] Update orm.py --- plugins/mysql/class/orm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/mysql/class/orm.py b/plugins/mysql/class/orm.py index 2c615c743..2410917d8 100755 --- a/plugins/mysql/class/orm.py +++ b/plugins/mysql/class/orm.py @@ -30,13 +30,17 @@ class ORM: def __Conn(self): '''连接MYSQL数据库''' try: - socket = '/www/server/mariadb/mysql.sock' + try: myconf = mw.readFile(self.__DB_CNF) rep = "port\s*=\s*([0-9]+)" self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) + + rep = "socket\s*=\s*(.*)" + socket = re.search(rep, myconf).groups()[0] except: self.__DB_PORT = 3306 + socket = '/www/server/mysql/mysql.sock' try: self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, From 97c527660f47bac35b1a331fc6d9312b83a30d12 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 13:55:55 +0800 Subject: [PATCH 090/173] up --- class/core/mw.py | 10 ++++++ class/plugin/orm.py | 76 ++++++++++++++++++++++++++++++++++++++++ plugins/mariadb/index.py | 60 ++++++++++++++++++++----------- 3 files changed, 125 insertions(+), 21 deletions(-) create mode 100755 class/plugin/orm.py diff --git a/class/core/mw.py b/class/core/mw.py index 76daa8e5b..4f706e9e9 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -1004,3 +1004,13 @@ def requestFcgiPHP(sock, uri, document_root='/tmp', method='GET', pdata=b''): pdata = url_encode(pdata) result = p.load_url_public(uri, pdata, method) return result + + +def getMyORM(): + ''' + 获取MySQL资源的ORM + ''' + sys.path.append(os.getcwd() + "/class/plugin") + import orm + o = orm.ORM() + return o diff --git a/class/plugin/orm.py b/class/plugin/orm.py new file mode 100755 index 000000000..d590b738e --- /dev/null +++ b/class/plugin/orm.py @@ -0,0 +1,76 @@ +# coding: utf-8 + +import re +import os +import sys + +from mysql import connector + + +class ORM: + __DB_PASS = None + __DB_USER = 'root' + __DB_PORT = 3306 + __DB_HOST = 'localhost' + __DB_CONN = None + __DB_CUR = None + __DB_ERR = None + __DB_CNF = '/etc/my.cnf' + __DB_SOCKET = '/www/server/mysql/mysql.sock' + + def __Conn(self): + '''连接MYSQL数据库''' + try: + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + + self.__DB_CUR = self.__DB_CONN.cursor() + return True + except Exception as e: + self.__DB_ERR = e + return False + + def setDbConf(self, conf): + self.__DB_CNF = conf + + def setPwd(self, pwd): + self.__DB_PASS = pwd + + def getPwd(self): + return self.__DB_PASS + + def execute(self, sql): + # 执行SQL语句返回受影响行 + if not self.__Conn(): + return self.__DB_ERR + try: + result = self.__DB_CUR.execute(sql) + self.__DB_CONN.commit() + self.__Close() + return result + except Exception as ex: + return ex + + def query(self, sql): + # 执行SQL语句返回数据集 + if not self.__Conn(): + return self.__DB_ERR + try: + self.__DB_CUR.execute(sql) + result = self.__DB_CUR.fetchall() + # 将元组转换成列表 + # data = list(map(list, result)) + self.__Close() + return result + except Exception as ex: + return ex + + def __Close(self): + # 关闭连接 + self.__DB_CUR.close() + self.__DB_CONN.close() diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 6069ba4a6..092cceef0 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -79,6 +79,38 @@ def getConf(): return path +def getDataDir(): + file = getConf() + content = mw.readFile(file) + rep = 'datadir\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getPidFile(): + file = getConf() + content = mw.readFile(file) + rep = 'pid-file\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getDbPort(): + file = getConf() + content = mw.readFile(file) + rep = 'port\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getSocketFile(): + file = getConf() + content = mw.readFile(file) + rep = 'socket\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def getInitdTpl(version=''): path = getPluginDir() + '/init.d/mariadb' + version + '.tpl' if not os.path.exists(path): @@ -121,13 +153,15 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - sys.path.append(getPluginDir() + "/class") - import orm + db = mw.getMyORM() - db = orm.ORM() db.setDbConf(getConf()) - db.setPwd(pSqliteDb('config').where( - 'id=?', (1,)).getField('mysql_root')) + + db.__DB_PORT = getDbPort() + db.__DB_SOCKET = getSocketFile() + + pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') + db.setPwd(pwd) return db @@ -187,22 +221,6 @@ def status(version=''): return 'stop' -def getDataDir(): - file = getConf() - content = mw.readFile(file) - rep = 'datadir\s*=\s*(.*)' - tmp = re.search(rep, content) - return tmp.groups()[0].strip() - - -def getPidFile(): - file = getConf() - content = mw.readFile(file) - rep = 'pid-file\s*=\s*(.*)' - tmp = re.search(rep, content) - return tmp.groups()[0].strip() - - def binLog(): args = getArgs() conf = getConf() From 34bb0baf4969ca851ce5351da3ee359429400b93 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 13:59:51 +0800 Subject: [PATCH 091/173] Update info.json --- plugins/mariadb/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/info.json b/plugins/mariadb/info.json index 440997690..771222dc7 100755 --- a/plugins/mariadb/info.json +++ b/plugins/mariadb/info.json @@ -3,7 +3,7 @@ "tip":"soft", "name":"mariadb", "type":"运行环境", - "ps":"[DEV]一种关系数据库管理系统!", + "ps":"一种关系数据库管理系统!", "uninstall_pre_inspection":true, "checks": "server/mariadb", "path": "server/mariadb", From a91552d4267326b91cbcc2818ec8c778db50ff1e Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 14:02:18 +0800 Subject: [PATCH 092/173] Update lib.sh --- scripts/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 8c16c5330..7d81063ef 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -134,7 +134,7 @@ pip3 install flask-session==0.3.2 pip3 install pymongo pip3 install psutil pip3 install flask-socketio==5.2.0 -pip3 install mysqlclient +# pip3 install mysqlclient if [ ! -f /www/server/mdserver-web/bin/activate ];then @@ -155,5 +155,5 @@ pip3 install flask-session==0.3.2 pip3 install pymongo pip3 install psutil pip3 install flask-socketio==5.2.0 -pip3 install mysqlclient +# pip3 install mysqlclient From e7ed94b6091a5564cb202034452a3e7456f2ba95 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 14:03:10 +0800 Subject: [PATCH 093/173] Update lib.sh --- scripts/lib.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 7d81063ef..55dd284d9 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -128,11 +128,8 @@ pip3 install --upgrade setuptools cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt pip3 install gevent-websocket==0.10.1 -pip3 install requests==2.20.0 pip3 install flask-caching==1.10.1 pip3 install flask-session==0.3.2 -pip3 install pymongo -pip3 install psutil pip3 install flask-socketio==5.2.0 # pip3 install mysqlclient @@ -149,11 +146,8 @@ pip3 install --upgrade setuptools pip3 install -r /www/server/mdserver-web/requirements.txt pip3 install gevent-websocket==0.10.1 -pip3 install requests==2.20.0 pip3 install flask-caching==1.10.1 pip3 install flask-session==0.3.2 -pip3 install pymongo -pip3 install psutil pip3 install flask-socketio==5.2.0 # pip3 install mysqlclient From 2a060edff2bf8fcffd0f6d193b7f1e4c9bb3f2fe Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 14:05:01 +0800 Subject: [PATCH 094/173] Update orm.py --- plugins/mysql-yum/class/orm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/mysql-yum/class/orm.py b/plugins/mysql-yum/class/orm.py index 2c615c743..281d5cac0 100755 --- a/plugins/mysql-yum/class/orm.py +++ b/plugins/mysql-yum/class/orm.py @@ -30,13 +30,16 @@ class ORM: def __Conn(self): '''连接MYSQL数据库''' try: - socket = '/www/server/mariadb/mysql.sock' try: myconf = mw.readFile(self.__DB_CNF) rep = "port\s*=\s*([0-9]+)" self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) + + rep = "socket\s*=\s*(.*)" + socket = re.search(rep, myconf).groups()[0] except: self.__DB_PORT = 3306 + socket = '/www/server/mysql-yum/mysql.sock' try: self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, From 5197e931d205e1f3d20881ad83b50b593f3f0d12 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 14:06:10 +0800 Subject: [PATCH 095/173] Delete orm.py --- plugins/mariadb/class/orm.py | 93 ------------------------------------ 1 file changed, 93 deletions(-) delete mode 100755 plugins/mariadb/class/orm.py diff --git a/plugins/mariadb/class/orm.py b/plugins/mariadb/class/orm.py deleted file mode 100755 index 2c615c743..000000000 --- a/plugins/mariadb/class/orm.py +++ /dev/null @@ -1,93 +0,0 @@ -# coding: utf-8 - -import re -import os -import sys - - -from mysql import connector - -sys.path.append(os.getcwd() + "/class/core") -import mw - -# if mw.isAppleSystem(): -# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -# info = mw.execShell(cmd) -# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -# sys.path.append(p) - - -class ORM: - __DB_PASS = None - __DB_USER = 'root' - __DB_PORT = 3306 - __DB_HOST = 'localhost' - __DB_CONN = None - __DB_CUR = None - __DB_ERR = None - __DB_CNF = '/etc/my.cnf' - - def __Conn(self): - '''连接MYSQL数据库''' - try: - socket = '/www/server/mariadb/mysql.sock' - try: - myconf = mw.readFile(self.__DB_CNF) - rep = "port\s*=\s*([0-9]+)" - self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) - except: - self.__DB_PORT = 3306 - - try: - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except Exception as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - - self.__DB_CUR = self.__DB_CONN.cursor() - return True - except Exception as e: - self.__DB_ERR = e - return False - - def setDbConf(self, conf): - self.__DB_CNF = conf - - def setPwd(self, pwd): - self.__DB_PASS = pwd - - def getPwd(self): - return self.__DB_PASS - - def execute(self, sql): - # 执行SQL语句返回受影响行 - if not self.__Conn(): - return self.__DB_ERR - try: - result = self.__DB_CUR.execute(sql) - self.__DB_CONN.commit() - self.__Close() - return result - except Exception as ex: - return ex - - def query(self, sql): - # 执行SQL语句返回数据集 - if not self.__Conn(): - return self.__DB_ERR - try: - self.__DB_CUR.execute(sql) - result = self.__DB_CUR.fetchall() - # 将元组转换成列表 - # data = list(map(list, result)) - self.__Close() - return result - except Exception as ex: - return ex - - def __Close(self): - # 关闭连接 - self.__DB_CUR.close() - self.__DB_CONN.close() From a2628df36869be0dc9df49b396a42a589d18cf92 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 14:10:28 +0800 Subject: [PATCH 096/173] up --- class/plugin/orm.py | 4 ++-- plugins/mariadb/scripts/test.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/class/plugin/orm.py b/class/plugin/orm.py index d590b738e..a5d12c956 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -23,11 +23,11 @@ class ORM: try: try: self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) except Exception as e: self.__DB_HOST = '127.0.0.1' self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) self.__DB_CUR = self.__DB_CONN.cursor() return True diff --git a/plugins/mariadb/scripts/test.py b/plugins/mariadb/scripts/test.py index c32da0405..b4ef50fd2 100644 --- a/plugins/mariadb/scripts/test.py +++ b/plugins/mariadb/scripts/test.py @@ -18,8 +18,7 @@ root_dir = os.path.dirname(os.path.dirname(plugin_dir)) sys.path.append(root_dir + "/class/core") import mw -sys.path.append(plugin_dir + "/class") -import orm +os.chdir(root_dir) def getPluginName(): @@ -54,8 +53,11 @@ def getConf(): def pMysqlDb(): - db = orm.ORM() + db = mw.getMyORM() db.setDbConf(getConf()) + db.__DB_SOCKET = mw.getServerDir() + '/mysql/mysql.socket' + + print(mw.getServerDir() + '/mysql/mysql.socket') db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From b78aa28f15d30435c7da40ab8dee541f4a7d74a6 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 15:39:24 +0800 Subject: [PATCH 097/173] up --- class/plugin/orm.py | 24 +++++--- plugins/mysql-yum/class/mysqlDb.py | 99 ------------------------------ plugins/mysql-yum/class/orm.py | 96 ----------------------------- plugins/mysql-yum/index.py | 81 +++++++++++------------- plugins/mysql/class/mysqlDb.py | 98 ----------------------------- plugins/mysql/class/orm.py | 97 ----------------------------- plugins/mysql/index.py | 27 +++++--- 7 files changed, 71 insertions(+), 451 deletions(-) delete mode 100755 plugins/mysql-yum/class/mysqlDb.py delete mode 100755 plugins/mysql-yum/class/orm.py delete mode 100755 plugins/mysql/class/mysqlDb.py delete mode 100755 plugins/mysql/class/orm.py diff --git a/class/plugin/orm.py b/class/plugin/orm.py index a5d12c956..3bbd663fd 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -21,13 +21,23 @@ class ORM: def __Conn(self): '''连接MYSQL数据库''' try: - try: - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) - except Exception as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) + + if os.path.exists(self.__DB_SOCKET): + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=self.__DB_SOCKET) + else: + try: + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1) + except Exception as e: + self.__DB_HOST = '127.0.0.1' + self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, + port=self.__DB_PORT, charset="utf8", connect_timeout=1) self.__DB_CUR = self.__DB_CONN.cursor() return True diff --git a/plugins/mysql-yum/class/mysqlDb.py b/plugins/mysql-yum/class/mysqlDb.py deleted file mode 100755 index 6f5d74ecc..000000000 --- a/plugins/mysql-yum/class/mysqlDb.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding: utf-8 - -import re -import os -import sys - -# sys.path.append("/usr/local/lib/python3.9/site-packages") - -sys.path.append(os.getcwd() + "/class/core") -import mw - -# if mw.isAppleSystem(): -# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -# info = mw.execShell(cmd) -# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -# sys.path.append(p) - - -class mysqlDb: - __DB_PASS = None - __DB_USER = 'root' - __DB_PORT = 3306 - __DB_HOST = 'localhost' - __DB_CONN = None - __DB_CUR = None - __DB_ERR = None - __DB_CNF = '/etc/my.cnf' - - def __Conn(self): - '''连接MYSQL数据库''' - try: - import mw - socket = '/www/server/mysql-ya/mysql.sock' - try: - import MySQLdb - except Exception as ex: - # print('dd') - self.__DB_ERR = ex - return False - try: - myconf = mw.readFile(self.__DB_CNF) - rep = "port\s*=\s*([0-9]+)" - self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) - except: - self.__DB_PORT = 3306 - # print self.__DB_PASS - #self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root') - try: - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except MySQLdb.Error as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - self.__DB_CUR = self.__DB_CONN.cursor() - return True - except MySQLdb.Error as e: - self.__DB_ERR = e - return False - - def setDbConf(self, conf): - self.__DB_CNF = conf - - def setPwd(self, pwd): - self.__DB_PASS = pwd - - def getPwd(self): - return self.__DB_PASS - - def execute(self, sql): - # 执行SQL语句返回受影响行 - if not self.__Conn(): - return self.__DB_ERR - try: - result = self.__DB_CUR.execute(sql) - self.__DB_CONN.commit() - self.__Close() - return result - except Exception as ex: - return ex - - def query(self, sql): - # 执行SQL语句返回数据集 - if not self.__Conn(): - return self.__DB_ERR - try: - self.__DB_CUR.execute(sql) - result = self.__DB_CUR.fetchall() - # 将元组转换成列表 - # data = list(map(list, result)) - self.__Close() - return result - except Exception as ex: - return ex - - # 关闭连接 - def __Close(self): - self.__DB_CUR.close() - self.__DB_CONN.close() diff --git a/plugins/mysql-yum/class/orm.py b/plugins/mysql-yum/class/orm.py deleted file mode 100755 index 281d5cac0..000000000 --- a/plugins/mysql-yum/class/orm.py +++ /dev/null @@ -1,96 +0,0 @@ -# coding: utf-8 - -import re -import os -import sys - - -from mysql import connector - -sys.path.append(os.getcwd() + "/class/core") -import mw - -# if mw.isAppleSystem(): -# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -# info = mw.execShell(cmd) -# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -# sys.path.append(p) - - -class ORM: - __DB_PASS = None - __DB_USER = 'root' - __DB_PORT = 3306 - __DB_HOST = 'localhost' - __DB_CONN = None - __DB_CUR = None - __DB_ERR = None - __DB_CNF = '/etc/my.cnf' - - def __Conn(self): - '''连接MYSQL数据库''' - try: - try: - myconf = mw.readFile(self.__DB_CNF) - rep = "port\s*=\s*([0-9]+)" - self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) - - rep = "socket\s*=\s*(.*)" - socket = re.search(rep, myconf).groups()[0] - except: - self.__DB_PORT = 3306 - socket = '/www/server/mysql-yum/mysql.sock' - - try: - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except Exception as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - - self.__DB_CUR = self.__DB_CONN.cursor() - return True - except Exception as e: - self.__DB_ERR = e - return False - - def setDbConf(self, conf): - self.__DB_CNF = conf - - def setPwd(self, pwd): - self.__DB_PASS = pwd - - def getPwd(self): - return self.__DB_PASS - - def execute(self, sql): - # 执行SQL语句返回受影响行 - if not self.__Conn(): - return self.__DB_ERR - try: - result = self.__DB_CUR.execute(sql) - self.__DB_CONN.commit() - self.__Close() - return result - except Exception as ex: - return ex - - def query(self, sql): - # 执行SQL语句返回数据集 - if not self.__Conn(): - return self.__DB_ERR - try: - self.__DB_CUR.execute(sql) - result = self.__DB_CUR.fetchall() - # 将元组转换成列表 - # data = list(map(list, result)) - self.__Close() - return result - except Exception as ex: - return ex - - def __Close(self): - # 关闭连接 - self.__DB_CUR.close() - self.__DB_CONN.close() diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index 148e2fc20..c681667fe 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -35,39 +35,14 @@ def getPluginName(): def getPluginDir(): return mw.getPluginDir() + '/' + getPluginName() -sys.path.append(getPluginDir() + "/class") -import mysqlDb - def getServerDir(): return mw.getServerDir() + '/' + getPluginName() -def is_number(s): - try: - float(s) - return True - except ValueError: - pass - - try: - import unicodedata - unicodedata.numeric(s) - return True - except (TypeError, ValueError): - pass - - return False - - def getArgs(): args = sys.argv[2:] - # print(args) - - # if is_number(args): - # args = sys.argv[3:] - tmp = {} args_len = len(args) @@ -95,6 +70,38 @@ def getConf(): return path +def getDataDir(): + file = getConf() + content = mw.readFile(file) + rep = 'datadir\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getPidFile(): + file = getConf() + content = mw.readFile(file) + rep = 'pid-file\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getDbPort(): + file = getConf() + content = mw.readFile(file) + rep = 'port\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getSocketFile(): + file = getConf() + content = mw.readFile(file) + rep = 'socket\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def contentReplace(content): service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getRootDir()) @@ -125,12 +132,10 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - sys.path.append(getPluginDir() + "/class") - import orm - - db = orm.ORM() + db = mw.getMyORM() db.__DB_CNF = getConf() - db.setDbConf(getConf()) + db.__DB_PORT = getDbPort() + db.__DB_SOCKET = getSocketFile() db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db @@ -176,22 +181,6 @@ def status(version=''): return 'start' -def getDataDir(): - file = getConf() - content = mw.readFile(file) - rep = 'datadir\s*=\s*(.*)' - tmp = re.search(rep, content) - return tmp.groups()[0].strip() - - -def getPidFile(): - file = getConf() - content = mw.readFile(file) - rep = 'pid-file\s*=\s*(.*)' - tmp = re.search(rep, content) - return tmp.groups()[0].strip() - - def binLog(): args = getArgs() conf = getConf() diff --git a/plugins/mysql/class/mysqlDb.py b/plugins/mysql/class/mysqlDb.py deleted file mode 100755 index 0f27e56e9..000000000 --- a/plugins/mysql/class/mysqlDb.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding: utf-8 - -import re -import os -import sys - -# sys.path.append("/usr/local/lib/python3.9/site-packages") - -sys.path.append(os.getcwd() + "/class/core") -import mw - -# if mw.isAppleSystem(): -# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -# info = mw.execShell(cmd) -# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -# sys.path.append(p) - - -class mysqlDb: - __DB_PASS = None - __DB_USER = 'root' - __DB_PORT = 3306 - __DB_HOST = 'localhost' - __DB_CONN = None - __DB_CUR = None - __DB_ERR = None - __DB_CNF = '/etc/my.cnf' - - def __Conn(self): - '''连接MYSQL数据库''' - try: - import mw - socket = '/www/server/mysql/mysql.sock' - try: - import MySQLdb - except Exception as ex: - # print('dd') - self.__DB_ERR = ex - return False - try: - myconf = mw.readFile(self.__DB_CNF) - rep = "port\s*=\s*([0-9]+)" - self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) - except: - self.__DB_PORT = 3306 - - try: - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except MySQLdb.Error as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - self.__DB_CUR = self.__DB_CONN.cursor() - return True - except MySQLdb.Error as e: - self.__DB_ERR = e - return False - - def setDbConf(self, conf): - self.__DB_CNF = conf - - def setPwd(self, pwd): - self.__DB_PASS = pwd - - def getPwd(self): - return self.__DB_PASS - - def execute(self, sql): - # 执行SQL语句返回受影响行 - if not self.__Conn(): - return self.__DB_ERR - try: - result = self.__DB_CUR.execute(sql) - self.__DB_CONN.commit() - self.__Close() - return result - except Exception as ex: - return ex - - def query(self, sql): - # 执行SQL语句返回数据集 - if not self.__Conn(): - return self.__DB_ERR - try: - self.__DB_CUR.execute(sql) - result = self.__DB_CUR.fetchall() - # 将元组转换成列表 - # data = list(map(list, result)) - self.__Close() - return result - except Exception as ex: - return ex - - # 关闭连接 - def __Close(self): - self.__DB_CUR.close() - self.__DB_CONN.close() diff --git a/plugins/mysql/class/orm.py b/plugins/mysql/class/orm.py deleted file mode 100755 index 2410917d8..000000000 --- a/plugins/mysql/class/orm.py +++ /dev/null @@ -1,97 +0,0 @@ -# coding: utf-8 - -import re -import os -import sys - - -from mysql import connector - -sys.path.append(os.getcwd() + "/class/core") -import mw - -# if mw.isAppleSystem(): -# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -# info = mw.execShell(cmd) -# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -# sys.path.append(p) - - -class ORM: - __DB_PASS = None - __DB_USER = 'root' - __DB_PORT = 3306 - __DB_HOST = 'localhost' - __DB_CONN = None - __DB_CUR = None - __DB_ERR = None - __DB_CNF = '/etc/my.cnf' - - def __Conn(self): - '''连接MYSQL数据库''' - try: - - try: - myconf = mw.readFile(self.__DB_CNF) - rep = "port\s*=\s*([0-9]+)" - self.__DB_PORT = int(re.search(rep, myconf).groups()[0]) - - rep = "socket\s*=\s*(.*)" - socket = re.search(rep, myconf).groups()[0] - except: - self.__DB_PORT = 3306 - socket = '/www/server/mysql/mysql.sock' - - try: - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - except Exception as e: - self.__DB_HOST = '127.0.0.1' - self.__DB_CONN = connector.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS, - port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket) - - self.__DB_CUR = self.__DB_CONN.cursor() - return True - except Exception as e: - self.__DB_ERR = e - return False - - def setDbConf(self, conf): - self.__DB_CNF = conf - - def setPwd(self, pwd): - self.__DB_PASS = pwd - - def getPwd(self): - return self.__DB_PASS - - def execute(self, sql): - # 执行SQL语句返回受影响行 - if not self.__Conn(): - return self.__DB_ERR - try: - result = self.__DB_CUR.execute(sql) - self.__DB_CONN.commit() - self.__Close() - return result - except Exception as ex: - return ex - - def query(self, sql): - # 执行SQL语句返回数据集 - if not self.__Conn(): - return self.__DB_ERR - try: - self.__DB_CUR.execute(sql) - result = self.__DB_CUR.fetchall() - # 将元组转换成列表 - # data = list(map(list, result)) - self.__Close() - return result - except Exception as ex: - return ex - - def __Close(self): - # 关闭连接 - self.__DB_CUR.close() - self.__DB_CONN.close() diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 310babef6..8af90b93f 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -35,9 +35,6 @@ def getPluginName(): def getPluginDir(): return mw.getPluginDir() + '/' + getPluginName() -sys.path.append(getPluginDir() + "/class") -import mysqlDb - def getServerDir(): return mw.getServerDir() + '/' + getPluginName() @@ -79,6 +76,22 @@ def getConf(): return path +def getDbPort(): + file = getConf() + content = mw.readFile(file) + rep = 'port\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getSocketFile(): + file = getConf() + content = mw.readFile(file) + rep = 'socket\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def getInitdTpl(version=''): path = getPluginDir() + '/init.d/mysql' + version + '.tpl' if not os.path.exists(path): @@ -121,12 +134,10 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): - sys.path.append(getPluginDir() + "/class") - import orm - - db = orm.ORM() + db = mw.getMyORM() db.__DB_CNF = getConf() - db.setDbConf(getConf()) + db.__DB_PORT = getDbPort() + db.__DB_SOCKET = getSocketFile() db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From 76e5f7b25a44c907ca774576a5301ac2e7d67748 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 15:44:36 +0800 Subject: [PATCH 098/173] up --- plugins/mariadb/info.json | 2 +- plugins/mariadb/versions/10.7/install.sh | 87 ++++++++++++++++++++++++ plugins/mariadb/versions/10.8/install.sh | 87 ++++++++++++++++++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100755 plugins/mariadb/versions/10.7/install.sh create mode 100755 plugins/mariadb/versions/10.8/install.sh diff --git a/plugins/mariadb/info.json b/plugins/mariadb/info.json index 771222dc7..e0b2692c7 100755 --- a/plugins/mariadb/info.json +++ b/plugins/mariadb/info.json @@ -7,7 +7,7 @@ "uninstall_pre_inspection":true, "checks": "server/mariadb", "path": "server/mariadb", - "versions":["10.6"], + "versions":["10.6","10.7","10.8"], "shell":"install.sh", "checks":"server/mariadb", "path":"server/mariadb", diff --git a/plugins/mariadb/versions/10.7/install.sh b/plugins/mariadb/versions/10.7/install.sh new file mode 100755 index 000000000..2368f96f0 --- /dev/null +++ b/plugins/mariadb/versions/10.7/install.sh @@ -0,0 +1,87 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +#https://dev.mysql.com/downloads/mysql/5.5.html#downloads +#https://dev.mysql.com/downloads/file/?id=480541 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +install_tmp=${rootPath}/tmp/mw_install.pl +mariadbDir=${serverPath}/source/mariadb + +MY_VER=10.7.4 + +Install_app() +{ + mkdir -p ${mariadbDir} + echo '正在安装脚本文件...' > $install_tmp + + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + + if [ "$sysName" != "Darwin" ];then + mkdir -p /var/log/mariadb + touch /var/log/mariadb/mariadb.log + fi + + if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then + wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz + fi + + if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then + cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz + fi + + + if [ ! -d $serverPath/mariadb ];then + cd ${mariadbDir}/mariadb-${MY_VER} && cmake \ + -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ + -DMYSQL_DATADIR=$serverPath/mariadb/data/ \ + -DMYSQL_USER=mysql \ + -DMYSQL_UNIX_ADDR=$serverPath/mariadb/mysql.sock \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_MEMORY_STORAGE_ENGINE=1 \ + -DENABLED_LOCAL_INFILE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DEXTRA_CHARSETS=all \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ + make && make install && make clean + + if [ -d $serverPath/mariadb ];then + echo '10.7' > $serverPath/mariadb/version.pl + echo '安装完成' > $install_tmp + else + # rm -rf ${mariadbDir}/mariadb-${MY_VER} + echo '安装失败' > $install_tmp + echo 'install fail'>&2 + exit 1 + fi + fi +} + +Uninstall_app() +{ + rm -rf $serverPath/mariadb + echo '卸载完成' > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_app +else + Uninstall_app +fi diff --git a/plugins/mariadb/versions/10.8/install.sh b/plugins/mariadb/versions/10.8/install.sh new file mode 100755 index 000000000..b17e9c2bc --- /dev/null +++ b/plugins/mariadb/versions/10.8/install.sh @@ -0,0 +1,87 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +#https://dev.mysql.com/downloads/mysql/5.5.html#downloads +#https://dev.mysql.com/downloads/file/?id=480541 + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +install_tmp=${rootPath}/tmp/mw_install.pl +mariadbDir=${serverPath}/source/mariadb + +MY_VER=10.8.3 + +Install_app() +{ + mkdir -p ${mariadbDir} + echo '正在安装脚本文件...' > $install_tmp + + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + + if [ "$sysName" != "Darwin" ];then + mkdir -p /var/log/mariadb + touch /var/log/mariadb/mariadb.log + fi + + if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then + wget -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://downloads.mariadb.org/interstitial/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz + fi + + if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then + cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz + fi + + + if [ ! -d $serverPath/mariadb ];then + cd ${mariadbDir}/mariadb-${MY_VER} && cmake \ + -DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \ + -DMYSQL_DATADIR=$serverPath/mariadb/data/ \ + -DMYSQL_USER=mysql \ + -DMYSQL_UNIX_ADDR=$serverPath/mariadb/mysql.sock \ + -DWITH_MYISAM_STORAGE_ENGINE=1 \ + -DWITH_INNOBASE_STORAGE_ENGINE=1 \ + -DWITH_MEMORY_STORAGE_ENGINE=1 \ + -DENABLED_LOCAL_INFILE=1 \ + -DWITH_PARTITION_STORAGE_ENGINE=1 \ + -DEXTRA_CHARSETS=all \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ + make && make install && make clean + + if [ -d $serverPath/mariadb ];then + echo '10.7' > $serverPath/mariadb/version.pl + echo '安装完成' > $install_tmp + else + # rm -rf ${mariadbDir}/mariadb-${MY_VER} + echo '安装失败' > $install_tmp + echo 'install fail'>&2 + exit 1 + fi + fi +} + +Uninstall_app() +{ + rm -rf $serverPath/mariadb + echo '卸载完成' > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_app +else + Uninstall_app +fi From e3bb93c23294f331dbeef688245b2bfdd928f78d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:08:53 +0800 Subject: [PATCH 099/173] up --- plugins/gogs/index.py | 13 +++++++++++-- plugins/gogs/js/gogs.js | 14 ++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index c5ee31848..5c69ddf4c 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -383,6 +383,10 @@ def postReceiveLog(): def getGogsConf(): + conf = getConf() + if not os.path.exists(conf): + return mw.returnJson(False, "请先安装初始化!") + gets = [ {'name': 'DOMAIN', 'type': -1, 'ps': '服务器域名'}, {'name': 'ROOT_URL', 'type': -1, 'ps': '公开的完整URL路径'}, @@ -403,7 +407,7 @@ def getGogsConf(): {'name': 'SHOW_FOOTER_VERSION', 'type': 2, 'ps': 'Gogs版本信息'}, {'name': 'SHOW_FOOTER_TEMPLATE_LOAD_TIME', 'type': 2, 'ps': 'Gogs模板加载时间'}, ] - conf = mw.readFile(getConf()) + conf = mw.readFile(conf) result = [] for g in gets: @@ -413,7 +417,7 @@ def getGogsConf(): continue g['value'] = tmp.groups()[0] result.append(g) - return mw.getJson(result) + return mw.returnJson(True, 'OK', result) def submitGogsConf(): @@ -445,6 +449,11 @@ def submitGogsConf(): def userList(): + + conf = getConf() + if not os.path.exists(conf): + return mw.returnJson(False, "请先安装初始化!") + import math args = getArgs() diff --git a/plugins/gogs/js/gogs.js b/plugins/gogs/js/gogs.js index 0792201c0..e6318cc8c 100755 --- a/plugins/gogs/js/gogs.js +++ b/plugins/gogs/js/gogs.js @@ -39,9 +39,12 @@ function gogsPost(method,args,callback, title){ function gogsSetConfig(){ gogsPost('get_gogs_conf', '', function(data){ - // console.log(data); - var rdata = $.parseJSON(data.data); - // console.log(rdata); + var rrdata = $.parseJSON(data.data); + if (!rrdata.status){ + layer.msg(rrdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + var rdata = rrdata.data; var mlist = ''; for (var i = 0; i < rdata.length; i++) { var w = '140'; @@ -141,7 +144,10 @@ function gogsUserList(page, search) { gogsPost('user_list', _data, function(data){ var rdata = $.parseJSON(data.data); - // console.log(rdata); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } content = '
'; content += '
'; From 39fcbebe4a92cfddc493eeb175a324a20e462454 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:10:31 +0800 Subject: [PATCH 100/173] Update index.py --- plugins/mariadb/index.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 092cceef0..37b7653c4 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -35,9 +35,6 @@ def getPluginName(): def getPluginDir(): return mw.getPluginDir() + '/' + getPluginName() -sys.path.append(getPluginDir() + "/class") -import mysqlDb - def getServerDir(): return mw.getServerDir() + '/' + getPluginName() From b5e27c22dbe37a9b52e7694c313a91358331c2dd Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:15:17 +0800 Subject: [PATCH 101/173] Update index.py --- plugins/mariadb/index.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 37b7653c4..02f36dc26 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -180,11 +180,6 @@ def initDreplace(version=''): if not os.path.exists(mysql_conf_dir): os.mkdir(mysql_conf_dir) - mysql_tmp = getServerDir() + '/tmp' - if not os.path.exists(mysql_tmp): - os.mkdir(mysql_tmp) - mw.execShell("chown -R mysql:mysql " + mysql_tmp) - mysql_conf = mysql_conf_dir + '/my.cnf' if not os.path.exists(mysql_conf): mysql_conf_tpl = getPluginDir() + '/conf/my.cnf' @@ -192,6 +187,11 @@ def initDreplace(version=''): content = contentReplace(content) mw.writeFile(mysql_conf, content) + mysql_tmp = getServerDir() + '/tmp' + if not os.path.exists(mysql_tmp): + os.mkdir(mysql_tmp) + mw.execShell("chown -R mysql:mysql " + mysql_tmp) + # systemd systemDir = mw.systemdCfgDir() systemService = systemDir + '/mariadb.service' From 83d5eb3c340cdb0c07c4a8e0c6caf6e92bbf7acc Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:17:23 +0800 Subject: [PATCH 102/173] Update index.py --- plugins/mariadb/index.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 02f36dc26..df943dd38 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -169,13 +169,6 @@ def initDreplace(version=''): if not os.path.exists(initD_path): os.mkdir(initD_path) - file_bin = initD_path + '/' + getPluginName() - if not os.path.exists(file_bin): - content = mw.readFile(initd_tpl) - content = contentReplace(content) - mw.writeFile(file_bin, content) - mw.execShell('chmod +x ' + file_bin) - mysql_conf_dir = getServerDir() + '/etc' if not os.path.exists(mysql_conf_dir): os.mkdir(mysql_conf_dir) @@ -187,6 +180,13 @@ def initDreplace(version=''): content = contentReplace(content) mw.writeFile(mysql_conf, content) + file_bin = initD_path + '/' + getPluginName() + if not os.path.exists(file_bin): + content = mw.readFile(initd_tpl) + content = contentReplace(content) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + mysql_tmp = getServerDir() + '/tmp' if not os.path.exists(mysql_tmp): os.mkdir(mysql_tmp) From 8c1df01df72e0c8babad08ce6a926b5d5120a324 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:17:43 +0800 Subject: [PATCH 103/173] Update index.py --- plugins/mariadb/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index df943dd38..8e666818c 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -165,10 +165,6 @@ def pMysqlDb(): def initDreplace(version=''): initd_tpl = getInitdTpl(version) - initD_path = getServerDir() + '/init.d' - if not os.path.exists(initD_path): - os.mkdir(initD_path) - mysql_conf_dir = getServerDir() + '/etc' if not os.path.exists(mysql_conf_dir): os.mkdir(mysql_conf_dir) @@ -180,6 +176,10 @@ def initDreplace(version=''): content = contentReplace(content) mw.writeFile(mysql_conf, content) + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + file_bin = initD_path + '/' + getPluginName() if not os.path.exists(file_bin): content = mw.readFile(initd_tpl) From d14fd10e98b6ca10b648c50b125df1296757d77d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:36:15 +0800 Subject: [PATCH 104/173] Update task.py --- task.py | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/task.py b/task.py index 4989153d5..c5ffdf44b 100755 --- a/task.py +++ b/task.py @@ -392,7 +392,7 @@ def startPHPVersion(version): try: # system - phpService = '/lib/systemd/system/php' + version + '.service' + phpService = mw.systemdCfgDir() + '/php' + version + '.service' if os.path.exists(phpService): mw.execShell("systemctl restart php" + version) if checkPHPVersion(version): @@ -439,17 +439,42 @@ def startPHPVersion(version): return True -# 检查指定PHP版本 -def checkPHPVersion(version): +def getFpmConfFile(version): + return mw.getServerDir() + '/php/' + version + '/etc/php-fpm.d/www.conf' + + +def getFpmAddress(version): + fpm_address = '/tmp/php-cgi-{}.sock'.format(version) + php_fpm_file = getFpmConfFile(version) try: - url = 'http://127.0.0.1/phpfpm_status_' + version - result = mw.httpGet(url, 1) - if result.find('timed out'): - raise + content = readFile(php_fpm_file) + tmp = re.findall(r"listen\s*=\s*(.+)", content) + if not tmp: + return fpm_address + if tmp[0].find('sock') != -1: + return fpm_address + if tmp[0].find(':') != -1: + listen_tmp = tmp[0].split(':') + if bind: + fpm_address = (listen_tmp[0], int(listen_tmp[1])) + else: + fpm_address = ('127.0.0.1', int(listen_tmp[1])) + else: + fpm_address = ('127.0.0.1', int(tmp[0])) + return fpm_address + except: + return fpm_address + +# 检查指定PHP版本 + + +def checkPHPVersion(version): + + try: + sock = getFpmAddress(version) + data = mw.requestFcgiPHP(sock, '/phpfpm_status_' + version + '?json') + result = str(data, encoding='utf-8') except Exception as e: - url = 'http://' + mw.getLocalIp() + '/phpfpm_status_' + version - result = mw.httpGet(url, 1) - else: result = 'Bad Gateway' # print(version,result) @@ -468,7 +493,7 @@ def checkPHPVersion(version): return True # systemd - systemd = '/lib/systemd/system/openresty.service' + systemd = mw.systemdCfgDir() + '/openresty.service' if os.path.exists(systemd): execShell('systemctl reload openresty') return True From 59f9a4bfa31462e20e21fccf596514000bda8f2a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:45:37 +0800 Subject: [PATCH 105/173] up --- plugins/mariadb/init.d/{mysql.tpl => mariadb.tpl} | 0 task.py | 4 +--- 2 files changed, 1 insertion(+), 3 deletions(-) rename plugins/mariadb/init.d/{mysql.tpl => mariadb.tpl} (100%) diff --git a/plugins/mariadb/init.d/mysql.tpl b/plugins/mariadb/init.d/mariadb.tpl similarity index 100% rename from plugins/mariadb/init.d/mysql.tpl rename to plugins/mariadb/init.d/mariadb.tpl diff --git a/task.py b/task.py index c5ffdf44b..98e3cbe6b 100755 --- a/task.py +++ b/task.py @@ -465,11 +465,9 @@ def getFpmAddress(version): except: return fpm_address -# 检查指定PHP版本 - def checkPHPVersion(version): - + # 检查指定PHP版本 try: sock = getFpmAddress(version) data = mw.requestFcgiPHP(sock, '/phpfpm_status_' + version + '?json') From f28d74a525aa79d93833a21b4c52487f24feddda Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 16:56:05 +0800 Subject: [PATCH 106/173] Update index.py --- plugins/mariadb/index.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 8e666818c..ed7342bcf 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -117,15 +117,9 @@ def getInitdTpl(version=''): def contentReplace(content): service_path = mw.getServerDir() - if content.find('{$ROOT_PATH}') != -1: - content = content.replace('{$ROOT_PATH}', mw.getRootDir()) - - if content.find('{$SERVER_PATH}') != -1: - content = content.replace('{$SERVER_PATH}', service_path) - - if content.find('{$SERVER_APP_PATH}') != -1: - content = content.replace( - '{$SERVER_APP_PATH}', service_path + '/mariadb') + content = content.replace('{$ROOT_PATH}', mw.getRootDir()) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$SERVER_APP_PATH}', service_path + '/mariadb') return content From dc95f5faa409454c0617858c3f1fa5eb6ef38c0a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 17:10:23 +0800 Subject: [PATCH 107/173] Update index.py --- plugins/mariadb/index.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index ed7342bcf..621fc29b5 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -321,6 +321,10 @@ def initMysqlPwd(): cmd_pass = cmd_pass + "flush privileges;\"" data = mw.execShell(cmd_pass) + if data[1].find("ERROR"): + print("init mariadb db fail") + exit(1) + # print(data) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True @@ -552,8 +556,6 @@ def setDbStatus(): def isSqlError(data): # 检测数据库执行错误 errMsg = str(data) - if "MySQLdb" in errMsg: - return mw.returnJson(False, 'MySQLdb组件缺失!
进入SSH命令行输入: pip install mysql-python | pip install mysqlclient==2.0.3') if "2002," in errMsg: return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') if "2003," in errMsg: From cc67959516c7dc425c676b283935dfe53cf85b4d Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 17:16:50 +0800 Subject: [PATCH 108/173] Update index.py --- plugins/mariadb/index.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 621fc29b5..65e4c10d1 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -556,12 +556,14 @@ def setDbStatus(): def isSqlError(data): # 检测数据库执行错误 errMsg = str(data) - if "2002," in errMsg: + if "2002" in errMsg: return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') - if "2003," in errMsg: + if "2003" in errMsg: return mw.returnJson(False, "Can't connect to MySQL server on '127.0.0.1' (61)") - if "1698," in errMsg: + if "1698" in errMsg: return mw.returnJson(False, "Access denied for user 'root'@'localhost'") + if "1045" in errMsg: + return mw.returnJson(False, "Access denied for user 'root'@'localhost' (using password: YES)") if "using password:" in errMsg: return mw.returnJson(False, '数据库管理密码错误!') if "Connection refused" in errMsg: From 0db13969a37530c73d6cd4b05500f99257ab02ba Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 17:21:14 +0800 Subject: [PATCH 109/173] up --- class/plugin/orm.py | 6 ++++++ plugins/mariadb/index.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/class/plugin/orm.py b/class/plugin/orm.py index 3bbd663fd..b38e8683a 100755 --- a/class/plugin/orm.py +++ b/class/plugin/orm.py @@ -48,6 +48,12 @@ class ORM: def setDbConf(self, conf): self.__DB_CNF = conf + def setSocket(self, sock): + self.__DB_SOCKET = sock + + def setPort(self, port): + self.__DB_PORT = port + def setPwd(self, pwd): self.__DB_PASS = pwd diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 65e4c10d1..0cdf6c9a7 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -148,8 +148,8 @@ def pMysqlDb(): db.setDbConf(getConf()) - db.__DB_PORT = getDbPort() - db.__DB_SOCKET = getSocketFile() + db.setPort(getDbPort()) + db.setSocket(getSocketFile()) pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root') db.setPwd(pwd) From 1f801876f86d3a779f5d2a8376b949676b266efb Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 17:21:37 +0800 Subject: [PATCH 110/173] Update index.py --- plugins/mysql/index.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 8af90b93f..d157d5db3 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -135,9 +135,8 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): db = mw.getMyORM() - db.__DB_CNF = getConf() - db.__DB_PORT = getDbPort() - db.__DB_SOCKET = getSocketFile() + db.setPort(getDbPort()) + db.setSocket(getSocketFile()) db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From e1beed64c501e86ad143d95241ad85768b03c660 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 17:32:17 +0800 Subject: [PATCH 111/173] Update index.py --- plugins/mysql-yum/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index c681667fe..d1fc6dea1 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -134,8 +134,8 @@ def pSqliteDb(dbname='databases'): def pMysqlDb(): db = mw.getMyORM() db.__DB_CNF = getConf() - db.__DB_PORT = getDbPort() - db.__DB_SOCKET = getSocketFile() + db.setPort(getDbPort()) + db.setSocket(getSocketFile()) db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')) return db From 59b5f6143e87b0bbb3d5af8ca3899b11633d35d5 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 18:25:37 +0800 Subject: [PATCH 112/173] Update index.py --- plugins/php/index.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/php/index.py b/plugins/php/index.py index 160f7a625..23012a4d9 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -782,6 +782,9 @@ def installPreInspection(version): if sysName == 'debian' and sys_id > 10: return 'debian10可以安装' + + if sysName == 'fedora' and sys_id > 31: + return 'fedora[31]可以安装' return 'ok' if __name__ == "__main__": From 2a3c19cc90c2a00cfb73117ad200d0cb53572881 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 18:48:27 +0800 Subject: [PATCH 113/173] Update index.py --- plugins/php/index.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/php/index.py b/plugins/php/index.py index 23012a4d9..4a89a7204 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -783,8 +783,12 @@ def installPreInspection(version): if sysName == 'debian' and sys_id > 10: return 'debian10可以安装' - if sysName == 'fedora' and sys_id > 31: - return 'fedora[31]可以安装' + if sysName == 'fedora': + sys_id = mw.execShell( + "cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}'") + sysId = sys_id[0].strip() + if int(sysId) > 31: + return 'fedora[{}]不可安装'.format(sysId) return 'ok' if __name__ == "__main__": From 2d614eee4242d504f239db0050b9c02cb564b8dc Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 18:49:51 +0800 Subject: [PATCH 114/173] Update index.py --- plugins/php/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/index.py b/plugins/php/index.py index 4a89a7204..fdbb500ec 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -780,7 +780,7 @@ def installPreInspection(version): if sysName == 'ubuntu': return 'ubuntu已经安装不了' - if sysName == 'debian' and sys_id > 10: + if sysName == 'debian' and sysId > 10: return 'debian10可以安装' if sysName == 'fedora': From 9edd8529747586f7a49ca4ec11d0efd334abdf41 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 19:19:22 +0800 Subject: [PATCH 115/173] up --- scripts/install/fedora.sh | 1 + scripts/update/fedora.sh | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index f76968118..4ab4c71f3 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -70,6 +70,7 @@ yum -y install epel-release yum install -y libevent libevent-devel libxslt* libjpeg* libpng* gd* zip libmcrypt libmcrypt-devel yum install -y gcc libffi-devel python-devel openssl-devel +yum install -y curl-devel libmcrypt libmcrypt-devel python3-devel yum -y install wget python-devel python-imaging libicu-devel unzip bzip2-devel gcc libxml2 libxml2-devel libjpeg-devel libpng-devel libwebp libwebp-devel lsof pcre pcre-devel crontabs yum -y install net-tools diff --git a/scripts/update/fedora.sh b/scripts/update/fedora.sh index 231c2d532..353291eaa 100644 --- a/scripts/update/fedora.sh +++ b/scripts/update/fedora.sh @@ -11,8 +11,6 @@ fi sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config -yum install -y curl-devel libmcrypt libmcrypt-devel python36-devel - cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From 1131dd2d9b7b53ebb54731620f96ad4ba1229800 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 19:36:38 +0800 Subject: [PATCH 116/173] up --- plugins/php/index.py | 5 +++-- plugins/php/versions/common.sh | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/php/index.py b/plugins/php/index.py index fdbb500ec..837b5a3dc 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -726,7 +726,7 @@ def installLib(version): name = args['name'] execstr = "cd " + getPluginDir() + "/versions && /bin/bash common.sh " + \ - version + ' install ' + ' ' + name + version + ' install ' + name rettime = time.strftime('%Y-%m-%d %H:%M:%S') insert_info = (None, '安装[' + name + '-' + version + ']', @@ -745,8 +745,9 @@ def uninstallLib(version): name = args['name'] execstr = "cd " + getPluginDir() + "/versions && /bin/bash common.sh " + \ - version + ' uninstall ' + ' ' + name + version + ' uninstall ' + name + return mw.returnJson(False, execstr) data = mw.execShell(execstr) # data[0] == '' and if data[1] == '': diff --git a/plugins/php/versions/common.sh b/plugins/php/versions/common.sh index bff62a9bf..e2812378e 100644 --- a/plugins/php/versions/common.sh +++ b/plugins/php/versions/common.sh @@ -36,9 +36,9 @@ fi if [ "$action" == 'uninstall' ];then if [ -f $FILE ];then - cd ${curPath}/${version} && bash ${extName}.sh install ${version} + cd ${curPath}/${version} && bash ${extName}.sh uninstall ${version} elif [ -f $FILE_COMMON ];then - cd ${curPath}/common && bash ${extName}.sh install ${version} + cd ${curPath}/common && bash ${extName}.sh uninstall ${version} else echo 'no such extension' fi @@ -46,5 +46,5 @@ fi echo "cd ${curPath}/common && bash ${extName}.sh install ${version}" echo "cd ${curPath}/${version} && bash ${extName}.sh install ${version}" -echo "cd ${curPath}/common && bash ${extName}.sh uinstall ${version}" -echo "cd ${curPath}/${version} && bash ${extName}.sh uinstall ${version}" +echo "cd ${curPath}/common && bash ${extName}.sh uninstall ${version}" +echo "cd ${curPath}/${version} && bash ${extName}.sh uninstall ${version}" From 06797bf482d4a0d566715478d237a54f190253cd Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 19:39:40 +0800 Subject: [PATCH 117/173] Update index.py --- plugins/php/index.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/php/index.py b/plugins/php/index.py index 837b5a3dc..c20038b8d 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -747,7 +747,6 @@ def uninstallLib(version): execstr = "cd " + getPluginDir() + "/versions && /bin/bash common.sh " + \ version + ' uninstall ' + name - return mw.returnJson(False, execstr) data = mw.execShell(execstr) # data[0] == '' and if data[1] == '': From 7b3e7198438fe2a3807eb6f3264ec1fb61dfd1c1 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 19:58:59 +0800 Subject: [PATCH 118/173] Update compatibility.md --- compatibility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compatibility.md b/compatibility.md index f624c3df6..5195b5126 100644 --- a/compatibility.md +++ b/compatibility.md @@ -42,7 +42,7 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh | Ubuntu 20.04 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | Ubuntu 22.04 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | Fedora 31 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | -| Fedora 32 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | +| Fedora 32 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | AlmaLinix 9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | RockyLinux 8.6 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | openSUSE 15.4 |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: | From d99d1d03d15e5aa840fab8fbdd1c0dfe49e0e5cb Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 21:10:04 +0800 Subject: [PATCH 119/173] up --- plugins/op_waf/index.py | 24 ++++++++++-------------- plugins/op_waf/install.sh | 3 --- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index 4141dfeb3..c435ad7a0 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -186,7 +186,7 @@ def status(): def contentReplace(content): service_path = mw.getServerDir() - waf_path = mw.getServerDir() + "/openresty/nginx/conf/waf" + waf_path = getServerDir() + "/waf" content = content.replace('{$ROOT_PATH}', mw.getRootDir()) content = content.replace('{$SERVER_PATH}', service_path) content = content.replace('{$WAF_PATH}', waf_path) @@ -195,20 +195,21 @@ def contentReplace(content): def initDreplace(): - path = mw.getServerDir() + "/openresty/nginx/conf" + path = getServerDir() if not os.path.exists(path + '/waf'): sdir = getPluginDir() + '/waf' cmd = 'cp -rf ' + sdir + ' ' + path mw.execShell(cmd) - config = mw.getServerDir() + '/openresty/nginx/conf/waf/config.json' + config = path + '/waf/config.json' content = mw.readFile(config) content = json.loads(content) - content['reqfile_path'] = mw.getServerDir( - ) + "/openresty/nginx/conf/waf/html" + + wfDir = path + "/waf/html" + content['reqfile_path'] = wfDir mw.writeFile(config, mw.getJson(content)) - config = mw.getServerDir() + "/openresty/nginx/conf/waf/lua/init.lua" + config = path + "/waf/lua/init.lua" content = mw.readFile(config) content = contentReplace(content) mw.writeFile(config, content) @@ -230,18 +231,13 @@ def start(): path = getConf() conf = mw.readFile(path) conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;") - mw.writeFile(path, conf) + mw.restartWeb() return 'ok' def stop(): - path = mw.getServerDir() + "/openresty/nginx/conf/waf" - if os.path.exists(path): - cmd = 'rm -rf ' + path - mw.execShell(cmd) - path = getConf() conf = mw.readFile(path) conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;") @@ -265,12 +261,12 @@ def reload(): def getJsonPath(name): - path = mw.getServerDir() + "/openresty/nginx/conf/waf/" + name + ".json" + path = getServerDir() + "/waf/" + name + ".json" return path def getRuleJsonPath(name): - path = mw.getServerDir() + "/openresty/nginx/conf/waf/rule/" + name + ".json" + path = getServerDir() + "/waf/rule/" + name + ".json" return path diff --git a/plugins/op_waf/install.sh b/plugins/op_waf/install.sh index d29ae27b7..e4a6e9a97 100755 --- a/plugins/op_waf/install.sh +++ b/plugins/op_waf/install.sh @@ -16,9 +16,6 @@ Install_of(){ echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/op_waf - if [ -f $serverPath/openresty ];then - mkdir -p $serverPath/openresty/nginx/conf/waf - fi echo '0.1' > $serverPath/op_waf/version.pl echo 'install ok' > $install_tmp } From 67a32af5b199a2fcc5035fc37891c5a7845f9222 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 13 Jul 2022 22:27:16 +0800 Subject: [PATCH 120/173] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0b3bf380e..777de65c3 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ data/datadir.pl data/502Task.pl data/default.pl data/backup.pl +data/default_site.pl lib/python* bin @@ -144,3 +145,4 @@ plugins/gdrive plugins/mtproxy debug.out + From b17d6949155dd9e0f504f0bc9cd6dd730f3de27f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 09:41:03 +0800 Subject: [PATCH 121/173] Update index.py --- plugins/gogs/index.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index 5c69ddf4c..82f4e18d9 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -616,11 +616,9 @@ def projectScriptLoad(): def projectScriptUnload(): args = getArgs() - if not 'user' in args: - return mw.returnJson(True, 'username missing') - - if not 'name' in args: - return mw.returnJson(True, 'project name missing') + data = checkArgs(args, ['user', 'name']) + if not data[0]: + return data[1] user = args['user'] name = args['name'] + '.git' @@ -637,11 +635,10 @@ def projectScriptUnload(): def projectScriptDebug(): args = getArgs() - if not 'user' in args: - return mw.returnJson(True, 'username missing') + data = checkArgs(args, ['user', 'name']) + if not data[0]: + return data[1] - if not 'name' in args: - return mw.returnJson(True, 'project name missing') user = args['user'] name = args['name'] + '.git' commit_log = getRootPath() + '/' + user + '/' + name + \ From 74d491c5f77284cb85b2f13f5ca75ac8212f6d37 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 10:29:40 +0800 Subject: [PATCH 122/173] Update alma.sh --- scripts/install/alma.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/install/alma.sh b/scripts/install/alma.sh index 1e70f2e15..d37d7ab43 100755 --- a/scripts/install/alma.sh +++ b/scripts/install/alma.sh @@ -104,6 +104,3 @@ cd /www/server/mdserver-web && /etc/init.d/mw start cd /www/server/mdserver-web && /etc/init.d/mw default - - - From 4161acd6306d0fc311c2121f345e4e2eb9cb845e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 11:12:49 +0800 Subject: [PATCH 123/173] Update install.sh --- plugins/varnish/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index a0fdb5d37..978216330 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -23,7 +23,7 @@ Install_varnish() if [ "${OSNAME}" == "macos" ]; then brew install varnish - elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ]; then yum install varnish -y elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then apt install varnish -y @@ -49,9 +49,9 @@ Uninstall_varnish() if [ "${OSNAME}" == "macos" ]; then brew uninstall varnish - elif [ "${OSNAME}" == "centos" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ]; then yum remove varnish -y - elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ]; then + elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then apt remove varnish -y elif [ "${OSNAME}" == "opensuse" ];then zypper remove -y varnish From d7ae3623e70345a4c71e1fc7b37d6006f2b81c9c Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 11:30:30 +0800 Subject: [PATCH 124/173] Update getos.sh --- scripts/getos.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/getos.sh b/scripts/getos.sh index e98e89fba..13f8af9d5 100755 --- a/scripts/getos.sh +++ b/scripts/getos.sh @@ -14,6 +14,8 @@ elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then OSNAME='arch' elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then OSNAME='centos' +elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then + OSNAME='alma' elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then OSNAME='rocky' elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then From 60b83ca8412d6efddf52d481f7f7bdf61a09e803 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 13:17:21 +0800 Subject: [PATCH 125/173] Update install.sh --- plugins/sphinx/install.sh | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/plugins/sphinx/install.sh b/plugins/sphinx/install.sh index 49ca46742..94e97d638 100755 --- a/plugins/sphinx/install.sh +++ b/plugins/sphinx/install.sh @@ -11,32 +11,16 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -sysName=`uname` -echo "use system: ${sysName}" +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` -if [ ${sysName} == "Darwin" ]; then - OSNAME='macos' -elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then - OSNAME='centos' -elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then - OSNAME='fedora' -elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then - OSNAME='debian' -elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then - OSNAME='ubuntu' -elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then - OSNAME='raspbian' -else - OSNAME='unknow' -fi - -if [ ${OSNAME} == "centos" ] || [ ${OSNAME} == "fedora" ]; then +if [ ${OSNAME} == "centos" ] || + [ ${OSNAME} == "fedora" ] || + [ ${OSNAME} == "alma" ]; then yum install -y postgresql-libs unixODBC fi - - - Install_sphinx() { @@ -49,7 +33,7 @@ Install_sphinx() if [ $sysName == 'Darwin' ]; then wget -O ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-darwin-amd64.tar.gz else - wget -O ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz + curl -sSLo ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-linux-amd64.tar.gz fi fi From a103512ca4f2b5d96d513ca680eab0af0619fd4a Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 13:54:12 +0800 Subject: [PATCH 126/173] Update all_test.sh --- plugins/php/versions/all_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/all_test.sh b/plugins/php/versions/all_test.sh index 98a29ebd0..e8d11ed20 100644 --- a/plugins/php/versions/all_test.sh +++ b/plugins/php/versions/all_test.sh @@ -44,7 +44,7 @@ for PHP_VER in ${PHP_VER_LIST[@]}; do echo "php${PHP_VER} -- start" if [ ! -d /www/server/php/${PHP_VER} ];then - echo "php{$PHP_VER} is not install!" + echo "php${PHP_VER} is not install!" break; fi From 1eabd8ccb45aa736aa5e5f36d9fac54c021e300c Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 14:04:21 +0800 Subject: [PATCH 127/173] Update compatibility.md --- compatibility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compatibility.md b/compatibility.md index 5195b5126..744099db0 100644 --- a/compatibility.md +++ b/compatibility.md @@ -62,7 +62,7 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh | Ubuntu 22.04 |✅ |✅ |✅ |✅ | | Fedora 31 |✅ |✅ |✅ |✅ | | Fedora 32 |✅ |✅ |✅ |✅ | -| AlmaLinix 9 |✅ |✅ |✅ |✅ | +| AlmaLinix 9 |✅ |:x: |:x: |:x: | | RockyLinux 8.6 |✅ |✅ |✅ |✅ | | openSUSE 15.4 |:x: |:x: |:x: |:x: | From 305c9e90d48d76800642e82d9f9cf65636b3e643 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 15:07:28 +0800 Subject: [PATCH 128/173] Update install.sh --- plugins/sphinx/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/sphinx/install.sh b/plugins/sphinx/install.sh index 94e97d638..8506f07c8 100755 --- a/plugins/sphinx/install.sh +++ b/plugins/sphinx/install.sh @@ -50,10 +50,11 @@ Install_sphinx() Uninstall_sphinx() { - if [ -f /usr/lib/systemd/system/sphinx.service ];then + if [ -f /usr/lib/systemd/system/sphinx.service ] || [ -f /lib/systemd/system/sphinx.service ];then systemctl stop sphinx systemctl disable sphinx rm -rf /usr/lib/systemd/system/sphinx.service + rm -rf /lib/systemd/system/sphinx.service systemctl daemon-reload fi From 402d3283d6f121d46a78542b8dd14bc6779fc5cf Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 15:17:40 +0800 Subject: [PATCH 129/173] Update compatibility.md --- compatibility.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compatibility.md b/compatibility.md index 744099db0..7f18c493e 100644 --- a/compatibility.md +++ b/compatibility.md @@ -43,7 +43,7 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh | Ubuntu 22.04 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | Fedora 31 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | Fedora 32 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | -| AlmaLinix 9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | +| AlmaLinix 9 |:x: |✅ |✅ |:x: |:x: |:x: |:x: |:x: |✅ |:x: |:x: |:x: | | RockyLinux 8.6 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ | | openSUSE 15.4 |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: | From 4cde1c44c2f9049eb520927abaa2a65e494e98a6 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 15:36:08 +0800 Subject: [PATCH 130/173] Update rocky.sh --- scripts/install/rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index c4cbcf1b5..6b427a8b0 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -17,7 +17,7 @@ yum install -y wget lsof crontabs yum install -y python3-devel yum install -y python-devel yum install -y vixie-cron - +yum install -y curl curl-devel libcurl libcurl-devel #https need if [ ! -d /root/.acme.sh ];then From 1005e5167ef4cf34b6422096b309519f109db09d Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 15:40:35 +0800 Subject: [PATCH 131/173] Update rocky.sh --- scripts/install/rocky.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 6b427a8b0..714041bbf 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -13,10 +13,10 @@ fi setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config -yum install -y wget lsof crontabs +yum install -y wget lsof yum install -y python3-devel yum install -y python-devel -yum install -y vixie-cron +yum install -y crontabs yum install -y curl curl-devel libcurl libcurl-devel #https need @@ -76,7 +76,7 @@ yum install -y lsof net-tools yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python -for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof vixie-cron crontabs expat-devel readline-devel; +for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do yum -y install $yumPack;done cd /www/server/mdserver-web/scripts && bash lib.sh From 01afd3d67301ebd41c54c0ccaf8f9433c6d29b72 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:03:29 +0800 Subject: [PATCH 132/173] Update install.sh --- plugins/sphinx/install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/sphinx/install.sh b/plugins/sphinx/install.sh index 8506f07c8..dee40993d 100755 --- a/plugins/sphinx/install.sh +++ b/plugins/sphinx/install.sh @@ -28,7 +28,6 @@ Install_sphinx() mkdir -p $serverPath/sphinx SPHINX_DIR=${serverPath}/source/sphinx - mkdir -p $SPHINX_DIR if [ ! -f ${SPHINX_DIR}/sphinx-3.1.1.tar.gz ];then if [ $sysName == 'Darwin' ]; then wget -O ${SPHINX_DIR}/sphinx-3.1.1.tar.gz http://sphinxsearch.com/files/sphinx-3.1.1-612d99f-darwin-amd64.tar.gz @@ -38,8 +37,12 @@ Install_sphinx() fi cd ${SPHINX_DIR} && tar -zxvf sphinx-3.1.1.tar.gz - cp -rf ${SPHINX_DIR}/sphinx-3.1.1/ $serverPath/sphinx/bin - + + if [ "$?" == "0" ];then + mkdir -p $SPHINX_DIR + cp -rf ${SPHINX_DIR}/sphinx-3.1.1/ $serverPath/sphinx/bin + fi + if [ -d $serverPath/sphinx ];then echo '3.1.1' > $serverPath/sphinx/version.pl echo '安装完成' > $install_tmp From 4398693b66eb404e53b2dae5e3d4d6cc882d7e55 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:12:10 +0800 Subject: [PATCH 133/173] Update install.sh --- plugins/rsyncd/install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/rsyncd/install.sh b/plugins/rsyncd/install.sh index b901b4342..6b420bfb4 100755 --- a/plugins/rsyncd/install.sh +++ b/plugins/rsyncd/install.sh @@ -23,8 +23,10 @@ Install_rsyncd() echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/rsyncd - if [ $OSNAME == 'debian' ];then + if [ "$OSNAME" == "debian'" ] || [ "$OSNAME" == "ubuntu'" ];then apt install -y rsync + else + yum install -y rsync fi @@ -36,10 +38,11 @@ Install_rsyncd() Uninstall_rsyncd() { - if [ -f /usr/lib/systemd/system/rsyncd.service ];then + if [ -f /usr/lib/systemd/system/rsyncd.service ] || [ -f /lib/systemd/system/rsyncd.service ];then systemctl stop rsyncd systemctl disable rsyncd rm -rf /usr/lib/systemd/system/rsyncd.service + rm -rf /lib/systemd/system/rsyncd.service systemctl daemon-reload fi From 6f5900c0d0034984668697c69defbfb2642ca87e Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:12:23 +0800 Subject: [PATCH 134/173] Update alma.sh --- scripts/install/alma.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install/alma.sh b/scripts/install/alma.sh index d37d7ab43..85f078dc9 100755 --- a/scripts/install/alma.sh +++ b/scripts/install/alma.sh @@ -81,6 +81,10 @@ for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-li do yum -y install $yumPack;done +# findLD=`cat /etc/ld.so.conf | grep '/usr/local/lib64'` +# echo "/usr/local/lib64" >> /etc/ld.so.conf + + cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data @@ -99,6 +103,7 @@ do fi done + cd /www/server/mdserver-web && /etc/init.d/mw stop cd /www/server/mdserver-web && /etc/init.d/mw start cd /www/server/mdserver-web && /etc/init.d/mw default From 8bb46df983be6b755094fa841b53cea1d2bcbfbb Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:21:14 +0800 Subject: [PATCH 135/173] Update index.py --- plugins/gogs/index.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index 82f4e18d9..76b8edb3a 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -216,8 +216,11 @@ def getRootPath(): def getDbConfValue(): - content = mw.readFile(getConf()) + conf = getConf() + if not os.path.exists(conf): + return {} + content = mw.readFile(conf) rep_scope = "\[database\](.*?)\[" tmp = re.findall(rep_scope, content, re.S) From 6d122ffb5af7d9a77ad2f25b602028c58bd6fdc0 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:23:05 +0800 Subject: [PATCH 136/173] Update install.sh --- plugins/varnish/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index 978216330..6a4852cba 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -23,7 +23,7 @@ Install_varnish() if [ "${OSNAME}" == "macos" ]; then brew install varnish - elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then yum install varnish -y elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then apt install varnish -y From a21990ffea6abc247147df8d12f840422c7f9172 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 16:23:31 +0800 Subject: [PATCH 137/173] Update install.sh --- plugins/varnish/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/varnish/install.sh b/plugins/varnish/install.sh index 6a4852cba..fa1e5c7b7 100755 --- a/plugins/varnish/install.sh +++ b/plugins/varnish/install.sh @@ -49,7 +49,7 @@ Uninstall_varnish() if [ "${OSNAME}" == "macos" ]; then brew uninstall varnish - elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ]; then + elif [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ] || [ "${OSNAME}" == "alma" ] || [ "${OSNAME}" == "rocky" ]; then yum remove varnish -y elif [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then apt remove varnish -y From f43d1ea4066b5cd3000e698cc93dfa52a2fc458d Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 19:49:13 +0800 Subject: [PATCH 138/173] Update rocky.sh --- scripts/install/rocky.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 714041bbf..df20d83cf 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -79,6 +79,8 @@ yum install -y MySQL-python for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do yum -y install $yumPack;done +yum install -y libtirpc libtirpc-devel + cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From fa459b0c839ee0742fabad711354123a7d8c678c Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 19:53:54 +0800 Subject: [PATCH 139/173] Update install.sh --- plugins/sphinx/install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/sphinx/install.sh b/plugins/sphinx/install.sh index dee40993d..7373c4dd2 100755 --- a/plugins/sphinx/install.sh +++ b/plugins/sphinx/install.sh @@ -36,6 +36,11 @@ Install_sphinx() fi fi + if [ ! -f ${SPHINX_DIR}/sphinx-3.1.1.tar.gz ];then + curl -sSLo ${SPHINX_DIR}/sphinx-3.1.1.tar.gz https://github.com/midoks/mdserver-web/releases/download/init/sphinx-3.1.1.tar.gz + fi + + cd ${SPHINX_DIR} && tar -zxvf sphinx-3.1.1.tar.gz if [ "$?" == "0" ];then From 277737efd7b5608668120fada2639933c4e1589d Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 20:14:08 +0800 Subject: [PATCH 140/173] up --- plugins/mysql/lib/rpcgen.sh | 29 +++++++++++++++++++++++++++ plugins/mysql/versions/5.7/install.sh | 3 ++- plugins/mysql/versions/8.0/install.sh | 4 +++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 plugins/mysql/lib/rpcgen.sh diff --git a/plugins/mysql/lib/rpcgen.sh b/plugins/mysql/lib/rpcgen.sh new file mode 100644 index 000000000..b00af73c2 --- /dev/null +++ b/plugins/mysql/lib/rpcgen.sh @@ -0,0 +1,29 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") + +# echo $rootPath + +SERVER_ROOT=$rootPath/lib +SOURCE_ROOT=$rootPath/source/lib + +which rpcgen +if [ "$?" != "0" ];then + + if [ ! -f ${SOURCE_ROOT}/rpcsvc-proto-1.4.tar.gz ];then + wget -O ${SOURCE_ROOT}/rpcsvc-proto-1.4.tar.gz https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz + fi + + if [ ! -d ${SERVER_ROOT}/rpcsvc-proto-1.4 ];then + cd ${SOURCE_ROOT} && tar -zxvf rpcsvc-proto-1.4.tar.gz + cd ${SOURCE_ROOT}/rpcsvc-proto-1.4 + ./configure && make && make install + fi + +fi \ No newline at end of file diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 577aa572a..85629889e 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -38,6 +38,7 @@ Install_mysql() touch /var/log/mariadb/mariadb.log fi + cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz @@ -95,7 +96,7 @@ Install_mysql() echo '5.7' > $serverPath/mysql/version.pl echo '安装完成' > $install_tmp else - rm -rf ${mysqlDir}/mysql-${VERSION} + # rm -rf ${mysqlDir}/mysql-${VERSION} echo '安装失败' > $install_tmp echo 'install fail'>&2 exit 1 diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index 038469b89..acd58a003 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -75,6 +75,8 @@ Install_mysql() useradd -g mysql mysql fi + cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh + INSTALL_CMD=cmake # check cmake version CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'` @@ -154,7 +156,7 @@ Install_mysql() echo '8.0' > $serverPath/mysql/version.pl echo '安装完成' > $install_tmp else - rm -rf ${mysqlDir}/mysql-${VERSION} + # rm -rf ${mysqlDir}/mysql-${VERSION} echo '安装失败' > $install_tmp echo 'install fail'>&2 exit 1 From 2bd150803d305b753934ff7eda48b470cbdb0554 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 20:45:11 +0800 Subject: [PATCH 141/173] up --- plugins/php/lib/oniguruma.sh | 26 ++++++++++++++++++++++++++ plugins/php/versions/74/install.sh | 1 + plugins/php/versions/80/install.sh | 1 + plugins/php/versions/81/install.sh | 1 + 4 files changed, 29 insertions(+) create mode 100644 plugins/php/lib/oniguruma.sh diff --git a/plugins/php/lib/oniguruma.sh b/plugins/php/lib/oniguruma.sh new file mode 100644 index 000000000..be4926be9 --- /dev/null +++ b/plugins/php/lib/oniguruma.sh @@ -0,0 +1,26 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") +rootPath=$(dirname "$rootPath") + +# echo $rootPath + +SERVER_ROOT=$rootPath/lib +SOURCE_ROOT=$rootPath/source/lib + +which onig-config +if [ "$?" != "0" ];then + cd ${SOURCE_ROOT} + if [ ! -f ${SOURCE_ROOT}/oniguruma-6.9.4.tar.gz ];then + wget -O ${SOURCE_ROOT}/oniguruma-6.9.4.tar.gz https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz + fi + cd ${SOURCE_ROOT} && tar -zxvf oniguruma-6.9.4.tar.gz + cd oniguruma-6.9.4/ + ./autogen.sh && ./configure --prefix=/usr && make && make install +fi + diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index a111ad05a..59ae5303a 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -24,6 +24,7 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index 5e7b859ed..1d2fbf523 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -24,6 +24,7 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index 177ae1d1f..5c01896da 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -24,6 +24,7 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then From def8aafe26e7d0b2a44bc9501386908fe0f3e26f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 20:46:33 +0800 Subject: [PATCH 142/173] Update oniguruma.sh --- plugins/php/lib/oniguruma.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/php/lib/oniguruma.sh b/plugins/php/lib/oniguruma.sh index be4926be9..9168410e9 100644 --- a/plugins/php/lib/oniguruma.sh +++ b/plugins/php/lib/oniguruma.sh @@ -20,7 +20,6 @@ if [ "$?" != "0" ];then wget -O ${SOURCE_ROOT}/oniguruma-6.9.4.tar.gz https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz fi cd ${SOURCE_ROOT} && tar -zxvf oniguruma-6.9.4.tar.gz - cd oniguruma-6.9.4/ - ./autogen.sh && ./configure --prefix=/usr && make && make install + cd ${SOURCE_ROOT}/oniguruma-6.9.4 && ./autogen.sh && ./configure --prefix=/usr && make && make install fi From 15aa581df36490a4a80fc232013a38351baf091a Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 20:59:16 +0800 Subject: [PATCH 143/173] Update yac.sh --- plugins/php/versions/common/yac.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/yac.sh b/plugins/php/versions/common/yac.sh index e0038d2bc..947c2d590 100755 --- a/plugins/php/versions/common/yac.sh +++ b/plugins/php/versions/common/yac.sh @@ -47,7 +47,7 @@ Install_lib() php_lib=$sourcePath/php_lib mkdir -p $php_lib - if [ ! -f $php_lib/${LIBNAME}-${LIBV} ];then + if [ ! -f $php_lib/${LIBNAME}-${LIBV}.tgz ];then wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz cd $php_lib tar xvf ${LIBNAME}-${LIBV}.tgz From 99873676cc192c7e77cabfc04034d223b2aa3800 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 21:19:54 +0800 Subject: [PATCH 144/173] up --- plugins/php/versions/74/install.sh | 2 +- plugins/php/versions/80/install.sh | 2 +- plugins/php/versions/81/install.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 59ae5303a..2c101f9ed 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -11,7 +11,7 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -version=7.4.26 +version=7.4.30 PHP_VER=74 Install_php() { diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index 1d2fbf523..fc42f1b23 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -11,7 +11,7 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -version=8.0.20 +version=8.0.21 PHP_VER=80 Install_php() { diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index 5c01896da..b38b624a3 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -11,7 +11,7 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -version=8.1.7 +version=8.1.8 PHP_VER=81 Install_php() { From 228226638541577ae8dbd08c4b36f010731c7f49 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 21:21:59 +0800 Subject: [PATCH 145/173] Create install.sh --- plugins/php/versions/82/install.sh | 98 ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 plugins/php/versions/82/install.sh diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh new file mode 100755 index 000000000..d9fdb01d9 --- /dev/null +++ b/plugins/php/versions/82/install.sh @@ -0,0 +1,98 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sourcePath=${serverPath}/source +sysName=`uname` +install_tmp=${rootPath}/tmp/mw_install.pl + + +version=8.2.0 +PHP_VER=82 +Install_php() +{ +#------------------------ install start ------------------------------------# +echo "安装php-${version} ..." > $install_tmp +mkdir -p $sourcePath/php +mkdir -p $serverPath/php + +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh +cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh + + +if [ ! -d $sourcePath/php/php${PHP_VER} ];then + + if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then + wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-8.2.0alpha2.tar.xz + fi + + cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz + mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER} +fi + +cd $sourcePath/php/php${PHP_VER} + +OPTIONS='' +if [ $sysName == 'Darwin' ]; then + OPTIONS='--without-iconv' + OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl" + # OPTIONS="${OPTIONS} --enable-zip" +else + OPTIONS="--with-iconv=${serverPath}/lib/libiconv" + OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype" + OPTIONS="${OPTIONS} --with-curl" + OPTIONS="${OPTIONS} --with-libzip=${serverPath}/lib/libzip" +fi + + +echo "$sourcePath/php/php${PHP_VER}" + +if [ ! -d $serverPath/php/${PHP_VER} ];then + cd $sourcePath/php/php${PHP_VER} + ./buildconf --force + ./configure \ + --prefix=$serverPath/php/${PHP_VER} \ + --exec-prefix=$serverPath/php/${PHP_VER} \ + --with-config-file-path=$serverPath/php/${PHP_VER}/etc \ + --enable-mysqlnd \ + --with-mysqli=mysqlnd \ + --with-pdo-mysql=mysqlnd \ + --enable-mbstring \ + --with-zlib-dir=$serverPath/lib/zlib \ + --enable-ftp \ + --enable-sockets \ + --enable-simplexml \ + --enable-soap \ + --enable-posix \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --disable-intl \ + --disable-fileinfo \ + $OPTIONS \ + --enable-fpm + make clean && make && make install && make clean +fi +#------------------------ install end ------------------------------------# +} + +Uninstall_php() +{ + $serverPath/php/init.d/php${PHP_VER} stop + rm -rf $serverPath/php/${PHP_VER} + echo "卸载php-${version}..." > $install_tmp +} + +action=${1} +if [ "${1}" == 'install' ];then + Install_php +else + Uninstall_php +fi From 4b9f7ba02320f4859a9cdd08cf9fee577cd269e2 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 21:22:54 +0800 Subject: [PATCH 146/173] Update info.json --- plugins/php/info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/info.json b/plugins/php/info.json index dc1b12cb5..6b165ba48 100755 --- a/plugins/php/info.json +++ b/plugins/php/info.json @@ -5,8 +5,8 @@ "name": "php", "title": "PHP", "coexist": true, - "versions": ["52","53","54","55","56","70","71","72","73","74","80","81"], - "updates": ["5.2.17","5.3.29","5.4.45","5.6.36","7.0.30","7.1.33","7.2.32","7.3.20","7.4.8","8.0.13","8.1.0"], + "versions": ["52","53","54","55","56","70","71","72","73","74","80","81","82"], + "updates": ["5.2.17","5.3.29","5.4.45","5.6.36","7.0.30","7.1.33","7.2.32","7.3.20","7.4.30","8.0.30","8.1.8","8.2.0"], "tip": "soft", "install_pre_inspection":true, "checks": "server/php/VERSION/bin/php", From fee59e5e7848e56b8c9eeb8a37c974263440a1ae Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 21:47:43 +0800 Subject: [PATCH 147/173] Update install.sh --- plugins/php/versions/82/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index d9fdb01d9..c9c6be68d 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -11,7 +11,7 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl -version=8.2.0 +version=8.2.0alpha2 PHP_VER=82 Install_php() { From dbfee1e9898dd52e090ea3008919fd9fd9dd6664 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 21:58:41 +0800 Subject: [PATCH 148/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 9a6e90333..bfded1b86 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -43,9 +43,7 @@ Install_lib() php_lib=$sourcePath/php_lib mkdir -p $php_lib - rm -rf $php_lib/${LIBNAME}-${LIBV} - - if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then + if [ ! -d $php_lib/${LIBNAME}-${LIBV}.tgz ];then wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz fi From 4cd9d9ce65e07af131010f0b6e0e01806f7ef7fe Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:08:39 +0800 Subject: [PATCH 149/173] Update phplib.conf --- plugins/php/versions/phplib.conf | 65 +++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/plugins/php/versions/phplib.conf b/plugins/php/versions/phplib.conf index eac4b8284..ef232bfd4 100755 --- a/plugins/php/versions/phplib.conf +++ b/plugins/php/versions/phplib.conf @@ -53,7 +53,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "缓存器", "msg": "用于加速PHP脚本!", @@ -73,7 +74,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "SSL!", @@ -88,7 +90,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "加密软件!", @@ -108,7 +111,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "缓存器", "msg": "用于信号控制!", @@ -127,7 +131,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "用于FILE!", @@ -146,7 +151,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "用于图像文件格式!", @@ -167,7 +173,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "通用GD库!", @@ -188,7 +195,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "提供国际化支持", @@ -222,7 +230,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "缓存器", "msg": "强大的内容缓存器,支持集群", @@ -243,7 +252,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "缓存器", "msg": "更强大的内容缓存器,支持集群", @@ -273,7 +283,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "比GD更强大的图形库", @@ -292,7 +303,9 @@ "72", "73", "74", - "80" + "80", + "81", + "82" ], "type": "调试器", "msg": "不多说,不了解的不要安装", @@ -313,7 +326,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "性能分析", "msg": "不多说,不了解的不要安装!", @@ -332,7 +346,9 @@ "72", "73", "74", - "80" + "80", + "81", + "82" ], "type": "通用扩展", "msg": "异步、并行、高性能网络通信引擎", @@ -363,7 +379,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "框架", "msg": "Yaf是一个C语言编写的PHP框架", @@ -383,7 +400,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "框架", "msg": "Yar是一个RPC框架", @@ -414,7 +432,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "通用扩展", "msg": "Mongodb数据库连接驱动", @@ -430,7 +449,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "缓存器", "msg": "高性能无锁共享内存Cache", @@ -450,7 +470,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "大数据", "msg": "SOLR全文搜索服务", @@ -470,7 +491,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "日志", "msg": "SeasLog高性能日志记录", @@ -486,7 +508,8 @@ "73", "74", "80", - "81" + "81", + "82" ], "type": "压缩", "msg": "压缩组件", From b3cda9cece069340cfa3549d1e5cb71051d1d6f7 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:09:29 +0800 Subject: [PATCH 150/173] Update all_test.sh --- plugins/php/versions/all_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/versions/all_test.sh b/plugins/php/versions/all_test.sh index e8d11ed20..352c7a402 100644 --- a/plugins/php/versions/all_test.sh +++ b/plugins/php/versions/all_test.sh @@ -24,7 +24,7 @@ ROOT_DIR=$(cd "$(dirname "$0")"; pwd) # echo "php${PHP_VER} -- end" -PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81) +PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82) # PHP_VER_LIST=(81) for PHP_VER in ${PHP_VER_LIST[@]}; do echo "php${PHP_VER} -- start" @@ -35,7 +35,7 @@ for PHP_VER in ${PHP_VER_LIST[@]}; do done cd $DIR -PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81) +PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82) PHP_EXT_LIST=(ioncube ZendGuardLoader pdo mysqlnd sqlite3 openssl pcntl opcache mcrypt fileinfo \ exif gd intl memcache memcached redis imagemagick xdebug xhprof \ swoole yaf yar yac apc mongo mongodb solr seaslog mbstring zip) From d9ca421aa5d604eabf793798d9a6a5a8a5c612a9 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:19:31 +0800 Subject: [PATCH 151/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index bfded1b86..3458ba512 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -43,7 +43,7 @@ Install_lib() php_lib=$sourcePath/php_lib mkdir -p $php_lib - if [ ! -d $php_lib/${LIBNAME}-${LIBV}.tgz ];then + if [ ! -f $php_lib/${LIBNAME}-${LIBV}.tgz ];then wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz fi From 025d65aede47b38c703778cba88ae950e94348f7 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:26:10 +0800 Subject: [PATCH 152/173] Update mcrypt.sh --- plugins/php/versions/common/mcrypt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/versions/common/mcrypt.sh b/plugins/php/versions/common/mcrypt.sh index 30707fefc..be7bc4a23 100755 --- a/plugins/php/versions/common/mcrypt.sh +++ b/plugins/php/versions/common/mcrypt.sh @@ -45,7 +45,7 @@ Install_lib() php_lib=$sourcePath/php_lib mkdir -p $php_lib - if [ ! -f $php_lib/${LIBNAME}-${LIBV} ];then + if [ ! -f $php_lib/${LIBNAME}-${LIBV}.tgz ];then wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz cd $php_lib tar xvf ${LIBNAME}-${LIBV}.tgz @@ -54,7 +54,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi From 7cd9f11b161aa11b7e60a53c0db99c6bdc51e8f1 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:27:01 +0800 Subject: [PATCH 153/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 3458ba512..8213d2442 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -37,6 +37,8 @@ Install_lib() echo "php-$version 已安装${LIBNAME},请选择其它版本!" return fi + + cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libmemcached.sh if [ ! -f "$extFile" ];then From 4bf6d21867b7450500568f60d985db3872592b6f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:30:45 +0800 Subject: [PATCH 154/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 8213d2442..818e88b4b 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -51,7 +51,7 @@ Install_lib() fi cd $php_lib/${LIBNAME}-${LIBV} - sed -i '_bak' "3237,3238s#ulong#zend_ulong#g" $php_lib/${LIBNAME}-${LIBV}/php_memcached.c + # sed -i '_bak' "3237,3238s#ulong#zend_ulong#g" $php_lib/${LIBNAME}-${LIBV}/php_memcached.c $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ From 56b94c437c92ac1f5f839bebdb7029aa240578b3 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:42:07 +0800 Subject: [PATCH 155/173] Update libmemcached.sh --- plugins/php/lib/libmemcached.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/php/lib/libmemcached.sh b/plugins/php/lib/libmemcached.sh index 76297d853..2dca0bf21 100644 --- a/plugins/php/lib/libmemcached.sh +++ b/plugins/php/lib/libmemcached.sh @@ -15,14 +15,27 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib +#----------------------------- libmemcached start -------------------------# +# if [ ! -d ${SERVER_ROOT}/libmemcached ];then +# cd ${SOURCE_ROOT} +# if [ ! -f ${SOURCE_ROOT}/libmemcached-1.0.4.tar.gz ];then +# wget -O libmemcached-1.0.4.tar.gz https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz -T 20 +# fi +# tar -zxf libmemcached-1.0.4.tar.gz +# cd libmemcached-1.0.4 +# ./configure --prefix=${SERVER_ROOT}/libmemcached -with-memcached && make && make install +# fi +#----------------------------- libmemcached end -------------------------# + + #----------------------------- libmemcached start -------------------------# if [ ! -d ${SERVER_ROOT}/libmemcached ];then cd ${SOURCE_ROOT} - if [ ! -f ${SOURCE_ROOT}/libmemcached-1.0.4.tar.gz ];then - wget -O libmemcached-1.0.4.tar.gz https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz -T 20 + if [ ! -f ${SOURCE_ROOT}/libmemcached-1.0.18.tar.gz ];then + wget -O libmemcached-1.0.18.tar.gz https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz -T 20 fi - tar -zxf libmemcached-1.0.4.tar.gz - cd libmemcached-1.0.4 + tar -zxf libmemcached-1.0.18.tar.gz + cd libmemcached-1.0.18 ./configure --prefix=${SERVER_ROOT}/libmemcached -with-memcached && make && make install fi #----------------------------- libmemcached end -------------------------# \ No newline at end of file From 3f845a5f5dce5c6873ad3701d4b9c1fdda1a80aa Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:49:34 +0800 Subject: [PATCH 156/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 818e88b4b..2e48b2342 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -38,7 +38,7 @@ Install_lib() return fi - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libmemcached.sh + # cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libmemcached.sh if [ ! -f "$extFile" ];then From 8d62b42fb23f2b46a07989a6a40b209c47611390 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:53:46 +0800 Subject: [PATCH 157/173] Update xdebug.sh --- plugins/php/versions/common/xdebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/xdebug.sh b/plugins/php/versions/common/xdebug.sh index 47a30921a..1d76fe3b5 100755 --- a/plugins/php/versions/common/xdebug.sh +++ b/plugins/php/versions/common/xdebug.sh @@ -56,7 +56,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi From 6bd2df4e58882d843e73d98e213c29e6451af9a4 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 22:57:14 +0800 Subject: [PATCH 158/173] up --- plugins/php/versions/common/exif.sh | 3 +-- plugins/php/versions/common/fileinfo.sh | 2 +- plugins/php/versions/common/imagemagick.sh | 4 ++-- plugins/php/versions/common/intl.sh | 3 +-- plugins/php/versions/common/memcache.sh | 2 +- plugins/php/versions/common/memcached.sh | 2 +- plugins/php/versions/common/mongo.sh | 3 +-- plugins/php/versions/common/mongodb.sh | 4 ++-- plugins/php/versions/common/seaslog.sh | 2 +- plugins/php/versions/common/solr.sh | 2 +- plugins/php/versions/common/swoole.sh | 2 +- plugins/php/versions/common/xhprof.sh | 2 +- plugins/php/versions/common/yaf.sh | 2 +- plugins/php/versions/common/zip.sh | 2 +- 14 files changed, 16 insertions(+), 19 deletions(-) diff --git a/plugins/php/versions/common/exif.sh b/plugins/php/versions/common/exif.sh index 6c3961b0f..d45cb90f7 100755 --- a/plugins/php/versions/common/exif.sh +++ b/plugins/php/versions/common/exif.sh @@ -59,8 +59,7 @@ Install_lib() sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile fi - - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/fileinfo.sh b/plugins/php/versions/common/fileinfo.sh index 23c9269fd..3270c8374 100755 --- a/plugins/php/versions/common/fileinfo.sh +++ b/plugins/php/versions/common/fileinfo.sh @@ -57,7 +57,7 @@ Install_lib() sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile fi - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/imagemagick.sh b/plugins/php/versions/common/imagemagick.sh index 874982610..e29de8fc2 100755 --- a/plugins/php/versions/common/imagemagick.sh +++ b/plugins/php/versions/common/imagemagick.sh @@ -53,8 +53,8 @@ Install_lib() cd $php_lib/${LIBNAME}-${LIBV} $serverPath/php/$version/bin/phpize - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - && make clean && make && make install && make clean + ./configure --with-php-config=$serverPath/php/$version/bin/php-config + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/intl.sh b/plugins/php/versions/common/intl.sh index b1ca3f906..d7883437d 100755 --- a/plugins/php/versions/common/intl.sh +++ b/plugins/php/versions/common/intl.sh @@ -53,8 +53,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config $OPTIONS - - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/memcache.sh b/plugins/php/versions/common/memcache.sh index eabf42bcc..39562af5d 100755 --- a/plugins/php/versions/common/memcache.sh +++ b/plugins/php/versions/common/memcache.sh @@ -50,7 +50,7 @@ Install_lib() cd ${LIBNAME}-${LIBV} $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config --enable-memcache --with-zlib-dir - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 2e48b2342..008a9c080 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -56,7 +56,7 @@ Install_lib() ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ --enable-memcached \ - --disable-memcached-sasl && \ + --disable-memcached-sasl make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/mongo.sh b/plugins/php/versions/common/mongo.sh index 4ba5ba6fa..1d6c8137d 100755 --- a/plugins/php/versions/common/mongo.sh +++ b/plugins/php/versions/common/mongo.sh @@ -58,8 +58,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config $OPTIONS - - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/mongodb.sh b/plugins/php/versions/common/mongodb.sh index 221a7860a..4052b1e4e 100755 --- a/plugins/php/versions/common/mongodb.sh +++ b/plugins/php/versions/common/mongodb.sh @@ -67,8 +67,8 @@ Install_lib() cd $php_lib/${LIBNAME}-${LIBV} $serverPath/php/$version/bin/phpize - ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ - && make clean && make && make install && make clean + ./configure --with-php-config=$serverPath/php/$version/bin/php-config + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/seaslog.sh b/plugins/php/versions/common/seaslog.sh index 7b429bab9..c15e4804e 100755 --- a/plugins/php/versions/common/seaslog.sh +++ b/plugins/php/versions/common/seaslog.sh @@ -58,7 +58,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi sleep 1 diff --git a/plugins/php/versions/common/solr.sh b/plugins/php/versions/common/solr.sh index 7f200319c..82f5ca13e 100755 --- a/plugins/php/versions/common/solr.sh +++ b/plugins/php/versions/common/solr.sh @@ -57,7 +57,7 @@ Install_lib() cd $php_lib/${LIBNAME}-${LIBV} $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config $OPTIONS - make && make install && make clean + make clean && make && make install && make clean fi sleep 1 if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/common/swoole.sh b/plugins/php/versions/common/swoole.sh index a1cc27c6c..bc6a43482 100755 --- a/plugins/php/versions/common/swoole.sh +++ b/plugins/php/versions/common/swoole.sh @@ -62,7 +62,7 @@ Install_lib() --enable-openssl \ --with-openssl-dir=$serverPath/lib/openssl \ --enable-sockets - make && make install && make clean + make clean && make && make install && make clean fi while [[ ! -f "$extFile" ]]; diff --git a/plugins/php/versions/common/xhprof.sh b/plugins/php/versions/common/xhprof.sh index e4b97d0ad..771826a29 100755 --- a/plugins/php/versions/common/xhprof.sh +++ b/plugins/php/versions/common/xhprof.sh @@ -51,7 +51,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --enable-xhprof \ --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/yaf.sh b/plugins/php/versions/common/yaf.sh index 8598e90b1..d47edad6f 100755 --- a/plugins/php/versions/common/yaf.sh +++ b/plugins/php/versions/common/yaf.sh @@ -62,7 +62,7 @@ Install_lib() $serverPath/php/$version/bin/phpize ./configure --with-php-config=$serverPath/php/$version/bin/php-config - make && make install && make clean + make clean && make && make install && make clean fi diff --git a/plugins/php/versions/common/zip.sh b/plugins/php/versions/common/zip.sh index dc877acbe..8ca5d2e05 100755 --- a/plugins/php/versions/common/zip.sh +++ b/plugins/php/versions/common/zip.sh @@ -52,7 +52,7 @@ Install_lib() ./configure --with-php-config=$serverPath/php/$version/bin/php-config \ --with-zip - make && make install && make clean + make clean && make && make install && make clean fi From 2bf965d2a35eb88485bbb7c0a6d4899cbaa7f819 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:34:41 +0800 Subject: [PATCH 159/173] Update rocky.sh --- scripts/install/rocky.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index df20d83cf..bdb333524 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -81,6 +81,8 @@ do yum -y install $yumPack;done yum install -y libtirpc libtirpc-devel +dnf --enablerepo=powertools install -y libmemcached libmemcached-devel + cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From 8f4f7d9724a3acb05f0275a6da49b3e26ad20838 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:35:01 +0800 Subject: [PATCH 160/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index 008a9c080..a6380714b 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -38,8 +38,6 @@ Install_lib() return fi - # cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libmemcached.sh - if [ ! -f "$extFile" ];then php_lib=$sourcePath/php_lib From 49572a807484d929ff8c4d9eb8a934860a4b7979 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:36:13 +0800 Subject: [PATCH 161/173] Update rocky.sh --- scripts/install/rocky.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index bdb333524..c26557a7b 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -82,6 +82,7 @@ do yum -y install $yumPack;done yum install -y libtirpc libtirpc-devel dnf --enablerepo=powertools install -y libmemcached libmemcached-devel +dnf --enablerepo=powertools install -y rpcgen cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From d4f433f6c6c2d9e2f27f5e2b3247be468429eb4a Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:38:16 +0800 Subject: [PATCH 162/173] up --- plugins/php/versions/74/install.sh | 1 - plugins/php/versions/80/install.sh | 1 - plugins/php/versions/81/install.sh | 1 - plugins/php/versions/82/install.sh | 1 - scripts/install/rocky.sh | 1 + 5 files changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 2c101f9ed..ede715e75 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -24,7 +24,6 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index fc42f1b23..38dcd912e 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -24,7 +24,6 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index b38b624a3..fb8000c24 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -24,7 +24,6 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index c9c6be68d..6ceed4984 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -24,7 +24,6 @@ cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash oniguruma.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index c26557a7b..ccc832f9b 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -83,6 +83,7 @@ yum install -y libtirpc libtirpc-devel dnf --enablerepo=powertools install -y libmemcached libmemcached-devel dnf --enablerepo=powertools install -y rpcgen +dnf --enablerepo=powertools install -y oniguruma oniguruma-devel cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From 66893cc76f053ec0b69fbefcce21b71bf508056a Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:39:49 +0800 Subject: [PATCH 163/173] Update rocky.sh --- scripts/install/rocky.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index ccc832f9b..e6152c4b7 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -85,6 +85,8 @@ dnf --enablerepo=powertools install -y libmemcached libmemcached-devel dnf --enablerepo=powertools install -y rpcgen dnf --enablerepo=powertools install -y oniguruma oniguruma-devel +dnf --enablerepo=powertools install -y re2c bison + cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data From 6de53d16a630ef5f348bd81ebb96d9e1dbb7d7c1 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:51:19 +0800 Subject: [PATCH 164/173] up --- scripts/install/fedora.sh | 2 ++ scripts/install/rocky.sh | 3 +-- scripts/lib.sh | 5 ----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index 4ab4c71f3..86eef8531 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -82,6 +82,8 @@ yum -y install python3-devel for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof vixie-cron crontabs expat-devel readline-devel; do yum -y install $yumPack;done +dnf install libxml2 libxml2-devel -y + cd /www/server/mdserver-web/scripts && bash lib.sh chmod 755 /www/server/mdserver-web/data diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index e6152c4b7..5d3ea7a93 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -77,14 +77,13 @@ yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; -do yum -y install $yumPack;done +do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel dnf --enablerepo=powertools install -y libmemcached libmemcached-devel dnf --enablerepo=powertools install -y rpcgen dnf --enablerepo=powertools install -y oniguruma oniguruma-devel - dnf --enablerepo=powertools install -y re2c bison cd /www/server/mdserver-web/scripts && bash lib.sh diff --git a/scripts/lib.sh b/scripts/lib.sh index 55dd284d9..2ddedb25d 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -109,11 +109,6 @@ else yum install -y mysql-devel yum install -y oniguruma oniguruma-devel yum install -y ImageMagick ImageMagick-devel - - if [ "$OSNAME" == "fedora" ]; then - dnf install libxml2 libxml2-devel -y - - fi fi From 6eac91a74d83077a0580fec7a2330d5a63ebad19 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 14 Jul 2022 23:58:51 +0800 Subject: [PATCH 165/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index a6380714b..e50b00e7e 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -21,6 +21,10 @@ if [ "$version" -lt "70" ];then LIBV=2.2.0 fi +if [ "$version" -eq "70" ];then + LIBV=3.1.5 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so From c1cce73776eb4d42626400b887bd16f4b6181fe1 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:06:50 +0800 Subject: [PATCH 166/173] Update xdebug.sh --- plugins/php/versions/common/xdebug.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/php/versions/common/xdebug.sh b/plugins/php/versions/common/xdebug.sh index 1d76fe3b5..ccc6ccf0c 100755 --- a/plugins/php/versions/common/xdebug.sh +++ b/plugins/php/versions/common/xdebug.sh @@ -25,6 +25,11 @@ if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then LIBV=2.7.0 fi +if [ "$version" -eq "82" ];then + echo "not need" + exit 1 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so From 6fbdae550ca9b4823dbfdcc23d68a5f0572c81ae Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:07:53 +0800 Subject: [PATCH 167/173] Update memcached.sh --- plugins/php/versions/common/memcached.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/common/memcached.sh b/plugins/php/versions/common/memcached.sh index e50b00e7e..aa4b52db9 100755 --- a/plugins/php/versions/common/memcached.sh +++ b/plugins/php/versions/common/memcached.sh @@ -21,7 +21,7 @@ if [ "$version" -lt "70" ];then LIBV=2.2.0 fi -if [ "$version" -eq "70" ];then +if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then LIBV=3.1.5 fi From ce9542eee62ef920fdd390cc4c7c81f679e94131 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:08:52 +0800 Subject: [PATCH 168/173] up --- plugins/php/versions/common/swoole.sh | 5 +++++ plugins/php/versions/common/yaf.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/plugins/php/versions/common/swoole.sh b/plugins/php/versions/common/swoole.sh index bc6a43482..826b27559 100755 --- a/plugins/php/versions/common/swoole.sh +++ b/plugins/php/versions/common/swoole.sh @@ -27,6 +27,11 @@ else echo '72+' fi +if [ "$version" -eq "82" ];then + echo "not need" + exit 1 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so diff --git a/plugins/php/versions/common/yaf.sh b/plugins/php/versions/common/yaf.sh index d47edad6f..affe7ab66 100755 --- a/plugins/php/versions/common/yaf.sh +++ b/plugins/php/versions/common/yaf.sh @@ -31,6 +31,11 @@ if [ "$version" -eq "72" ] || [ "$version" -eq "73" ];then LIBV=3.2.5 fi +if [ "$version" -eq "82" ];then + echo "not need" + exit 1 +fi + NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts` extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so From 7539bd4c48f44bb24d721e7621757eb31c417f1e Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:20:26 +0800 Subject: [PATCH 169/173] Update rocky.sh --- scripts/install/rocky.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 5d3ea7a93..0544bfaca 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -81,6 +81,8 @@ do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel +dnf install boost-locale + dnf --enablerepo=powertools install -y libmemcached libmemcached-devel dnf --enablerepo=powertools install -y rpcgen dnf --enablerepo=powertools install -y oniguruma oniguruma-devel From 2102054f67b31afadbe47a57936c66a6c315a703 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:22:55 +0800 Subject: [PATCH 170/173] Update rocky.sh --- scripts/install/rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 0544bfaca..610288f52 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -76,7 +76,7 @@ yum install -y lsof net-tools yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python -for yumPack in make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; +for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel From 952af309a7ce976af107af57f106c3559bea1cc5 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:23:59 +0800 Subject: [PATCH 171/173] Update rocky.sh --- scripts/install/rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 610288f52..faae2c14e 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -76,7 +76,7 @@ yum install -y lsof net-tools yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python -for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; +for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel From 2fbb26535e4d325ff63aff876d9a7122acf43536 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:24:21 +0800 Subject: [PATCH 172/173] Update rocky.sh --- scripts/install/rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index faae2c14e..a42a6745e 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -76,7 +76,7 @@ yum install -y lsof net-tools yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python -for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; +for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel From 45e88ca43d17801d147344389f958fd49f027e02 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 15 Jul 2022 00:24:59 +0800 Subject: [PATCH 173/173] Update rocky.sh --- scripts/install/rocky.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index a42a6745e..f0cba70db 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -76,7 +76,7 @@ yum install -y lsof net-tools yum install -y ncurses-devel mysql-devel cmake yum install -y MySQL-python -for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; +for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel; do dnf --enablerepo=powertools install -y $yumPack;done yum install -y libtirpc libtirpc-devel