Skip to content

Commit

Permalink
Merge pull request #310 from midoks/dev
Browse files Browse the repository at this point in the history
0.12.0
  • Loading branch information
midoks authored Dec 21, 2022
2 parents b64f02f + 5a11d1b commit 975cb98
Show file tree
Hide file tree
Showing 75 changed files with 1,406 additions and 699 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Debian x, Centos x, Centos x stream, Ubuntu x?

Ex:
```bash
................start mw success
bash: line 149: ./scripts/init.d/mw: No such file or directory
一个issue,一个问题。多余问题,视情况而答。
```

## 错误截图 ?
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.11.4
### 版本更新 0.12.0

* PHP82正式释出。
* PHP-fileinfo扩展优化。
* 删除任务时删除日志。
* 优化修改密码后的显示问题(#288)。
此次版本:默认面板名为【大圣面板】。
由于#309问题。先注释。提前发版。

* 安装脚本优化 @hiCasper
* 数据库[pg/apt/yum/mariadb]计划任务备份ok。
* php源码加入sodium扩展。
* 站点分类问题 #300


### JSDelivr安装地址
Expand Down Expand Up @@ -161,7 +164,7 @@ wget -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/s
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh | bash
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/install_dev.sh | bash
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/install_dev.sh | bash
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash
```

Expand Down
11 changes: 10 additions & 1 deletion class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class config_api:

__version = '0.11.4'
__version = '0.12.0'
__api_addr = 'data/api.json'

def __init__(self):
Expand Down Expand Up @@ -730,4 +730,13 @@ def get(self):
data['username'] = mw.M('users').where(
"id=?", (1,)).getField('username')

# databases hook 获取
database_file = 'data/hook_database.json'
if os.path.exists(database_file):
df = mw.readFile(database_file)
df = json.loads(df)
data['hook_database'] = df
else:
data['hook_database'] = []

return data
69 changes: 47 additions & 22 deletions class/core/crontab_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def listApi(self):
rdata['list'] = mw.getPage(_page)
rdata['p'] = p

# backup hock
# backup hook
bh_file = mw.getPanelDataDir() + "/hook_backup.json"
if os.path.exists(bh_file):
hb_data = mw.readFile(bh_file)
Expand Down Expand Up @@ -131,7 +131,7 @@ def getCrondFindApi(self):
# 参数校验
def cronCheck(self, params):

if params['stype'] == 'site' or params['stype'] == 'database' or params['stype'] == 'logs':
if params['stype'] == 'site' or params['stype'] == 'database' or params['stype'].find('database_') > -1 or params['stype'] == 'logs' or params['stype'] == 'path':
if params['save'] == '':
return False, '保留份数不能为空!'

Expand Down Expand Up @@ -230,8 +230,8 @@ def modifyCrondApi(self):
cronInfo['sbody'] = get['sbody']
cronInfo['urladdress'] = get['urladdress']

addData = mw.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to,sbody,urladdress', (get[
'name'], field_type, get['where1'], get['hour'], get['minute'], get['save'], get['backup_to'], get['sbody'], get['urladdress']))
addData = mw.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to, sname, sbody,urladdress',
(iname, field_type, get['where1'], get['hour'], get['minute'], get['save'], get['backup_to'], sname, get['sbody'], get['urladdress']))
self.removeForCrond(cronInfo['echo'])
self.syncToCrond(cronInfo)
mw.writeLog('计划任务', '修改计划任务[' + cronInfo['name'] + ']成功')
Expand Down Expand Up @@ -377,28 +377,46 @@ def getDataListApi(self):
stype = request.form.get('type', '')

bak_data = []

if stype == 'sites' or stype == 'databases':
if stype == 'site' or stype == 'sites' or stype == 'database' or stype.find('database_') > -1 or stype == 'path':
hookPath = mw.getPanelDataDir() + "/hook_backup.json"
if os.path.exists(hookPath):
t = mw.readFile(hookPath)
bak_data = json.loads(t)

if stype == 'databases':
if stype == 'database' or stype.find('database_') > -1:
sqlite3_name = 'mysql'
path = mw.getServerDir() + '/mysql'
if stype != 'database':
soft_name = stype.replace('database_', '')
path = mw.getServerDir() + '/' + soft_name

if soft_name == 'postgresql':
sqlite3_name = 'pgsql'

db_list = {}
db_list['orderOpt'] = bak_data
path = mw.getServerDir() + '/mysql'
if not os.path.exists(path + '/mysql.db'):

if not os.path.exists(path + '/' + sqlite3_name + '.db'):
db_list['data'] = []
else:
db_list['data'] = mw.M('databases').dbPos(
path, 'mysql').field('name,ps').select()
path, sqlite3_name).field('name,ps').select()
return mw.getJson(db_list)

if stype == 'path':
db_list = {}
db_list['data'] = [{"name": mw.getWwwDir(), "ps": "www"}]
db_list['orderOpt'] = bak_data
return mw.getJson(db_list)

data = {}
data['orderOpt'] = bak_data

data['data'] = mw.M(stype).field('name,ps').select()
default_db = 'sites'
# if stype == 'site' or stype == 'logs':
# stype == 'sites'

data['data'] = mw.M(default_db).field('name,ps').select()
return mw.getJson(data)
##### ----- start ----- ###

Expand Down Expand Up @@ -495,13 +513,19 @@ def getShell(self, param):
MW_PATH=%s/bin/activate
if [ -f $MW_PATH ];then
source $MW_PATH
fi
''' % (mw.getRunDir(),)
fi''' % (mw.getRunDir(),)

head = head + source_bin_activate + "\n"
log = '.log'

script_dir = mw.getServerDir() + "/mdserver-web/scripts"
script_dir = mw.getRunDir() + "/scripts"
source_stype = 'database'
if stype.find('database_') > -1:
plugin_name = stype.replace('database_', '')
script_dir = mw.getRunDir() + "/plugins/" + plugin_name + "/scripts"

source_stype = stype
stype = 'database'

wheres = {
'path': head + "python3 " + script_dir + "/backup.py path " + param['sname'] + " " + str(param['save']),
Expand All @@ -513,13 +537,14 @@ def getShell(self, param):
if param['backup_to'] != 'localhost':
cfile = mw.getPluginDir() + "/" + \
param['backup_to'] + "/index.py"
wheres = {
'path': head + "python3 " + cfile + " path " + param['sname'] + " " + str(param['save']),
'site': head + "python3 " + cfile + " site " + param['sname'] + " " + str(param['save']),
'database': head + "python3 " + cfile + " database " + param['sname'] + " " + str(param['save']),
'logs': head + "python3 " + script_dir + "/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
'rememory': head + "/bin/bash " + script_dir + '/rememory.sh'
}

wheres['path'] = head + "python3 " + cfile + \
" path " + param['sname'] + " " + str(param['save'])
wheres['site'] = head + "python3 " + cfile + \
" site " + param['sname'] + " " + str(param['save'])
wheres['database'] = head + "python3 " + cfile + " " + \
source_stype + " " + \
param['sname'] + " " + str(param['save'])
try:
shell = wheres[stype]
except:
Expand Down Expand Up @@ -583,9 +608,9 @@ def writeShell(self, config):
# 重载配置
def crondReload(self):
if mw.isAppleSystem():
# mw.execShell('/usr/sbin/cron restart')
if os.path.exists('/etc/crontab'):
pass
# mw.execShell('/usr/sbin/cron restart')
else:
if os.path.exists('/etc/init.d/crond'):
mw.execShell('/etc/init.d/crond reload')
Expand Down
12 changes: 6 additions & 6 deletions class/core/firewall_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ def setFw(self, status):
elif self.__isMac:
pass
else:
mw.execShell('/etc/init.d/iptables save')
mw.execShell('/etc/init.d/iptables stop')
mw.execShell('service iptables save')
mw.execShell('service iptables stop')
else:
if self.__isUfw:
mw.execShell("echo 'y'| ufw enable")
Expand All @@ -363,8 +363,8 @@ def setFw(self, status):
elif self.__isMac:
pass
else:
mw.execShell('/etc/init.d/iptables save')
mw.execShell('/etc/init.d/iptables restart')
mw.execShell('service iptables save')
mw.execShell('service iptables restart')

return mw.returnData(True, '设置成功!')

Expand Down Expand Up @@ -437,8 +437,8 @@ def firewallReload(self):
elif self.__isMac:
pass
else:
mw.execShell('/etc/init.d/iptables save')
mw.execShell('/etc/init.d/iptables restart')
mw.execShell('service iptables save')
mw.execShell('service iptables restart')

def getFwStatus(self):
if self.__isUfw:
Expand Down
23 changes: 22 additions & 1 deletion class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ def makeConf():
file = getRunDir() + '/data/json/config.json'
if not os.path.exists(file):
c = {}
c['title'] = '猫王面板'
c['title'] = '大圣面板'
c['home'] = 'http://github/midoks/mdserver-web'
c['recycle_bin'] = True
c['template'] = 'default'
Expand Down Expand Up @@ -1453,3 +1453,24 @@ def getMyORMDb():
import ormDb
o = ormDb.ORM()
return o

# ---------------------------------------------------------------------------------
# 打印相关
# ---------------------------------------------------------------------------------


def echoStart(tag):
print("=" * 90)
print("★开始{}[{}]".format(tag, formatDate()))
print("=" * 90)


def echoEnd(tag):
print("=" * 90)
print("☆{}完成[{}]".format(tag, formatDate()))
print("=" * 90)
print("\n")


def echoInfo(msg):
print("|-{}".format(msg))
4 changes: 2 additions & 2 deletions class/core/plugins_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def hookInstall(self, info):
if 'hook' in info:
hooks = info['hook']
for x in hooks:
if x in ['backup']:
if x in ['backup', 'database']:
self.hookInstallFile(x, info)
return True
return False
Expand All @@ -245,7 +245,7 @@ def hookUninstall(self, info):
if 'hook' in info:
hooks = info['hook']
for x in hooks:
if x in ['backup']:
if x in ['backup', 'database']:
self.hookUninstallFile(x, info)
return True
return False
Expand Down
49 changes: 26 additions & 23 deletions class/core/site_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def __init__(self):
def listApi(self):
limit = request.form.get('limit', '10')
p = request.form.get('p', '1')
type_id = request.form.get('type_id', '')
type_id = request.form.get('type_id', '0').strip()

start = (int(p) - 1) * (int(limit))

siteM = mw.M('sites')
if type_id != '' and type_id == '-1' and type_id == '0':
siteM.where('type_id=?', (type_id))
siteM = mw.M('sites').field('id,name,path,status,ps,addtime,edate')
if type_id != '' and int(type_id) >= 0:
siteM.where('type_id=?', (type_id,))

_list = siteM.field('id,name,path,status,ps,addtime,edate').limit(
(str(start)) + ',' + limit).order('id desc').select()
_list = siteM.limit((str(start)) + ',' +
limit).order('id desc').select()

for i in range(len(_list)):
_list[i]['backup_count'] = mw.M('backup').where(
Expand Down Expand Up @@ -140,6 +140,10 @@ def getDefaultSiteApi(self):
return mw.getJson(data)

def getCliPhpVersionApi(self):
php_dir = mw.getServerDir() + '/php'
if not os.path.exists(php_dir):
return mw.returnJson(False, '未安装PHP,无法设置')

php_bin = '/usr/bin/php'
php_versions = self.getPhpVersion()
php_versions = php_versions[1:]
Expand Down Expand Up @@ -840,18 +844,6 @@ def createLetApi(self):
'auth_to': auth_to,
}

import cert_api
data = cert_api.cert_api().applyCertApi(to_args)

if not data['status']:
msg = data['msg']
if type(data['msg']) != str:
msg = data['msg'][0]
emsg = data['msg'][1]['challenges'][0]['error']
msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
return mw.returnJson(data['status'], msg, data['msg'])

src_letpath = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
src_csrpath = src_letpath + "/fullchain.pem" # 生成证书路径
src_keypath = src_letpath + "/privkey.pem" # 密钥文件路径
Expand All @@ -860,11 +852,22 @@ def createLetApi(self):
dst_csrpath = dst_letpath + '/fullchain.pem'
dst_keypath = dst_letpath + '/privkey.pem'

if not os.path.exists(dst_letpath):
mw.execShell('mkdir -p ' + dst_letpath)
mw.buildSoftLink(src_csrpath, dst_csrpath, True)
mw.buildSoftLink(src_keypath, dst_keypath, True)
mw.execShell('echo "lets" > "' + dst_letpath + '/README"')
if not os.path.exists(src_letpath):
import cert_api
data = cert_api.cert_api().applyCertApi(to_args)
if not data['status']:
msg = data['msg']
if type(data['msg']) != str:
msg = data['msg'][0]
emsg = data['msg'][1]['challenges'][0]['error']
msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
return mw.returnJson(data['status'], msg, data['msg'])

mw.execShell('mkdir -p ' + dst_letpath)
mw.buildSoftLink(src_csrpath, dst_csrpath, True)
mw.buildSoftLink(src_keypath, dst_keypath, True)
mw.execShell('echo "lets" > "' + dst_letpath + '/README"')

# 写入配置文件
result = self.setSslConf(siteName)
Expand Down
6 changes: 4 additions & 2 deletions plugins/backup_ftp/class/ftp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ def get_config(self):
return default_config

def injection_config(self, data):
host = data["ftp_host"].strip()
self.__host = host = data["ftp_host"].strip()
if host.find(':') == -1:
self.__port = self.default_port
else:
self.__host = host.split(':')[0]
self.__port = host.split(':')[1]

self.__host = data['ftp_host'].strip()
self.__user = data['ftp_user'].strip()
self.__password = data['ftp_pass'].strip()
bp = data['backup_path'].strip()
Expand Down
Loading

0 comments on commit 975cb98

Please sign in to comment.