diff --git a/class/core/plugin_api.py b/class/core/plugin_api.py index 9b9fa53cf..a610e98ff 100755 --- a/class/core/plugin_api.py +++ b/class/core/plugin_api.py @@ -87,6 +87,7 @@ class plugin_api: def getVersion(self, path): version_f = path + '/version.pl' + print version_f if os.path.exists(version_f): return public.readFile(version_f).strip() return '' @@ -151,7 +152,7 @@ class plugin_api: pluginInfo['setup_version'] = info['versions'] else: pluginInfo['setup_version'] = self.getVersion( - pluginInfo['path']) + pluginInfo['install_checks']) # pluginInfo['status'] = os.path.exists(pluginInfo['install_checks']) return pluginInfo diff --git a/plugins/openresty/index.html b/plugins/openresty/index.html index cf0b57f1b..6d79dac18 100755 --- a/plugins/openresty/index.html +++ b/plugins/openresty/index.html @@ -1,550 +1,16 @@ - - -
-

密钥

-

面板设置

-

面板登录日志

-

SSH设置

-

SSH日志管理

+

服务

+

配置修改

+

负载状态

-
-

- 密钥: - -

- -
    -
  • 宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存
  • -
  • 一但密钥丢失,可能导致您无法登录服务器
  • -
-
- - - - +
-
- \ No newline at end of file diff --git a/plugins/openresty/index.py b/plugins/openresty/index.py new file mode 100755 index 000000000..c52f6bd6e --- /dev/null +++ b/plugins/openresty/index.py @@ -0,0 +1,59 @@ +# coding:utf-8 + +import sys +import io +import os +import time + +sys.path.append(os.getcwd() + "/class/core") +import public + + +def status(): + data = public.execShell( + "ps -ef|grep openresty |grep -v grep | grep -v python | awk '{print $2}'") + if data[0] == '': + return 'stop' + return 'start' + + +def start(): + path = os.path.dirname(os.getcwd()) + cmd = path + "/openresty/bin/openresty -c " + cmd = cmd + path + "/openresty/nginx/conf/nginx.conf" + data = public.execShell(cmd) + if data[0] == '': + return 'ok' + return 'fail' + + +def stop(): + path = os.path.dirname(os.getcwd()) + cmd = path + "/openresty/bin/openresty -s stop" + data = public.execShell(cmd) + if data[0] == '': + return 'ok' + return 'fail' + + +def reload(): + path = os.path.dirname(os.getcwd()) + cmd = path + "/openresty/bin/openresty -s reload" + data = public.execShell(cmd) + if data[0] == '': + return 'ok' + return 'fail' + + +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print status() + elif func == 'start': + print start() + elif func == 'stop': + print stop() + elif func == 'reload': + print reload() + else: + print 'error' diff --git a/plugins/openresty/js/openresty.js b/plugins/openresty/js/openresty.js index 7532bd8ae..e676177eb 100755 --- a/plugins/openresty/js/openresty.js +++ b/plugins/openresty/js/openresty.js @@ -246,7 +246,11 @@ function addWafKey(name) { //查看Nginx负载状态 -function GetNginxStatus() { +function getStatus() { + + $.post('/plugins/run', {name:'openresty', func:'run_status'}, function(data) { + console.log(data); + },'json'); $.post('/ajax?action=GetNginxStatus', '', function(rdata) { var con = "
\ \ @@ -258,5 +262,73 @@ function GetNginxStatus() { \
" + lan.bt.nginx_active + "" + rdata.active + "
" + lan.bt.nginx_waiting + "" + rdata.Waiting + "
"; $(".soft-man-con").html(con); + },'json'); +} + +function openrestyOp(a, b) { + + var c = "name=" + a + "&func=" + b; + var d = ""; + + switch(b) { + case "stop":d = '停止';break; + case "start":d = '启动';break; + case "restart":d = '重启';break; + case "reload":d = '重载';break; + } + layer.confirm( '您真的要{1}{2}服务吗?'.replace('{1}', d).replace('{2}', a), {icon:3,closeBtn: 2}, function() { + var e = layer.msg('正在{1}{2}服务,请稍候...'.replace('{1}', d).replace('{2}', a), {icon: 16,time: 0}); + $.post("/plugins/run", c, function(g) { + layer.close(e); + + var f = g.data == 'ok' ? '{1}服务已{2}'.replace('{1}', a).replace('{2}', d):'{1}服务{2}失败!'.replace('{1}', a).replace('{2}', d); + layer.msg(f, {icon: g.data == 'ok' ? 1 : 2}); + + if(b != "reload" && g.data == 'ok') { + if (b == 'start') { + setRedisService('redis', true); + } else if (b=='stop'){ + setRedisService('redis', false); + } else { + } + } + if(g.data != 'ok') { + layer.msg(g.data, {icon: 2,time: 0,shade: 0.3,shadeClose: true}); + } + },'json').error(function() { + layer.close(e); + layer.msg('操作成功!', {icon: 1}); + }); }) -} \ No newline at end of file +} + +//服务 +function setOpenrestyService(name, status){ + var serviceCon ='

当前状态:'+(status ? '开启' : '关闭' )+ + '

\ + \ + \ + \ +
'; + $(".soft-man-con").html(serviceCon); +} + +//服务 +function openrestyService(){ + + $.post('/plugins/run', {name:'openresty', func:'status'}, function(data) { + console.log(data); + if(!data.status){ + layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']}); + return; + } + if (data.data == 'start'){ + setOpenrestyService('openresty', true); + } else { + setOpenrestyService('openresty', false); + } + },'json'); +} +openrestyService(); diff --git a/plugins/openresty/versions/1.11.2/install.sh b/plugins/openresty/versions/1.11.2/install.sh index 262a7a300..f5400ee7d 100755 --- a/plugins/openresty/versions/1.11.2/install.sh +++ b/plugins/openresty/versions/1.11.2/install.sh @@ -24,7 +24,7 @@ Install_openresty() cd ${openrestyDir}/openresty* && ./configure --prefix=$serverPath/openresty \ --with-openssl=$serverPath/source/lib/openssl-1.0.2q && make && make install - echo '1.11.2' > ${openrestyDir}/version.pl + echo '1.11.2' > $serverPath/openresty/version.pl echo '安装完成' > $install_tmp } diff --git a/plugins/openresty/versions/1.13.6/install.sh b/plugins/openresty/versions/1.13.6/install.sh index 1ad1d40fb..969fff1d9 100755 --- a/plugins/openresty/versions/1.13.6/install.sh +++ b/plugins/openresty/versions/1.13.6/install.sh @@ -24,8 +24,7 @@ Install_openresty() cd ${openrestyDir}/openresty* && ./configure --prefix=$serverPath/openresty \ --with-openssl=$serverPath/source/lib/openssl-1.0.2q && make && make install - echo - + echo '1.13.6' > $serverPath/openresty/version.pl echo '安装完成' > $install_tmp } diff --git a/plugins/readme/index.html b/plugins/readme/index.html index d98b5fd06..a0e4c13a3 100755 --- a/plugins/readme/index.html +++ b/plugins/readme/index.html @@ -2,9 +2,10 @@

