diff --git a/plugins/go-fastdfs/ico.png b/plugins/go-fastdfs/ico.png new file mode 100644 index 000000000..23f776333 Binary files /dev/null and b/plugins/go-fastdfs/ico.png differ diff --git a/plugins/go-fastdfs/index.html b/plugins/go-fastdfs/index.html new file mode 100755 index 000000000..576029102 --- /dev/null +++ b/plugins/go-fastdfs/index.html @@ -0,0 +1,21 @@ +
+
+
+

服务

+

自启动

+

管理

+

日志

+

说明

+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/plugins/go-fastdfs/index.py b/plugins/go-fastdfs/index.py new file mode 100755 index 000000000..5a54012cf --- /dev/null +++ b/plugins/go-fastdfs/index.py @@ -0,0 +1,266 @@ +# coding: utf-8 + +import time +import random +import os +import json +import re +import sys + +sys.path.append(os.getcwd() + "/class/core") +import public + +app_debug = False +if public.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'solr' + + +def getPluginDir(): + return public.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return public.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + if app_debug: + return '/tmp/' + getPluginName() + return '/etc/init.d/' + getPluginName() + + +def getInitDTpl(): + return getPluginDir() + "/init.d/" + getPluginName() + ".tpl" + + +def getLog(): + return getServerDir() + "/server/logs/solr.log" + + +def getArgs(): + args = sys.argv[2:] + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':') + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':') + tmp[t[0]] = t[1] + + return tmp + + +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, public.returnJson(True, 'ok')) + + +def status(): + pn = getPluginName() + data = public.execShell( + "ps -ef|grep " + pn + " |grep -v grep | grep -v python | awk '{print $2}'") + if data[0] == '': + return 'stop' + return 'start' + + +def initDreplace(): + + file_tpl = getInitDTpl() + service_path = os.path.dirname(os.getcwd()) + + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + + user = 'www' + if public.getOs() == 'darwin': + user = public.execShell( + "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + + file_bin = initD_path + '/' + getPluginName() + if not os.path.exists(file_bin): + content = public.readFile(file_tpl) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$RUN_USER}', user) + public.writeFile(file_bin, content) + public.execShell('chmod +x ' + file_bin) + + return file_bin + + +def start(): + file = initDreplace() + data = public.execShell(file + ' start') + if data[1] == '': + return 'ok' + return 'fail' + + +def stop(): + file = initDreplace() + data = public.execShell(file + ' stop') + if data[1] == '': + return 'ok' + return 'fail' + + +def restart(): + file = initDreplace() + data = public.execShell(file + ' restart') + if data[1] == '': + return 'ok' + return 'fail' + + +def reload(): + file = initDreplace() + data = public.execShell(file + ' reload') + if data[1] == '': + return 'ok' + return 'fail' + + +def initdStatus(): + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + return 'fail' + + +def initdInstall(): + import shutil + + source_bin = initDreplace() + initd_bin = getInitDFile() + shutil.copyfile(source_bin, initd_bin) + public.execShell('chmod +x ' + initd_bin) + + if not app_debug: + public.execShell('chkconfig --add ' + getPluginName()) + return 'ok' + + +def initdUinstall(): + if not app_debug: + public.execShell('chkconfig --del ' + getPluginName()) + + initd_bin = getInitDFile() + + if os.path.exists(initd_bin): + os.remove(initd_bin) + return 'ok' + + +def collectionList(): + path = getServerDir() + '/server/solr' + listDir = os.listdir(path) + data = {} + dlist = [] + for dirname in listDir: + dirpath = path + '/' + dirname + if not os.path.isdir(dirpath): + continue + if dirname == 'configsets': + continue + + tmp = {} + tmp['name'] = dirname + dlist.append(tmp) + data['list'] = dlist + data['ip'] = public.getLocalIp() + data['port'] = '8983' + + content = public.readFile(path+'/solr.xml') + + rep = "jetty.port:(.*)\}" + tmp = re.search(rep, content) + port = tmp.groups()[0] + data['port'] = port + + return public.returnJson(True, 'OK', data) + + +def addCollection(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + name = args['name'] + solr_bin = getServerDir() + "/bin/solr" + + retdata = public.execShell(solr_bin + ' create -c ' + name) + if retdata[1] != "": + return public.returnJson(False, '添加失败!:' + retdata[0]) + return public.returnJson(True, '添加成功!:' + retdata[0]) + + +def removeCollection(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + name = args['name'] + solr_bin = getServerDir() + "/bin/solr" + + retdata = public.execShell(solr_bin + ' delete -c ' + name) + if retdata[1] != "": + return public.returnJson(False, '添加失败!:' + retdata[0]) + return public.returnJson(True, '添加成功!:' + retdata[0]) + + +def confFileCollection(): + args = getArgs() + data = checkArgs(args, ['name']) + if not data[0]: + return data[1] + + conf_file = getServerDir() + "/server/solr/" + \ + args['name'] + "/conf/" + args['conf_file'] + # print conf_file + return public.returnJson(True, 'OK', {'path': conf_file}) + + +# rsyncdReceive +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print status() + elif func == 'start': + print start() + elif func == 'stop': + print stop() + elif func == 'restart': + 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_log': + print getLog() + elif func == 'collection_list': + print collectionList() + elif func == 'add_collection': + print addCollection() + elif func == 'remove_collection': + print removeCollection() + elif func == 'conf_file_collection': + print confFileCollection() + else: + print 'error' diff --git a/plugins/go-fastdfs/info.json b/plugins/go-fastdfs/info.json new file mode 100755 index 000000000..9870a8af9 --- /dev/null +++ b/plugins/go-fastdfs/info.json @@ -0,0 +1,16 @@ +{ + "id":10, + "title":"go-fastdfs", + "tip":"soft", + "name":"go-fastdfs", + "type":"软件", + "ps":"一个基于http协议的分布式文件系统", + "versions":"1.3.1", + "shell":"install.sh", + "checks":"server/go-fastdfs", + "path": "server/go-fastdfs", + "author":"midoks", + "home":"https://github.com/sjqzhang/go-fastdfs", + "date":"2019-08-02", + "pid":"2" +} \ No newline at end of file diff --git a/plugins/go-fastdfs/init.d/solr.tpl b/plugins/go-fastdfs/init.d/solr.tpl new file mode 100644 index 000000000..c2194130a --- /dev/null +++ b/plugins/go-fastdfs/init.d/solr.tpl @@ -0,0 +1,78 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +### BEGIN INIT INFO +# Provides: solr +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Description: Controls Apache Solr as a Service +### END INIT INFO + +# Example of a very simple *nix init script that delegates commands to the bin/solr script +# Typical usage is to do: +# +# cp bin/init.d/solr /etc/init.d/solr +# chmod 755 /etc/init.d/solr +# chown root:root /etc/init.d/solr +# update-rc.d solr defaults +# update-rc.d solr enable + +# Where you extracted the Solr distribution bundle +SOLR_INSTALL_DIR="{$SERVER_PATH}/solr" + +if [ ! -d "$SOLR_INSTALL_DIR" ]; then + echo "$SOLR_INSTALL_DIR not found! Please check the SOLR_INSTALL_DIR setting in your $0 script." + exit 1 +fi + +# Path to an include file that defines environment specific settings to override default +# variables used by the bin/solr script. It's highly recommended to define this script so +# that you can keep the Solr binary files separated from live files (pid, logs, index data, etc) +# see bin/solr.in.sh for an example +SOLR_ENV="{$SERVER_PATH}/solr/bin/solr.in.sh" + +if [ ! -f "$SOLR_ENV" ]; then + echo "$SOLR_ENV not found! Please check the SOLR_ENV setting in your $0 script." + exit 1 +fi + +# Specify the user to run Solr as; if not set, then Solr will run as root. +# Running Solr as root is not recommended for production environments +RUNAS="{$RUN_USER}" + +# verify the specified run as user exists +runas_uid="`id -u "$RUNAS"`" +if [ $? -ne 0 ]; then + echo "User $RUNAS not found! Please create the $RUNAS user before running this script." + exit 1 +fi + +case "$1" in + start|stop|restart|status) + SOLR_CMD="$1" + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit +esac + +if [ -n "$RUNAS" ]; then + sh -c "SOLR_INCLUDE=\"$SOLR_ENV\" \"$SOLR_INSTALL_DIR/bin/solr\" $SOLR_CMD" - "$RUNAS" +else + SOLR_INCLUDE="$SOLR_ENV" "$SOLR_INSTALL_DIR/bin/solr" "$SOLR_CMD" +fi diff --git a/plugins/go-fastdfs/install.sh b/plugins/go-fastdfs/install.sh new file mode 100755 index 000000000..a45cea07b --- /dev/null +++ b/plugins/go-fastdfs/install.sh @@ -0,0 +1,51 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` + +install_tmp=${rootPath}/tmp/mw_install.pl + +action=$1 +version=$2 +Install_solr() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/solr + SOLR_DIR=${serverPath}/source/solr + mkdir -p $SOLR_DIR + if [ ! -f ${SOLR_DIR}/solr-8.2.0.tgz ];then + wget -O ${SOLR_DIR}/solr-8.2.0.tgz http://mirror.bit.edu.cn/apache/lucene/solr/8.2.0/solr-8.2.0.tgz + fi + + if [ ! -d $serverPath/solr/bin ];then + cd ${SOLR_DIR} && tar -zxvf solr-8.2.0.tgz + cp -rf ${SOLR_DIR}/solr-8.2.0/ $serverPath/solr + fi + + if [ -d $serverPath/solr/dist ]; then + wget -O $serverPath/solr/dist/mysql-connector-java-5.1.48.jar http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar + wget -O $serverPath/solr/dist/mysql-connector-java-8.0.17.jar http://central.maven.org/maven2/mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar + fi + + echo "$version" > $serverPath/solr/version.pl + echo '安装完成' > $install_tmp + +} + +Uninstall_solr() +{ + rm -rf $serverPath/solr + echo "卸载完成" > $install_tmp +} + + +if [ "${1}" == 'install' ];then + Install_solr $version +else + Uninstall_solr $version +fi diff --git a/plugins/go-fastdfs/js/solr.js b/plugins/go-fastdfs/js/solr.js new file mode 100755 index 000000000..8b36e5ecb --- /dev/null +++ b/plugins/go-fastdfs/js/solr.js @@ -0,0 +1,192 @@ +function str2Obj(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; + } + return data; +} + +function pPost(method,args,callback, title){ + + var _args = null; + if (typeof(args) == 'string'){ + _args = JSON.stringify(str2Obj(args)); + } else { + _args = JSON.stringify(args); + } + + var _title = '正在获取...'; + if (typeof(title) != 'undefined'){ + _title = title; + } + + var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'solr', func:method, args:_args}, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + + +function collectionManagement(){ + pPost('collection_list', '', function(data){ + var rdata = $.parseJSON(data.data); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); + return; + } + + var list = rdata.data.list; + var con = ''; + con += '
'; + con += ''; + con += ''; + con += ''; + con += ''; + + con += ''; + + for (var i = 0; i < list.length; i++) { + con += ''+ + '' + + ' \ + '; + } + + con += ''; + con += '
collection操作(添加)'+ '|'+ 'WEB管理
' + list[i]['name']+'\ + 命令 \ + | 配置 \ + | 删除
'; + + $(".soft-man-con").html(con); + }); +} + + +function addCollection(){ + var loadOpen = layer.open({ + type: 1, + title: '添加Collection', + area: '400px', + content:"
\ +
\ + Collection\ +
\ + \ +
\ +
\ +
\ + \ +
\ +
", + }); + + $('#add_ok').click(function(){ + _data = {}; + _data['name'] = $('#name').val(); + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + pPost('add_collection', _data, function(data){ + var rdata = $.parseJSON(data.data); + layer.close(loadOpen); + layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); + setTimeout(function(){collectionManagement();},2000); + }); + }); +} + +function removeCollection(name){ + var loadOpen = layer.open({ + type: 1, + title: '删除用户', + area: '350px', + content:"
\ +
你要确认要删除collection["+ name + "]
\ +
\ + \ + \ +
\ +
" + }); + + $('#solr_del_close').click(function(){ + layer.close(loadOpen); + }); + + $('#solr_del_ok').click(function(){ + var _data = {}; + _data['name'] = name; + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + _data = {}; + _data['name'] = name; + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + pPost('remove_collection', _data, function(data){ + var rdata = $.parseJSON(data.data); + layer.close(loadOpen); + layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']}); + setTimeout(function(){collectionManagement();},2000); + }); + }); +} + + +function confCollection(name){ + var html = ''; + html += ''; + html += ''; + + var loadOpen = layer.open({ + type: 1, + title: '['+name+']配置设置', + area: '240px', + content:'
'+html+'
' + }); +} + +function confFileCollection(name, conf_file){ + pPost('conf_file_collection', {'name':name, 'conf_file':conf_file}, function(data){ + var rdata = $.parseJSON(data.data); + if (rdata['status']){ + onlineEditFile(0, rdata['data']['path']); + } else { + layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']}); + } + }); +} + + +function cmdCollection(name){ + var cmd = '
'; + cmd += ''; + cmd += ''; + cmd += ''; + cmd += '
增量更新curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=delta-import&wt=json&clean=false&commit=true"
权限更新curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=full-import&wt=json&clean=false&commit=true"
默认端口:8983(可修改),默认IP为本地,可修改。
'; + + layer.open({ + type: 1, + title: '命令', + area: '750px', + content:cmd, + }); +} + +function pRead(){ + var readme = ''; + + $('.soft-man-con').html(readme); +} \ No newline at end of file diff --git a/plugins/memcached/info.json b/plugins/memcached/info.json index c0df0b735..f8383836e 100755 --- a/plugins/memcached/info.json +++ b/plugins/memcached/info.json @@ -1,6 +1,6 @@ { "sort": 7, - "ps": "Memcached 是一个高性能的分布式内存对象缓存系统", + "ps": "是一个高性能的分布式内存对象缓存系统", "name": "memcached", "title": "Memcached", "shell": "install.sh", diff --git a/plugins/mysql/info.json b/plugins/mysql/info.json index b25e3ba79..7051b9406 100755 --- a/plugins/mysql/info.json +++ b/plugins/mysql/info.json @@ -3,7 +3,7 @@ "tip":"soft", "name":"mysql", "type":"运行环境", - "ps":"MySQL是一种关系数据库管理系统!", + "ps":"一种关系数据库管理系统!", "todo_versions":["5.6","5.7","8.0"], "versions":["5.5"], "updates":["5.5.62"], diff --git a/plugins/pureftp/info.json b/plugins/pureftp/info.json index a9efa1414..9b6821ce0 100755 --- a/plugins/pureftp/info.json +++ b/plugins/pureftp/info.json @@ -2,7 +2,7 @@ "title":"PureFtpd", "tip":"soft", "name":"pureftp", - "ps":"PureFTPd是一款免费FTP服务器软件", + "ps":"一款免费FTP服务器软件", "versions": "1.0.47", "shell":"install.sh", "checks":"server/pureftp", diff --git a/plugins/redis/info.json b/plugins/redis/info.json index e9a70d269..938076319 100755 --- a/plugins/redis/info.json +++ b/plugins/redis/info.json @@ -1,6 +1,6 @@ { "sort": 7, - "ps": "Redis 是一个高性能的KV数据库", + "ps": "一个高性能的KV数据库", "name": "redis", "title": "Redis", "shell": "install.sh", diff --git a/plugins/solr/info.json b/plugins/solr/info.json index 201017635..16ae21d24 100755 --- a/plugins/solr/info.json +++ b/plugins/solr/info.json @@ -4,7 +4,7 @@ "tip":"soft", "name":"solr", "type":"软件", - "ps":"Solr是一个独立的企业级搜索应用服务器", + "ps":"一个独立的企业级搜索应用服务器", "versions":"8.2.0", "shell":"install.sh", "checks":"server/solr",