diff --git a/class/core/config_api.py b/class/core/config_api.py
index 243e843d8..d089b89eb 100755
--- a/class/core/config_api.py
+++ b/class/core/config_api.py
@@ -16,7 +16,7 @@ from flask import request
class config_api:
# mariadb 优化
- __version = '0.9.0'
+ __version = '0.9.0.1'
def __init__(self):
pass
diff --git a/plugins/postgresql/class/pg.py b/plugins/postgresql/class/pg.py
index 74aae0f52..c984a9350 100755
--- a/plugins/postgresql/class/pg.py
+++ b/plugins/postgresql/class/pg.py
@@ -15,10 +15,18 @@ class ORM:
__DB_CONN = None
__DB_CUR = None
__DB_ERR = None
- __DB_CNF = '/etc/my.cnf'
+ __DB_CNF = '/etc/postgresql.cnf'
__DB_SOCKET = '/www/server/postgresql/mysql.sock'
__DB_CHARSET = "utf8"
+ __DB_TABLE = "" # 被操作的表名称
+ __OPT_WHERE = "" # where条件
+ __OPT_LIMIT = "" # limit条件
+ __OPT_GROUP = "" # group条件
+ __OPT_ORDER = "" # order条件
+ __OPT_FIELD = "*" # field条件
+ __OPT_PARAM = () # where值
+
def __Conn(self):
'''连接数据库'''
try:
@@ -55,6 +63,82 @@ class ORM:
def getPwd(self):
return self.__DB_PASS
+ def table(self, table):
+ # 设置表名
+ self.__DB_TABLE = table
+ return self
+
+ def where(self, where, param=()):
+ # WHERE条件
+ if where:
+ self.__OPT_WHERE = " WHERE " + where
+ self.__OPT_PARAM = param
+ return self
+
+ def andWhere(self, where, param):
+ # WHERE条件
+ if where:
+ self.__OPT_WHERE = self.__OPT_WHERE + " and " + where
+ # print(param)
+ # print(self.__OPT_PARAM)
+ self.__OPT_PARAM = self.__OPT_PARAM + param
+ return self
+
+ def order(self, order):
+ # ORDER条件
+ if len(order):
+ self.__OPT_ORDER = " ORDER BY " + order
+ else:
+ self.__OPT_ORDER = ""
+ return self
+
+ def group(self, group):
+ if len(group):
+ self.__OPT_GROUP = " GROUP BY " + group
+ else:
+ self.__OPT_GROUP = ""
+ return self
+
+ def limit(self, limit):
+ # LIMIT条件
+ if len(limit):
+ self.__OPT_LIMIT = " LIMIT " + limit
+ else:
+ self.__OPT_LIMIT = ""
+ return self
+
+ def field(self, field):
+ # FIELD条件
+ if len(field):
+ self.__OPT_FIELD = field
+ return self
+
+ def select(self):
+ # 查询数据集
+ self.__Conn()
+ try:
+ sql = "SELECT " + self.__OPT_FIELD + " FROM " + self.__DB_TABLE + \
+ self.__OPT_WHERE + self.__OPT_GROUP + self.__OPT_ORDER + self.__OPT_LIMIT
+ # print(sql)
+ result = self.__DB_CUR.execute(sql, self.__OPT_PARAM)
+ data = self.__DB_CUR.fetchall()
+ ret = []
+ if self.__OPT_FIELD != "*":
+ field = self.__OPT_FIELD.split(',')
+ for row in data:
+ i = 0
+ field_k = {}
+ for key in field:
+ field_k[key] = row[i]
+ i += 1
+ ret.append(field_k)
+ else:
+ ret = map(list, data)
+ self.__Close()
+ return ret
+ except Exception as ex:
+ return "error: " + str(ex)
+
def execute(self, sql):
# 执行SQL语句返回受影响行
if not self.__Conn():
diff --git a/plugins/postgresql/conf/postgresql.conf b/plugins/postgresql/conf/postgresql.conf
index 00e9606fe..78457a15e 100644
--- a/plugins/postgresql/conf/postgresql.conf
+++ b/plugins/postgresql/conf/postgresql.conf
@@ -2,6 +2,7 @@ port = 5432
listen_addresses='*'
unix_socket_directories='{$APP_PATH}/tmp'
+max_connections=200
max_wal_size = 1GB
min_wal_size = 80MB
diff --git a/plugins/postgresql/index.py b/plugins/postgresql/index.py
index edb1dcdcb..c890fb00c 100755
--- a/plugins/postgresql/index.py
+++ b/plugins/postgresql/index.py
@@ -606,7 +606,7 @@ def importDbBackup():
cmd = 'cd ' + mw.getRootDir() + '/backup/database && gzip -d ' + file
mw.execShell(cmd)
- pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
+ pwd = pSqliteDb('config').where('id=?', (1,)).getField('pg_root')
mysql_cmd = mw.getRootDir() + '/server/mysql/bin/mysql -uroot -p' + pwd + \
' ' + name + ' < ' + file_path_sql
@@ -699,7 +699,7 @@ def getDbList():
info = {}
info['root_pwd'] = pSqliteDb('config').where(
- 'id=?', (1,)).getField('mysql_root')
+ 'id=?', (1,)).getField('pg_root')
data['info'] = info
return mw.getJson(data)
@@ -708,20 +708,14 @@ def getDbList():
def syncGetDatabases():
pdb = pgDb()
psdb = pSqliteDb('databases')
- data = pdb.query('SELECT * FROM pg_database WHERE datistemplate = false')
- print(data)
- return
- # 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']
+ data = pdb.table('pg_database').field(
+ 'datname').where("datistemplate=false").select()
+ nameArr = ['postgres', ]
n = 0
# print(users)
for value in data:
- vdb_name = value["Database"]
+ vdb_name = value["datname"]
b = False
for key in nameArr:
if vdb_name == key:
@@ -732,14 +726,12 @@ def syncGetDatabases():
if psdb.where("name=?", (vdb_name,)).count() > 0:
continue
host = '127.0.0.1'
- for user in users:
- if vdb_name == user["User"]:
- host = user["Host"]
- break
+ # for user in users:
+ # if vdb_name == user["User"]:
+ # host = user["Host"]
+ # break
ps = mw.getMsg('INPUT_PS')
- if vdb_name == 'test':
- ps = mw.getMsg('DATABASE_TEST')
addTime = time.strftime('%Y-%m-%d %X', time.localtime())
if psdb.add('name,username,password,accept,ps,addtime', (vdb_name, vdb_name, '', host, ps, addTime)):
n += 1
@@ -748,12 +740,74 @@ def syncGetDatabases():
return mw.returnJson(True, msg)
+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 = pgDb()
+ psdb = pSqliteDb('databases')
+ if psdb.where("name=? or username=?", (dbname, dbuser)).count():
+ return mw.returnJson(False, '数据库已存在!')
+
+ result = pdb.execute("create database " + dbname)
+
+ print(result)
+ return
+
+ # 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 installPreInspection(version):
return 'ok'
def uninstallPreInspection(version):
- # return "请手动删除MySQL[{}]".format(version)
return 'ok'
if __name__ == "__main__":
@@ -800,6 +854,8 @@ if __name__ == "__main__":
print(setPgPort())
elif func == 'get_db_list':
print(getDbList())
+ elif func == 'add_db':
+ print(addDb())
elif func == 'sync_get_databases':
print(syncGetDatabases())
else:
diff --git a/scripts/install_cn.sh b/scripts/install_cn.sh
deleted file mode 100755
index f6d1fd9d4..000000000
--- a/scripts/install_cn.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/bash
-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
-export PATH
-# LANG=en_US.UTF-8
-is64bit=`getconf LONG_BIT`
-
-if [ -f /etc/motd ];then
- echo "welcome to mdserver-web panel" > /etc/motd
-fi
-
-startTime=`date +%s`
-
-_os=`uname`
-echo "use system: ${_os}"
-
-if [ "$EUID" -ne 0 ]
- then echo "Please run as root!"
- exit
-fi
-
-
-
-if [ ${_os} == "Darwin" ]; then
- OSNAME='macos'
-elif grep -Eq "openSUSE" /etc/*-release; then
- OSNAME='opensuse'
- zypper refresh
-elif grep -Eq "FreeBSD" /etc/*-release; then
- OSNAME='freebsd'
-elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
- OSNAME='centos'
- yum install -y wget zip unzip
-elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
- OSNAME='fedora'
- yum install -y wget zip unzip
-elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
- OSNAME='rocky'
- yum install -y wget zip unzip
-elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
- OSNAME='alma'
- yum install -y wget zip unzip
-elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
- OSNAME='debian'
- apt update -y
- apt install -y devscripts
- apt install -y wget zip unzip
-elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
- OSNAME='ubuntu'
- apt install -y wget zip unzip
-else
- OSNAME='unknow'
-fi
-
-
-if [ $OSNAME != "macos" ];then
- mkdir -p /www/server
- mkdir -p /www/wwwroot
- mkdir -p /www/wwwlogs
- mkdir -p /www/backup/database
- mkdir -p /www/backup/site
-
- if [ ! -d /www/server/mdserver-web ];then
- wget -O /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip
- cd /tmp && unzip /tmp/master.zip
- mv -f /tmp/mdserver-web-master /www/server/mdserver-web
- rm -rf /tmp/master.zip
- rm -rf /tmp/mdserver-web-master
- fi
-fi
-
-echo "use system version: ${OSNAME}"
-cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
-
-chmod +x /www/server/mdserver-web/mw-cli
-if [ ! -e /usr/bin/mw-cli ]; then
- ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli
-fi
-
-endTime=`date +%s`
-((outTime=(${endTime}-${startTime})/60))
-echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
-
-systemctl daemon-reload
-
-
diff --git a/scripts/update_cn.sh b/scripts/update_cn.sh
deleted file mode 100755
index f7392d136..000000000
--- a/scripts/update_cn.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
-export PATH
-# LANG=en_US.UTF-8
-is64bit=`getconf LONG_BIT`
-
-startTime=`date +%s`
-
-_os=`uname`
-echo "use system: ${_os}"
-
-if [ "$EUID" -ne 0 ]
- then echo "Please run as root!"
- exit
-fi
-
-
-
-if [ ${_os} == "Darwin" ]; then
- OSNAME='macos'
-elif grep -Eq "openSUSE" /etc/*-release; then
- OSNAME='opensuse'
- zypper refresh
-elif grep -Eq "FreeBSD" /etc/*-release; then
- OSNAME='freebsd'
-elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
- OSNAME='centos'
- yum install -y wget zip unzip
-elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
- OSNAME='fedora'
- yum install -y wget zip unzip
-elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
- OSNAME='rocky'
- yum install -y wget zip unzip
-elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
- OSNAME='alma'
- yum install -y wget zip unzip
-elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
- OSNAME='debian'
- apt install -y wget zip unzip
-elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
- OSNAME='ubuntu'
- apt install -y wget zip unzip
-elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
- OSNAME='raspbian'
-else
- OSNAME='unknow'
-fi
-
-wget -O /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip
-cd /tmp && unzip /tmp/master.zip
-cp -rf /tmp/mdserver-web-master/* /www/server/mdserver-web
-rm -rf /tmp/master.zip
-rm -rf /tmp/mdserver-web-master
-
-#pip uninstall public
-echo "use system version: ${OSNAME}"
-cd /www/server/mdserver-web && bash scripts/update/${OSNAME}.sh
-
-endTime=`date +%s`
-((outTime=($endTime-$startTime)/60))
-echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
\ No newline at end of file
diff --git a/version/info.json b/version/info.json
index 8fd667f62..0ed4efb26 100644
--- a/version/info.json
+++ b/version/info.json
@@ -1,47 +1,13 @@
[
{
- "version": "0.9.9",
+ "version": "0.9.1",
"content": "* 主流系统支持。
* 插件支持更多参数。
* MySQL主从支持GTID和经典模式。
* MariaDB主从支持GTID和经典模式。
* Rsyncd更新。
* 添加网站统计的插件。
* 添加varnish插件。",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.9.0/mdserver-web.zip"
- },
- {
- "version": "0.8.6",
- "content": "* mysql主从配置。
* swap插件[虚拟内存]。
* 部分优化。",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.8.6/mdserver-web.zip"
- },
- {
- "version": "0.8.5",
- "content": "* 添加PHP80版本-Alpha
* 自动识别IP地址
* 增加xhprof插件",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.8.5/mdserver-web.zip"
- },
- {
- "version": "0.7.3",
- "content": "* 修复自动更新错误
* 优化文件批量处理
* 添加PHP守护插件",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.7.3/mdserver-web.zip"
+ "path": "https://github.com/midoks/mdserver-web/releases/download/0.9.9/mdserver-web.zip",
+ "purge":"https://purge.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh",
},
{
- "version": "0.5.6",
- "content": "* openresty,php,mysql,memcached,redis,pureftp,sphinx自启动添加
* 修复rsync自启动问题",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.5.6/mdserver-web.zip"
- },
- {
- "version": "0.4.2",
- "content": "* ssh工具优化
* 面板收藏功能完成
* 网站子目录绑定
* 网站备份
* 自动更新优化",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.4.2/mdserver-web.zip"
- },
- {
- "version": "0.0.6",
- "content": "1.修复重复js方法",
- "path": "https://github.com//midoks/mdserver-web/archive/0.0.6.zip"
- },
- {
- "version": "0.0.5",
- "content": "1.基本功能OK
,2.网站HTTPS功能验证!",
- "path": "https://github.com//midoks/mdserver-web/archive/0.0.5.zip"
- },
- {
- "version": "0.0.1.2",
- "content": "1.项目初建!
2.面板更新功能!",
- "path": "https://github.com/midoks/mdserver-web/releases/download/0.0.1/mdserver-web.zip"
+ "version": "0.9.0",
+ "content": "* 主流系统支持。
* 插件支持更多参数。
* MySQL主从支持GTID和经典模式。
* MariaDB主从支持GTID和经典模式。
* Rsyncd更新。
* 添加网站统计的插件。
* 添加varnish插件。",
+ "path": "https://github.com/midoks/mdserver-web/releases/download/0.9.0/mdserver-web.zip"
}
]
\ No newline at end of file