Compare commits

...
32 Commits
Author SHA1 Message Date
Mr Chen 1a1e211107 Merge pull request #158 from midoks/dev
0.9.3
2022-08-13 01:35:11 +08:00
midoks 2d32578b5f Update phplib.conf 2022-08-12 23:09:45 +08:00
midoks e07f0fca9c Update phplib.conf 2022-08-12 23:06:49 +08:00
midoks 80344149da Update README.md 2022-08-12 23:03:58 +08:00
midoks 046abc4cba 移动到mw-plugins 不在和行插件维护。 2022-08-12 23:01:00 +08:00
midoks 588ec43543 Update install.sh 2022-08-12 21:35:48 +08:00
midoks ea8a4baba6 Update info.json 2022-08-12 19:54:00 +08:00
midoks bcf3516f22 Update README.md 2022-08-12 19:53:26 +08:00
midoks 16acda5d60 up 2022-08-12 19:52:26 +08:00
midoks 68b9b95d5c 依赖github,自动更新。 2022-08-12 19:47:41 +08:00
midoks e32c4926ca 更改同步信息 2022-08-12 19:18:51 +08:00
midoks f4bb052776 Update info.json 2022-08-12 18:52:40 +08:00
midoks 3cc92a1eab Update info.json 2022-08-12 17:42:08 +08:00
midoks 24b8b1ee7c Update system_api.py 2022-08-12 17:41:04 +08:00
midoks 1996442b56 Update system_api.py 2022-08-12 17:24:55 +08:00
midoks 529ba08aee Update system_api.py 2022-08-12 17:19:09 +08:00
midoks 701b19e0b6 Update info.json 2022-08-12 16:40:05 +08:00
midoks 06f1b34f52 Update system_api.py 2022-08-12 16:35:49 +08:00
midoks 72c5efcc2f Update system_api.py 2022-08-12 15:29:59 +08:00
midoks ac29bb098b Update install.sh 2022-08-12 12:47:58 +08:00
Mr Chen 887589dbf9 Merge pull request #157 from midoks/dev
0.9.2
2022-08-12 12:12:37 +08:00
midoks bc640ad888 Update index.py 2022-08-12 12:07:08 +08:00
midoks 8b00a7436a up 2022-08-12 11:39:45 +08:00
midoks e8483b78a0 Update info.json 2022-08-12 00:46:53 +08:00
midoks ab6ffa4cf5 Update README.md 2022-08-12 00:41:24 +08:00
midoks 14682df7cb Update README.md 2022-08-12 00:40:42 +08:00
midoks 2c9b05be6d Update config_api.py 2022-08-12 00:37:56 +08:00
midoks 5626110bd9 常用命令说明 2022-08-12 00:37:19 +08:00
midoks e3e704984e 优化 2022-08-12 00:12:56 +08:00
midoks 1ac89246a4 防火墙安装自动化 2022-08-11 23:49:24 +08:00
midoks 6c8790b915 Update install.sh 2022-08-11 23:37:45 +08:00
midoks 2dad3bc59d Update info.json 2022-08-11 22:46:01 +08:00
26 changed files with 156 additions and 4504 deletions
+8 -4
View File
@@ -1,4 +1,4 @@
### mdserver-web 0.9.1
### mdserver-web 0.9.2
简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。
复制了后台管理界面,按照自己想要的方式写了一版。
@@ -22,6 +22,7 @@
- 吹水组 - https://t.me/mdserver_web
- [兼容性测试报告](/compatibility.md)
- [常用命令说明](/cmd.md)
### 主要插件介绍
@@ -70,10 +71,13 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```
### 版本更新 0.9.1
### 版本更新 0.9.3
* 菜单修复.
* 更新修复.
* 批量域名添加修复。
* 常用命令说明。
* 重写页面更新功能。
* MySQL8.0安装地址修改。
* 删除MySQL[Yum]插件。
### JSDelivr安装地址
+1 -2
View File
@@ -15,8 +15,7 @@ from flask import request
class config_api:
# mariadb 优化
__version = '0.9.1'
__version = '0.9.3'
def __init__(self):
pass
+1 -1
View File
@@ -171,7 +171,7 @@ class Sql():
def getField(self, keyName):
# 取回指定字段
result = self.field(keyName).select()
if len(result) >= 1:
if len(result) == 1:
return result[0][keyName]
return result
+4 -1
View File
@@ -878,6 +878,9 @@ class site_api:
domain = request.form.get('domain', '')
webname = request.form.get('webname', '')
pid = request.form.get('id', '')
return self.addDomain(domain, webname, pid)
def addDomain(self, domain, webname, pid):
if len(domain) < 3:
return mw.returnJson(False, '域名不能为空!')
domains = domain.split(',')
@@ -2184,7 +2187,7 @@ location ^~ {from} {
sdomain = domain
swebname = self.siteName
spid = str(pid)
# self.addDomain(domain, webname, pid)
self.addDomain(domain, webname, pid)
mw.M('domain').add('pid,name,port,addtime',
(pid, self.siteName, self.sitePort, mw.getDate()))
+39 -28
View File
@@ -625,13 +625,13 @@ class system_api:
def getServerInfo(self):
import urllib.request
import ssl
upAddr = 'https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/version/info.json'
upAddr = 'https://api.github.com/repos/midoks/mdserver-web/releases/latest'
try:
context = ssl._create_unverified_context()
req = urllib.request.urlopen(upAddr, context=context, timeout=3)
result = req.read().decode('utf-8')
version = json.loads(result)
return version[0]
return version
except Exception as e:
print('getServerInfo', e)
return {}
@@ -642,58 +642,69 @@ class system_api:
if not mw.isRestart():
return mw.returnJson(False, '请等待所有安装任务完成再执行!')
version_new_info = self.getServerInfo()
version_now = config_api.config_api().getVersion()
new_ver = version_new_info['name']
if stype == 'check':
version_now = config_api.config_api().getVersion()
version_new_info = self.getServerInfo()
if not 'version' in version_new_info:
if not 'name' in version_new_info:
return mw.returnJson(False, '服务器数据或网络有问题!')
diff = self.versionDiff(
version_now, version_new_info['version'])
diff = self.versionDiff(version_now, new_ver)
if diff == 'new':
return mw.returnJson(True, '有新版本!', version_new_info['version'])
return mw.returnJson(True, '有新版本!', new_ver)
elif diff == 'test':
return mw.returnJson(True, '有测试版本!', version_new_info['version'])
return mw.returnJson(True, '有测试版本!', new_ver)
else:
return mw.returnJson(False, '已经是最新,无需更新!')
if stype == 'info':
version_new_info = self.getServerInfo()
version_now = config_api.config_api().getVersion()
if not 'version' in version_new_info:
if not 'name' in version_new_info:
return mw.returnJson(False, '服务器数据有问题!')
diff = self.versionDiff(
version_now, version_new_info['version'])
return mw.returnJson(True, '更新信息!', version_new_info)
diff = self.versionDiff(version_now, new_ver)
data = {}
data['version'] = new_ver
data['content'] = version_new_info[
'body'].replace("\n", "<br/>")
return mw.returnJson(True, '更新信息!', data)
if stype == 'update':
if version == '':
return mw.returnJson(False, '缺少版本信息!')
v_new_info = self.getServerInfo()
if v_new_info['version'] != version:
if new_ver != version:
return mw.returnJson(False, '更新失败,请重试!')
if not 'path' in v_new_info or v_new_info['path'] == '':
return mw.returnJson(False, '下载地址不存在!')
newUrl = v_new_info['path']
toPath = mw.getRootDir() + '/temp'
if not os.path.exists(toPath):
mw.execShell('mkdir -p ' + toPath)
mw.execShell('wget -O ' + toPath + '/mw.zip ' + newUrl)
newUrl = "https://github.com/midoks/mdserver-web/archive/refs/tags/" + version + ".zip"
mw.execShell('unzip -o ' + toPath + '/mw.zip' + ' -d ./')
mw.execShell('unzip -o mw.zip -d ./')
mw.execShell('rm -f mw.zip')
dist_mw = toPath + '/mw.zip'
if not os.path.exists(dist_mw):
mw.execShell('wget -O ' + dist_mw + ' ' + newUrl)
dist_to = toPath + "/mdserver-web-" + version
if not os.path.exists(dist_to):
mw.execShell('unzip -o ' + toPath +
'/mw.zip' + ' -d ' + toPath)
cmd_cp = "cp -rf " + toPath + '/mdserver-web-' + \
version + "/* " + mw.getServerDir() + "/mdserver-web"
mw.execShell(cmd_cp)
mw.execShell('rm -rf ' + toPath + '/mdserver-web-' + version)
mw.execShell('rm -rf ' + toPath + '/mw.zip')
self.restartMw()
return mw.returnJson(True, '安装更新成功,需自己重启!')
return mw.returnJson(False, '已经是最新,无需更新!')
except Exception as ex:
print('updateServer', ex)
return mw.returnJson(False, "连接服务器失败!")
# print('updateServer', ex)
return mw.returnJson(False, "连接服务器失败!" + str(ex))
# 修复面板
def repPanel(self, get):
+68
View File
@@ -0,0 +1,68 @@
### 常用命令说明
- 面板相关命令
```
/etc/init.d/mw default
service mw [start|stop|reload|restart|status]
```
- OpenResty
```
sytemctl [start|stop|reload|restart|status] openresty
```
- MySQL
```
sytemctl [start|stop|reload|restart|status] mysql
```
- MariaDB
```
sytemctl [start|stop|reload|restart|status] mariadb
```
- PHP
```
sytemctl [start|stop|reload|restart|status] php[54-81]
sytemctl start php71
```
- Redis
```
sytemctl [start|stop|reload|restart|status] redis
```
- Memcached
```
sytemctl [start|stop|reload|restart|status] memcached
```
- sphinx
```
sytemctl [start|stop|reload|restart|status] sphinx
```
-97
View File
@@ -1,97 +0,0 @@
[client]
user = root
#password = your_password
port = 3376
socket = {$SERVER_APP_PATH}/mysql.sock
default-character-set = UTF8MB4
[mysqld]
pid-file = {$SERVER_APP_PATH}/data/mysql.pid
user = mysql
port = 3376
mysqlx_port = 33760
socket = {$SERVER_APP_PATH}/mysql.sock
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
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
-98
View File
@@ -1,98 +0,0 @@
[client]
user = root
#password = your_password
port = 3386
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 = 3386
mysqlx_port = 33860
socket = {$SERVER_APP_PATH}/mysql.sock
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
-28
View File
@@ -1,28 +0,0 @@
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
);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

-58
View File
@@ -1,58 +0,0 @@
<div class="bt-form">
<div class='plugin_version'></div>
<div class="bt-w-main">
<div class="bt-w-menu">
<script type="text/javascript">console.log($('.plugin_version').attr('version'));</script>
<p class="bgw" onclick="pluginService('mysql-yum', $('.plugin_version').attr('version'));">服务</p>
<p onclick="pluginInitD('mysql-yum', $('.plugin_version').attr('version'));">自启动</p>
<p onclick="pluginConfig('mysql-yum', $('.plugin_version').attr('version'));">配置文件</p>
<p onclick="myDbPos();">存储位置</p>
<p onclick="myPort();">端口</p>
<p onclick="runInfo();">当前状态</p>
<p onclick="myPerfOpt();">性能优化</p>
<p onclick="myLogs();">日志</p>
<p onclick="pluginLogs('mysql-yum',$('.plugin_version').attr('version'),'error_log');">错误日志</p>
<p onclick="pluginLogs('mysql-yum',$('.plugin_version').attr('version'),'show_log');">慢日志</p>
<p onclick="dbList()">管理列表</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<style type="text/css">
.db_list{
padding: 0px 0 10px 0;
font-size: 13px;
line-height: 35px;
height: 45px;
}
.db_list a{
margin-right: 15px;
color: #555;
font-weight: 600;
}
.db_list span:nth-child(1){
display: block;
float: left;
padding-left: 15px;
background: #ececec;
border-radius: 3px;
}
#db_tools button {
margin-right: 10px;
}
#db_tools button:last-child{
margin-right: 0;
}
</style>
<script type="text/javascript">
resetPluginWinWidth(800);
$.getScript( "/plugins/file?name=mysql-yum&f=js/mysql-yum.js", function(){
pluginService('mysql-yum',$('.plugin_version').attr('version'));
});
</script>
File diff suppressed because it is too large Load Diff
-17
View File
@@ -1,17 +0,0 @@
{
"title":"MySQL[YUM]",
"tip":"soft",
"name":"mysql-yum",
"type":"运行环境",
"ps":"一种关系数据库管理系统(极速安装)[YUM]!",
"todo_versions":["5.7","8.0"],
"versions":["5.7","8.0"],
"shell":"install.sh",
"install_pre_inspection":true,
"checks":"server/mysql-yum",
"path":"server/mysql-yum",
"author":"mysql",
"home":"https://dev.mysql.com/downloads/mysql",
"date":"2022-06-29",
"pid": "6"
}
@@ -1,63 +0,0 @@
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to use systemctl edit:
#
# $ systemctl edit mysqld.service
#
# this will create file
#
# /etc/systemd/system/mysqld.service.d/override.conf
#
# which be parsed after the file mysqld.service itself is parsed.
#
# For example, if you want to increase mysql's open-files-limit to 20000
# add following when editing with command above:
#
# [Service]
# LimitNOFILE=20000
#
# Or if you require to execute pre and post scripts in the unit file as root, set
# PermissionsStartOnly=true
#
# For more info about custom unit files, see systemd.unit(5) or
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
#
# Don't forget to reload systemd daemon after you change unit configuration:
# root> systemctl --system daemon-reload
[Unit]
Description=MySQL 8.0 database server
After=syslog.target
After=network.target
[Service]
Type=notify
User=mysql
Group=mysql
ExecStartPre=/usr/libexec/mysql-check-socket
ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n
# Note: we set --basedir to prevent probes that might trigger SELinux alarms,
# per bug #547485
ExecStart=/usr/libexec/mysqld --defaults-file={$SERVER_PATH}/mysql-ya/etc/my.cnf --basedir=/usr --user=mysql
ExecStartPost=/usr/libexec/mysql-check-upgrade
ExecStopPost=/usr/libexec/mysql-wait-stop
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
# Place temp files in a secure directory, not /tmp
PrivateTmp=false
Restart=on-failure
RestartPreventExitStatus=1
# Sets open_files_limit
LimitNOFILE = 10000
# Set enviroment variable MYSQLD_PARENT_PID. This is required for SQL restart command.
Environment=MYSQLD_PARENT_PID=1
[Install]
WantedBy=multi-user.target
-46
View File
@@ -1,46 +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")
serverPath=$(dirname "$rootPath")
# cd /www/server/mdserver-web/plugins/mysql-yum && bash install.sh install 8.0
# cd /www/server/mdserver-web/plugins/mysql-yum && bash install.sh uninstall 8.0
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mysql-yum/index.py start 8.0
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
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-yum/index.py stop ${type}
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-yum/index.py initd_uninstall ${type}
cd $curPath
fi
sh -x $curPath/versions/$2/install.sh $1
if [ "${action}" == "install" ];then
# #初始化
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-yum/index.py start ${type}
cd ${rootPath} && python3 ${rootPath}/plugins/mysql-yum/index.py initd_install ${type}
fi
File diff suppressed because it is too large Load Diff
-119
View File
@@ -1,119 +0,0 @@
# coding: utf-8
#-----------------------------
# 网站备份工具
#-----------------------------
import sys
import os
if sys.platform != 'darwin':
os.chdir('/www/server/mdserver-web')
chdir = os.getcwd()
sys.path.append(chdir + '/class/core')
# reload(sys)
# sys.setdefaultencoding('utf-8')
import mw
import db
import time
class backupTools:
def backupDatabase(self, name, count):
db_path = mw.getServerDir() + '/mysql-ya'
db_name = 'mysql'
name = mw.M('databases').dbPos(db_path, 'mysql').where(
'name=?', (name,)).getField('name')
startTime = time.time()
if not name:
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
log = "数据库[" + name + "]不存在!"
print("★[" + endDate + "] " + log)
print(
"----------------------------------------------------------------------------")
return
backup_path = mw.getRootDir() + '/backup/database'
if not os.path.exists(backup_path):
mw.execShell("mkdir -p " + backup_path)
filename = backup_path + "/db_" + name + "_" + \
time.strftime('%Y%m%d_%H%M%S', time.localtime()) + ".sql.gz"
import re
mysql_root = mw.M('config').dbPos(db_path, db_name).where(
"id=?", (1,)).getField('mysql_root')
mycnf = mw.readFile(db_path + '/etc/my.cnf')
rep = "\[mysqldump\]\nuser=root"
sea = "[mysqldump]\n"
subStr = sea + "user=root\npassword=" + mysql_root + "\n"
mycnf = mycnf.replace(sea, subStr)
if len(mycnf) > 100:
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
mw.execShell(
db_path + "/bin/mysqldump --opt --default-character-set=utf8 " + name + " | gzip > " + filename)
if not os.path.exists(filename):
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
log = "数据库[" + name + "]备份失败!"
print("★[" + endDate + "] " + log)
print(
"----------------------------------------------------------------------------")
return
mycnf = mw.readFile(db_path + '/etc/my.cnf')
mycnf = mycnf.replace(subStr, sea)
if len(mycnf) > 100:
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
outTime = time.time() - startTime
pid = mw.M('databases').dbPos(db_path, db_name).where(
'name=?', (name,)).getField('id')
mw.M('backup').add('type,name,pid,filename,addtime,size', (1, os.path.basename(
filename), pid, filename, endDate, os.path.getsize(filename)))
log = "数据库[" + name + "]备份成功,用时[" + str(round(outTime, 2)) + u"]秒"
mw.writeLog('计划任务', log)
print("★[" + endDate + "] " + log)
print("|---保留最新的[" + count + "]份备份")
print("|---文件名:" + filename)
# 清理多余备份
backups = mw.M('backup').where(
'type=? and pid=?', ('1', pid)).field('id,filename').select()
num = len(backups) - int(count)
if num > 0:
for backup in backups:
mw.execShell("rm -f " + backup['filename'])
mw.M('backup').where('id=?', (backup['id'],)).delete()
num -= 1
print("|---已清理过期备份文件:" + backup['filename'])
if num < 1:
break
def backupDatabaseAll(self, save):
db_path = mw.getServerDir() + '/mysql-ya'
db_name = 'mysql'
databases = mw.M('databases').dbPos(
db_path, db_name).field('name').select()
for database in databases:
self.backupDatabase(database['name'], save)
if __name__ == "__main__":
backup = backupTools()
type = sys.argv[1]
if type == 'database':
if sys.argv[2] == 'ALL':
backup.backupDatabaseAll(sys.argv[3])
else:
backup.backupDatabase(sys.argv[2], sys.argv[3])
-119
View File
@@ -1,119 +0,0 @@
# -*- coding: utf-8 -*-
#!/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.7.html
#https://dev.mysql.com/downloads/file/?id=489855
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
_os=`uname`
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
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
OSNAME='rhel'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
OSNAME='aliyun'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then
OSNAME='amazon'
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'
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
OSNAME='deepin'
else
OSNAME='unknow'
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
YUM_INSTALL()
{
#######
#http://repo.mysql.com/
if [ "${OSNAME}" == "centos" ] && [ "${VERSION_ID}" -le "7" ] ;then
wget -O /tmp/mysql57-community-release-el${VERSION_ID}.rpm http://repo.mysql.com/mysql57-community-release-el${VERSION_ID}.rpm
rpm -ivh /tmp/mysql57-community-release-el${VERSION_ID}.rpm
yum -y install mysql-server
rm -rf /tmp/mysql57-community-release-el${VERSION_ID}.rpm
fi
#######
}
YUM_UNINSTALL()
{
### YUM卸载 START ########
yum remove -y mysql-server
### YUM卸载 END ########
}
Install_mysql()
{
echo '正在安装脚本文件...' > $install_tmp
if id mysql &> /dev/null ;then
echo "mysql UID is `id -u mysql`"
echo "mysql Shell is `grep "^mysql:" /etc/passwd |cut -d':' -f7 `"
else
groupadd mysql
useradd -g mysql mysql
fi
isYum=`which yum`
if [ "$isYum" != "" ];then
YUM_INSTALL
fi
if [ "$?" == "0" ];then
mkdir -p $serverPath/mysql-yum
echo '5.7' > $serverPath/mysql-yum/version.pl
echo '安装完成' > $install_tmp
else
echo "暂时不支持该系统" > $install_tmp
fi
}
Uninstall_mysql()
{
isYum=`which yum`
if [ "$isYum" != "" ];then
YUM_UNINSTALL
fi
rm -rf $serverPath/mysql-yum
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_mysql
else
Uninstall_mysql
fi
-121
View File
@@ -1,121 +0,0 @@
# -*- coding: utf-8 -*-
#!/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.7.html
#https://dev.mysql.com/downloads/file/?id=489855
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
_os=`uname`
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
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
OSNAME='rhel'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
OSNAME='aliyun'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then
OSNAME='amazon'
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'
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
OSNAME='deepin'
else
OSNAME='unknow'
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
YUM_INSTALL()
{
#######
if [ "${OSNAME}" == "centos" ];then
wget -O /tmp/mysql80-community-release.rpm http://repo.mysql.com/mysql80-community-release-el${VERSION}.rpm
else
wget -O /tmp/mysql80-community-release.rpm http://repo.mysql.com/mysql80-community-release-el8.rpm
fi
rpm -ivh /tmp/mysql80-community-release.rpm
yum -y install mysql-server
rm -rf /tmp/mysql80-community-release.rpm
#######
}
YUM_UNINSTALL()
{
### YUM卸载 START ########
yum -y remove mysql-server
### YUM卸载 END ########
}
Install_mysql()
{
echo '正在安装脚本文件...' > $install_tmp
if id mysql &> /dev/null ;then
echo "mysql UID is `id -u mysql`"
echo "mysql Shell is `grep "^mysql:" /etc/passwd |cut -d':' -f7 `"
else
groupadd mysql
useradd -g mysql mysql
fi
isYum=`which yum`
if [ "$isYum" != "" ];then
YUM_INSTALL
fi
if [ "$?" == "0" ];then
mkdir -p $serverPath/mysql-yum
echo '8.0' > $serverPath/mysql-yum/version.pl
echo '安装完成' > $install_tmp
else
echo "暂时不支持该系统" > $install_tmp
fi
}
Uninstall_mysql()
{
isYum=`which yum`
if [ "$isYum" != "" ];then
YUM_UNINSTALL
fi
rm -rf $serverPath/mysql-ya
echo '卸载完成' > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_mysql
else
Uninstall_mysql
fi
+2 -5
View File
@@ -57,10 +57,7 @@ fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
VERSION=8.0.29
VERSION=8.0.28
Install_mysql()
{
mkdir -p ${mysqlDir}
@@ -114,7 +111,7 @@ Install_mysql()
fi
#检测文件是否损坏.
md5_mysql_ok=42fbfe0569089c20f9aa457b3f367d50
md5_mysql_ok=362b8141ecaf425b803fe55292e2df98
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
+7 -2
View File
@@ -901,8 +901,11 @@ def getWafConf():
return mw.readFile(conf)
def getWafSite():
return ''
def installPreInspection():
check_op = mw.getServerDir() + "/openresty"
if not os.path.exists(check_op):
return "请先安装OpenResty"
return 'ok'
if __name__ == "__main__":
@@ -917,6 +920,8 @@ if __name__ == "__main__":
print(restart())
elif func == 'reload':
print(reload())
elif func == 'install_pre_inspection':
print(installPreInspection())
elif func == 'conf':
print(getConf())
elif func == 'get_rule':
+4
View File
@@ -18,9 +18,13 @@ Install_of(){
echo '0.1' > $serverPath/op_waf/version.pl
echo 'install ok' > $install_tmp
cd ${rootPath} && python3 plugins/op_waf/index.py start
}
Uninstall_of(){
cd ${rootPath} && python3 plugins/op_waf/index.py stop
rm -rf $serverPath/op_waf
}
+6
View File
@@ -296,6 +296,10 @@ def errorLogPath():
return getServerDir() + '/nginx/logs/error.log'
def installPreInspection():
return 'ok'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -314,6 +318,8 @@ if __name__ == "__main__":
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'install_pre_inspection':
print(installPreInspection())
elif func == 'conf':
print(getConf())
elif func == 'get_os':
+3 -2
View File
@@ -5,12 +5,13 @@
"type":"其他插件",
"ps":"轻量级,占有内存少,并发能力强",
"shell":"install.sh",
"install_pre_inspection":true,
"checks":"server/openresty",
"path":"server/openresty",
"author":"agentzh",
"home":"http://openresty.org",
"date":"2017-11-24",
"pid": "1",
"versions": ["1.15.8.3","1.17.8.2","1.19.3.1","1.21.4.1"],
"updates": ["1.15.8.3","1.17.8.2","1.19.3.1","1.21.4.1"]
"versions": ["1.17.8.2","1.19.3.1","1.21.4.1"],
"updates": ["1.17.8.2","1.19.3.1","1.21.4.1"]
}
+3 -17
View File
@@ -15,9 +15,7 @@
{
"name": "mysqlnd",
"versions": [
"53",
"54",
"56",
"74",
"80",
"81",
"82"
@@ -30,9 +28,7 @@
{
"name": "oci8",
"versions": [
"53",
"54",
"56",
"74",
"80",
"81",
"82"
@@ -45,9 +41,7 @@
{
"name": "odbc",
"versions": [
"53",
"54",
"56",
"74",
"80",
"81",
"82"
@@ -101,14 +95,6 @@
{
"name": "opcache",
"versions": [
"53",
"54",
"55",
"56",
"70",
"71",
"72",
"73",
"74",
"80",
"81",
+10 -1
View File
@@ -1,9 +1,18 @@
[
{
"version": "0.9.9",
"content": "* 目标版本。",
},
{
"version": "0.9.2",
"content": "* 批量域名添加修复。<br/> * 常用命令说明。",
"path": "https://github.com/midoks/mdserver-web/releases/download/0.9.2/mdserver-web.zip"
},
{
"version": "0.9.1",
"content": "* 菜单修复。<br/> * 更新修复",
"path": "https://github.com/midoks/mdserver-web/releases/download/0.9.1/mdserver-web.zip",
"purge":"https://purge.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh",
"purge":"https://purge.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh"
},
{
"version": "0.9.0",