pull/368/head
midoks 2 years ago
parent 7198a4de95
commit a9fb6c9ec9
  1. 7
      plugins/memcached/index.py
  2. 4
      plugins/migration_api/index.html
  3. 202
      plugins/migration_api/index.py
  4. 4
      plugins/migration_api/info.json
  5. 12
      plugins/migration_api/js/app.js
  6. 7
      plugins/redis/index.py
  7. 7
      plugins/webhook/index.py
  8. 7
      plugins/webssh/index.py
  9. 4
      requirements.txt

@ -62,13 +62,16 @@ def getArgs():
if args_len == 1: if args_len == 1:
t = args[0].strip('{').strip('}') t = args[0].strip('{').strip('}')
t = t.split(':') if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
elif args_len > 1: elif args_len > 1:
for i in range(len(args)): for i in range(len(args)):
t = args[i].split(':') t = args[i].split(':')
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
return tmp return tmp

@ -223,8 +223,7 @@ label.checkbox_label span {
<div class="step_content"> <div class="step_content">
<div class="pd15 psync_info"> <div class="pd15 psync_info">
<div class="psync_tips"> <div class="psync_tips">
<span class="glyphicon glyphicon-alert" style="color: #f39c12; margin-right: 10px;"></span>只需在发送数据服务器安装本软件,请填写<span>『 接收数据服务器 』</span>资料, <span class="glyphicon glyphicon-alert" style="color: #f39c12; margin-right: 10px;"></span>只需在发送数据服务器安装本软件,请填写<span>『 接收数据服务器 』</span>资料。
<a href="#" class="btlink" style="text-decoration:underline;" target="_blank">迁移教程</a>
<a href="#" target="_blank" class="bt-ico-ask" style="cursor: pointer;">?</a> <a href="#" target="_blank" class="bt-ico-ask" style="cursor: pointer;">?</a>
</div> </div>
<div class="mtb20"> <div class="mtb20">
@ -287,7 +286,6 @@ label.checkbox_label span {
<script type="text/javascript"> <script type="text/javascript">
$.getScript( "/plugins/file?name=migration_api&f=js/app.js", function(){ $.getScript( "/plugins/file?name=migration_api&f=js/app.js", function(){
// pluginService('migration_api',$('.plugin_version').attr('version'));
initStep(); initStep();
}); });
</script> </script>

@ -33,26 +33,17 @@ def getInitDFile():
def getConf(): def getConf():
path = getServerDir() + "/init.d/memcached" path = getServerDir() + "/ma.cfg"
return path return path
def getConfEnv(): def getCfgData():
path = getServerDir() + "/memcached.env" path = getConf()
return path if not os.path.exists(path):
mw.writeFile(path, '{}')
def getConfTpl():
path = getPluginDir() + "/init.d/memcached.tpl"
return path
def getMemPort(): t = mw.returnJson(path)
path = getServerDir() + '/memcached.env' return json.loads(t)
content = mw.readFile(path)
rep = 'PORT\s*=\s*(\d*)'
tmp = re.search(rep, content)
return tmp.groups()[0]
def getArgs(): def getArgs():
@ -62,13 +53,16 @@ def getArgs():
if args_len == 1: if args_len == 1:
t = args[0].strip('{').strip('}') t = args[0].strip('{').strip('}')
t = t.split(':') if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
elif args_len > 1: elif args_len > 1:
for i in range(len(args)): for i in range(len(args)):
t = args[i].split(':') t = args[i].split(':')
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
return tmp return tmp
@ -84,163 +78,15 @@ def status():
def initDreplace(): def initDreplace():
file_tpl = getConfTpl()
service_path = mw.getServerDir()
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/memcached'
if not os.path.exists(file_bin):
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
# systemd
systemDir = mw.systemdCfgDir()
systemService = systemDir + '/memcached.service'
systemServiceTpl = getPluginDir() + '/init.d/memcached.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')
envFile = getServerDir() + '/memcached.env'
if not os.path.exists(envFile):
wbody = "IP=127.0.0.1\n"
wbody = wbody + "PORT=11211\n"
wbody = wbody + "USER=root\n"
wbody = wbody + "MAXCONN=1024\n"
wbody = wbody + "CACHESIZE=1024\n"
wbody = wbody + "OPTIONS=''\n"
mw.writeFile(envFile, wbody)
return file_bin
def memOp(method):
file = initDreplace()
if not mw.isAppleSystem():
data = mw.execShell('systemctl ' + method + ' ' + getPluginName())
if data[1] == '':
return 'ok'
return data[1]
data = mw.execShell(file + ' ' + method)
if data[1] == '':
return 'ok'
return data[1]
def start():
return memOp('start')
def stop():
return memOp('stop')
def restart():
return memOp('restart')
def reload():
return memOp('reload')
def runInfo():
# 获取memcached状态
import telnetlib
import re
port = getMemPort()
try:
tn = telnetlib.Telnet('127.0.0.1', int(port))
tn.write(b"stats\n")
tn.write(b"quit\n")
data = tn.read_all()
if type(data) == bytes:
data = data.decode('utf-8')
data = data.replace('STAT', '').replace('END', '').split("\n")
result = {}
res = ['cmd_get', 'get_hits', 'get_misses', 'limit_maxbytes', 'curr_items', 'bytes',
'evictions', 'limit_maxbytes', 'bytes_written', 'bytes_read', 'curr_connections']
for d in data:
if len(d) < 3:
continue
t = d.split()
if not t[0] in res:
continue
result[t[0]] = int(t[1])
result['hit'] = 1
if result['get_hits'] > 0 and result['cmd_get'] > 0:
result['hit'] = float(result['get_hits']) / \
float(result['cmd_get']) * 100
conf = mw.readFile(getServerDir() + '/memcached.env')
result['bind'] = re.search('IP=(.+)', conf).groups()[0]
result['port'] = int(re.search('PORT=(\d+)', conf).groups()[0])
result['maxconn'] = int(re.search('MAXCONN=(\d+)', conf).groups()[0])
result['cachesize'] = int(
re.search('CACHESIZE=(\d+)', conf).groups()[0])
return mw.getJson(result)
except Exception as e:
return mw.getJson({})
def saveConf():
args = getArgs()
data = checkArgs(args, ['ip', 'port', 'maxconn', 'maxsize'])
if not data[0]:
return data[1]
envFile = getServerDir() + '/memcached.env'
wbody = "IP=" + args['ip'] + "\n"
wbody = wbody + "PORT=" + args['port'] + "\n"
wbody = wbody + "USER=root\n"
wbody = wbody + "MAXCONN=" + args['maxconn'] + "\n"
wbody = wbody + "CACHESIZE=" + args['maxconn'] + "\n"
wbody = wbody + "OPTIONS=''\n"
mw.writeFile(envFile, wbody)
restart()
return 'save ok'
def initdStatus():
if mw.isAppleSystem():
return "Apple Computer does not support"
shell_cmd = 'systemctl status ' + \
getPluginName() + ' | grep loaded | grep "enabled;"'
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
return 'ok' return 'ok'
def initdInstall(): def stepOne():
if mw.isAppleSystem(): data = getCfgData()
return "Apple Computer does not support" print(data)
mw.execShell('systemctl enable ' + getPluginName())
return 'ok'
return mw.returnJson(True, 'ok')
def initdUinstall():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
mw.execShell('systemctl disable ' + getPluginName())
return 'ok'
if __name__ == "__main__": if __name__ == "__main__":
func = sys.argv[1] func = sys.argv[1]
@ -250,21 +96,7 @@ if __name__ == "__main__":
print(start()) print(start())
elif func == 'stop': elif func == 'stop':
print(stop()) print(stop())
elif func == 'restart': elif func == 'step_one':
print(restart())
elif func == 'reload':
print(reload())
elif func == 'initd_status':
print(initdStatus())
elif func == 'initd_install':
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'run_info':
print(runInfo())
elif func == 'conf_env':
print(getConfEnv())
elif func == 'save_conf':
print(saveConf()) print(saveConf())
else: else:
print('error') print('error')

@ -1,8 +1,8 @@
{ {
"sort": 7, "sort": 7,
"ps": "一键迁移", "ps": "[<span style='color:red;'>潜龙勿用</span>]一键迁移,仅网站数据和MySQL数据",
"name": "migration_api", "name": "migration_api",
"title": "一键迁移", "title": "一键迁移API",
"shell": "install.sh", "shell": "install.sh",
"versions":["1.0"], "versions":["1.0"],
"updates":["1.0"], "updates":["1.0"],

@ -58,11 +58,23 @@ function maPostCallbak(method, args, callback){
} }
function initStep1(){
maPost('step_one',{}, function(rdata){
console.log(rdata);
});
}
function initStep(){ function initStep(){
console.log($('.infoNext'));
$('.infoNext').click(function(){ $('.infoNext').click(function(){
var step = $('.step_head .active span').text(); var step = $('.step_head .active span').text();
console.log(step); console.log(step);
initStep1();
switch(step){
'1':initStep1();break;
'2':initStep2();break;
}
}); });
} }

@ -54,13 +54,16 @@ def getArgs():
if args_len == 1: if args_len == 1:
t = args[0].strip('{').strip('}') t = args[0].strip('{').strip('}')
t = t.split(':') if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
elif args_len > 1: elif args_len > 1:
for i in range(len(args)): for i in range(len(args)):
t = args[i].split(':') t = args[i].split(':')
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
return tmp return tmp

@ -34,13 +34,16 @@ def getArgs():
if args_len == 1: if args_len == 1:
t = args[0].strip('{').strip('}') t = args[0].strip('{').strip('}')
t = t.split(':') if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
elif args_len > 1: elif args_len > 1:
for i in range(len(args)): for i in range(len(args)):
t = args[i].split(':') t = args[i].split(':')
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
return tmp return tmp

@ -43,13 +43,16 @@ class App():
if args_len == 1: if args_len == 1:
t = args[0].strip('{').strip('}') t = args[0].strip('{').strip('}')
t = t.split(':') if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
elif args_len > 1: elif args_len > 1:
for i in range(len(args)): for i in range(len(args)):
t = args[i].split(':') t = args[i].split(':')
tmp[t[0]] = t[1] tmp[t[0]] = t[1]
return tmp return tmp
def checkArgs(self, data, ck=[]): def checkArgs(self, data, ck=[]):

@ -14,7 +14,7 @@ psutil==5.9.1
chardet==3.0.4 chardet==3.0.4
flask-sqlalchemy==2.3.2 flask-sqlalchemy==2.3.2
pyOpenSSL==22.0.0 pyOpenSSL==22.0.0
cryptography==36.0.1 cryptography==39.0.1
configparser==5.2.0 configparser==5.2.0
python-engineio==4.3.2 python-engineio==4.3.2
python-socketio>=4.2.0 python-socketio>=4.2.0
@ -28,4 +28,4 @@ Jinja2>=2.11.2
flask-caching>=1.10.1 flask-caching>=1.10.1
bcrypt==3.1.3 bcrypt==3.1.3
PyMySQL==1.0.2 PyMySQL==1.0.2
whitenoise==5.3.0 whitenoise==5.3.0

Loading…
Cancel
Save