mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-20 08:25:50 +08:00
up
This commit is contained in:
@@ -31,4 +31,19 @@ def list():
|
||||
clist = Crontab.query.paginate(page=int(page), per_page=size)
|
||||
# print(clist)
|
||||
|
||||
return []
|
||||
return []
|
||||
|
||||
|
||||
@blueprint.route('/add', endpoint='add', methods=['GET','POST'])
|
||||
@panel_login_required
|
||||
def add():
|
||||
page = request.args.get('p', 1)
|
||||
size = 10
|
||||
count = Crontab.query.count()
|
||||
# print(count)
|
||||
clist = Crontab.query.paginate(page=int(page), per_page=size)
|
||||
# print(clist)
|
||||
|
||||
return []
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import json
|
||||
from flask import Blueprint, render_template
|
||||
from flask import request
|
||||
|
||||
from utils.mwplugin import MwPlugin
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
from admin.user_login_check import panel_login_required
|
||||
|
||||
from admin import model
|
||||
|
||||
@@ -18,9 +18,11 @@ from flask import request
|
||||
from admin import model
|
||||
from admin.user_login_check import panel_login_required
|
||||
|
||||
|
||||
import core.mw as mw
|
||||
import utils.config as utils_config
|
||||
|
||||
|
||||
# 默认页面
|
||||
blueprint = Blueprint('setting', __name__, url_prefix='/setting', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@@ -218,12 +220,12 @@ def set_port():
|
||||
msg = mw.getInfo('放行端口[{1}]成功', (port,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
addtime = time.strftime('%Y-%m-%d %X', time.localtime())
|
||||
mw.M('firewall').add('port,ps,addtime', (port, "配置修改", addtime))
|
||||
mw.M('firewall').add('port,ps,add_time', (port, "配置修改", add_time))
|
||||
|
||||
# firewall_api.firewall_api().addAcceptPort(port)
|
||||
# firewall_api.firewall_api().firewallReload()
|
||||
|
||||
mw.restartMw()
|
||||
|
||||
return mw.returnJson(True, '端口保存成功!')
|
||||
return mw.returnData(True, '端口保存成功!')
|
||||
|
||||
@@ -16,7 +16,7 @@ from flask import request
|
||||
from admin.model import Sites
|
||||
from admin.user_login_check import panel_login_required
|
||||
|
||||
from utils.mwplugin import MwPlugin
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
import utils.site as site
|
||||
import core.mw as mw
|
||||
|
||||
|
||||
@@ -12,3 +12,4 @@ from .init import *
|
||||
from .option import *
|
||||
from .user import *
|
||||
from .sites import *
|
||||
from .tasks import *
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
def addTask(
|
||||
name: str | None = '常用任务',
|
||||
cmd: str | None = None,
|
||||
type: str | None = 'execshell',
|
||||
status: int | None = 0,
|
||||
):
|
||||
'''
|
||||
添加后台任务
|
||||
:name -> str 类型
|
||||
:cmd -> str 日志内容 (必填)
|
||||
:type -> str 用户ID
|
||||
'''
|
||||
if cmd is None:
|
||||
return False
|
||||
|
||||
add_time = mw.formatDate()
|
||||
insert_data = {
|
||||
'name':name,
|
||||
'type':type,
|
||||
'cmd':cmd,
|
||||
'start':0,
|
||||
'end':0,
|
||||
'status':status,
|
||||
'add_time':add_time,
|
||||
}
|
||||
mw.M('tasks').insert(insert_data)
|
||||
return True
|
||||
@@ -0,0 +1,9 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
@@ -230,7 +230,7 @@ class Firewall(object):
|
||||
if model.getFirewallCountByPort(port) > 0:
|
||||
return mw.returnData(False, '您要放行的端口已存在,无需重复放行!')
|
||||
|
||||
model.addFirewall(port,ps=ps,protocol=protocol)
|
||||
model.addFirewall(port, ps=ps,protocol=protocol)
|
||||
self.addAcceptPortCmd(port, protocol=protocol)
|
||||
self.reload()
|
||||
|
||||
|
||||
@@ -18,8 +18,9 @@ from admin import model
|
||||
|
||||
import core.mw as mw
|
||||
import admin.model.option as option
|
||||
import thisdb
|
||||
|
||||
class pa_thread(threading.Thread):
|
||||
class pg_thread(threading.Thread):
|
||||
|
||||
def __init__(self, func, args, name=''):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -34,7 +35,7 @@ class pa_thread(threading.Thread):
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
class MwPlugin(object):
|
||||
class plugin(object):
|
||||
|
||||
def_plugin_type = [
|
||||
{
|
||||
@@ -88,11 +89,11 @@ class MwPlugin(object):
|
||||
|
||||
@classmethod
|
||||
def instance(cls, *args, **kwargs):
|
||||
if not hasattr(MwPlugin, "_instance"):
|
||||
with MwPlugin._instance_lock:
|
||||
if not hasattr(MwPlugin, "_instance"):
|
||||
MwPlugin._instance = MwPlugin(*args, **kwargs)
|
||||
return MwPlugin._instance
|
||||
if not hasattr(plugin, "_instance"):
|
||||
with plugin._instance_lock:
|
||||
if not hasattr(plugin, "_instance"):
|
||||
plugin._instance = plugin(*args, **kwargs)
|
||||
return plugin._instance
|
||||
|
||||
"""插件类初始化"""
|
||||
def __init__(self):
|
||||
@@ -260,7 +261,7 @@ class MwPlugin(object):
|
||||
|
||||
self.hookInstall(info_data)
|
||||
title = '{0}[{1}-{2}]'.format(msg_head,name,version)
|
||||
model.addTask(name=title,cmd=exec_bash, status=0)
|
||||
thisdb.addTask(name=title,cmd=exec_bash, status=0)
|
||||
|
||||
# 调式日志
|
||||
mw.debugLog(exec_bash)
|
||||
@@ -494,7 +495,7 @@ class MwPlugin(object):
|
||||
threads = []
|
||||
ntmp_list = range(len(info))
|
||||
for i in ntmp_list:
|
||||
t = pa_thread(self.checkStatusThreads,(info[i], i))
|
||||
t = pg_thread(self.checkStatusThreads,(info[i], i))
|
||||
threads.append(t)
|
||||
|
||||
for i in ntmp_list:
|
||||
Reference in New Issue
Block a user