diff --git a/plugins/webhook/index.py b/plugins/webhook/index.py index a2fe7a073..106da859b 100755 --- a/plugins/webhook/index.py +++ b/plugins/webhook/index.py @@ -122,7 +122,7 @@ def getLog(): logPath = args['path'] - content = mw.getLastLine(logPath, 100) + content = mw.getLastLine(logPath, 16) return mw.returnJson(True, 'ok', content) @@ -132,11 +132,16 @@ def runShellArgs(args): if data[i]['access_key'] == args['access_key']: script_dir = getServerDir() + "/scripts" shellFile = script_dir + '/' + args['access_key'] - param = '' - if hasattr(args, 'param'): - param = args['param'] - os.system("bash {} \"{}\" >> {}.log &".format( - shellFile, param.replace('"', r'\"'), shellFile)) + param = args['params'] + if param == '': + param = 'no-parameters' + + param = re.sub("\"", '', param) + + cmd = "bash {} {} >> {}.log 2>&1 &".format( + shellFile, param, shellFile) + # print(cmd) + os.system(cmd) data[i]['count'] += 1 data[i]['uptime'] = int(time.time()) mw.writeFile(getCfgFilePath(), json.dumps(data)) @@ -150,6 +155,7 @@ def runShell(): if not check_arg[0]: return check_arg[1] + args['params'] = 'panel-test' return runShellArgs(args) diff --git a/plugins/webhook/js/webhook.js b/plugins/webhook/js/webhook.js index dbe6167f2..231219989 100755 --- a/plugins/webhook/js/webhook.js +++ b/plugins/webhook/js/webhook.js @@ -26,6 +26,32 @@ function whPost(method, args,callback){ },'json'); } + +function whPostNoMessage(method, args,callback){ + + var req_data = {}; + req_data['name'] = 'webhook'; + req_data['func'] = method; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(toArrayObject(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/run', req_data, function(data) {; + if (!data.status){ + //错误展示10S + layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + function whPostCallbak(method, version, args,callback){ var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); @@ -153,42 +179,60 @@ function showWebHookCode(url,code){