pull/109/head
Mr Chen 6 years ago
parent 39cc51ea3f
commit dc0405856c
  1. BIN
      plugins/go-fastdfs/ico.png
  2. 21
      plugins/go-fastdfs/index.html
  3. 266
      plugins/go-fastdfs/index.py
  4. 16
      plugins/go-fastdfs/info.json
  5. 78
      plugins/go-fastdfs/init.d/solr.tpl
  6. 51
      plugins/go-fastdfs/install.sh
  7. 192
      plugins/go-fastdfs/js/solr.js
  8. 2
      plugins/memcached/info.json
  9. 2
      plugins/mysql/info.json
  10. 2
      plugins/pureftp/info.json
  11. 2
      plugins/redis/info.json
  12. 2
      plugins/solr/info.json

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

@ -0,0 +1,21 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('solr');">服务</p>
<p onclick="pluginInitD('solr');">自启动</p>
<p onclick="collectionManagement();">管理</p>
<p onclick="pluginLogs('solr','','run_log');">日志</p>
<p onclick="pRead()">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=solr&f=js/solr.js", function() {
pluginService('solr');
});
</script>

@ -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:(.*)\}</int>"
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'

@ -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"
}

@ -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

@ -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

@ -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 += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
con += '<thead><tr>';
con += '<th>collection</th>';
con += '<th>操作(<a class="btlink" onclick="addCollection()">添加</a>)'+ '|'+ '<a class="btlink" target="_blank" href="http://'+rdata.data.ip+':'+rdata.data.port+'">WEB管理</a></th>';
con += '</tr></thead>';
con += '<tbody>';
for (var i = 0; i < list.length; i++) {
con += '<tr>'+
'<td>' + list[i]['name']+'</td>' +
'<td>\
<a class="btlink" onclick="cmdCollection(\''+list[i]['name']+'\')">命令</a> \
| <a class="btlink" onclick="confCollection(\''+list[i]['name']+'\')">配置</a> \
| <a class="btlink" onclick="removeCollection(\''+list[i]['name']+'\')">删除</a></td> \
</tr>';
}
con += '</tbody>';
con += '</table></div>';
$(".soft-man-con").html(con);
});
}
function addCollection(){
var loadOpen = layer.open({
type: 1,
title: '添加Collection',
area: '400px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='line'>\
<span class='tname'>Collection</span>\
<div class='info-r c4'>\
<input id='name' class='bt-input-text' type='text' name='name' placeholder='Collection' style='width:200px' />\
</div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='add_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>",
});
$('#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:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>你要确认要删除collection["+ name + "]</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='solr_del_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' id='solr_del_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#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 += '<button onclick="confFileCollection(\''+name+'\',\'solrconfig.xml\')" class="btn btn-default btn-sm">solrconfig.xml</button>';
html += '<button onclick="confFileCollection(\''+name+'\',\'managed-schema\')" class="btn btn-default btn-sm">managed-schema</button>';
var loadOpen = layer.open({
type: 1,
title: '['+name+']配置设置',
area: '240px',
content:'<div class="change-default pd20">'+html+'</div>'
});
}
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 = '<div class="change-default pd20"><table class="table table-hover">';
cmd += '<thead><tr><td>增量更新</td><td>curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=delta-import&wt=json&clean=false&commit=true"</td></tr>';
cmd += '<tr><td>权限更新</td><td>curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=full-import&wt=json&clean=false&commit=true"<td></tr>';
cmd += '<tr><td colspan="2">默认端口:8983(可修改),默认IP为本地,可修改。</td></tr></thead>';
cmd += '</table></div>';
layer.open({
type: 1,
title: '命令',
area: '750px',
content:cmd,
});
}
function pRead(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>使用默认solr端口,如有需要自行修改</li>';
readme += '<li>如果开启防火墙,需要放行solr设置的端口,例如(8983)</li>';
readme += '<li>数据源设置好后,需要在managed-schema中同时设置</li>';
readme += '<li><a target="_blank" href="https://github.com/midoks/mdserver-web/wiki/插件管理%5Bsolr使用说明%5D">wiki说明</a></li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}

@ -1,6 +1,6 @@
{
"sort": 7,
"ps": "Memcached 是一个高性能的分布式内存对象缓存系统",
"ps": "是一个高性能的分布式内存对象缓存系统",
"name": "memcached",
"title": "Memcached",
"shell": "install.sh",

@ -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"],

@ -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",

@ -1,6 +1,6 @@
{
"sort": 7,
"ps": "Redis 是一个高性能的KV数据库",
"ps": "一个高性能的KV数据库",
"name": "redis",
"title": "Redis",
"shell": "install.sh",

@ -4,7 +4,7 @@
"tip":"soft",
"name":"solr",
"type":"软件",
"ps":"Solr是一个独立的企业级搜索应用服务器",
"ps":"一个独立的企业级搜索应用服务器",
"versions":"8.2.0",
"shell":"install.sh",
"checks":"server/solr",

Loading…
Cancel
Save