INFO说明

+

index.py说明

-
+

在每一个插件中,都必须包含一个info.json文件,格式如下:


{
 "title": "插件开发说明",
@@ -21,16 +22,23 @@
 "date": "2018-11-30",
 "pid": "5"
 }
+
- - - +
+

在每一个插件中,都必须包含一个index.py文件


\ No newline at end of file diff --git a/plugins/redis/install.sh b/plugins/redis/install.sh index 611954653..5806472eb 100755 --- a/plugins/redis/install.sh +++ b/plugins/redis/install.sh @@ -16,24 +16,24 @@ Install_redis() echo '正在安装脚本文件...' > $install_tmp - wget -O $serverPath/tmp/redis.tar.gz http://download.redis.io/releases/redis-4.0.11.tar.gz - cd $serverPath/tmp && tar -zxvf redis.tar.gz + wget -O $serverPath/source/redis.tar.gz http://download.redis.io/releases/redis-4.0.11.tar.gz + cd $serverPath/source && tar -zxvf redis.tar.gz mkdir -p $serverPath/redis cd redis* && make PREFIX=$serverPath/redis install sed '/^ *#/d' redis.conf > $serverPath/redis/redis.conf - echo '安装完成' > $install_tmp + echo '4.0' > serverPath/redis/version.pl - rm -rf $serverPath/tmp + echo '安装完成' > $install_tmp } Uninstall_redis() { - echo "Uninstall_redis" + rm -rf $serverPath/redis + echo "Uninstall_redis" > $install_tmp } - action=$1 if [ "${1}" == 'install' ];then Install_redis diff --git a/route/plugins.py b/route/plugins.py index 4c2444ae6..8957818cc 100644 --- a/route/plugins.py +++ b/route/plugins.py @@ -127,7 +127,7 @@ def uninstall(): return public.returnJson(True, '已将卸载任务添加到队列!') -@plugins.route('/installed', methods=['POST']) +@plugins.route('/find', methods=['POST']) def installed(): rundir = public.getRunDir() diff --git a/static/js/public.js b/static/js/public.js index b432c3f0a..665b27d08 100755 --- a/static/js/public.js +++ b/static/js/public.js @@ -860,7 +860,7 @@ function GetTaskList(a) { }) } -function GetTaskCount() { +function getTaskCount() { $.get("/task/count", "", function(a) { $(".task").text(a) }) diff --git a/static/js/soft.js b/static/js/soft.js index a33f0df58..bcd06ab90 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -140,18 +140,12 @@ function getSList(isdisplay) { if (plugin.setup == true) { - // if (plugin.tip == 'lib') { - // var mupdate = (plugin.versions[n].no == plugin.versions[n].version) ? '' : '更新 | '; - // handle = mupdate + '' + lan.soft.setup + ' | 卸载'; - // titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"'; - // } else { - - var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; - // if (plugin.versions[n] == '') mupdate = ''; - handle = mupdate + '安装 | 卸载'; - titleClick = 'onclick="softMain(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"'; - // } + var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; + // if (plugin.versions[n] == '') mupdate = ''; + handle = mupdate + '设置 | 卸载'; + titleClick = 'onclick="softMain(\'' + plugin.name + '\',\'' + version_info + '\')" style="cursor:pointer"'; + softPath = ''; if (plugin.coexist){ indexshow = '
'; @@ -180,6 +174,7 @@ function getSList(isdisplay) { plugin_title = plugin.title + ' ' + plugin.setup_version; } + console.log(plugin_title); sBody += '' + '' + handle + '' + ''; } - sBody += pBody; $("#softList").html(sBody); @@ -204,26 +198,6 @@ function getSList(isdisplay) { },'json'); } -//更新 -function softUpdate(name, version, update) { - var msg = "
  • 建议您在服务器负载闲时进行软件更新.
  • "; - if (name == 'mysql') msg = ""; - SafeMessage('更新[' + name + ']', '更新过程可能会导致服务中断,您真的现在就将[' + name + ']更新到[' + update + ']吗?', function() { - var data = "name=" + name + "&version=" + version + "&type=0&upgrade=" + update; - var loadT = layer.msg('正在更新[' + name + '-' + version + '],请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post('/plugins/install', data, function(rdata) { - if (rdata.status) { - GetTaskCount(); - layer.msg('已添加到任务列表,请稍候...', { icon: 1 }); - } else { - layer.msg('更新失败!', { icon: 2 }); - } - - layer.close(loadT); - }); - }, msg); -} - function addVersion(name, ver, type, obj, title) { var option = ''; var titlename = name; @@ -405,6 +379,6 @@ function indexSoft() { // $(function() { // if (window.document.location.pathname == '/soft/') { -// setInterval(function() { getSList(true); }, 5000); +// setInterval(function() { getSList(); }, 5000); // } // }); \ No newline at end of file