midoks 3 years ago
parent 9e855e9318
commit a0771d202a
  1. BIN
      plugins/zimg/ico.png
  2. 19
      plugins/zimg/index.html
  3. 189
      plugins/zimg/index.py
  4. 15
      plugins/zimg/info.json
  5. 50
      plugins/zimg/init.d/zimg.tpl
  6. 100
      plugins/zimg/install.sh
  7. 92
      plugins/zimg/js/zimg.js

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,19 +0,0 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('zimg');">服务</p>
<p onclick="pluginInitD('zimg');">自启动</p>
<p onclick="pluginConfig('zimg');">配置修改</p>
<p onclick="pluginLogs('zimg','','run_log');">运行日志</p>
<p onclick="readme();">说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
$.getScript( "/plugins/file?name=zimg&f=js/zimg.js", function(){
pluginService('zimg');
});
</script>

@ -1,189 +0,0 @@
# coding:utf-8
import sys
import io
import os
import time
import shutil
import subprocess
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'zimg'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDTpl():
path = getPluginDir() + "/init.d/zimg.tpl"
return path
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 initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
file_bin = initD_path + '/' + getPluginName()
if not os.path.exists(initD_path):
os.mkdir(initD_path)
# initd replace
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
return file_bin
def checkArgs(data, ck=[]):
for i in range(len(ck)):
if not ck[i] in data:
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok'))
def status():
cmd = "ps -ef|grep zimg |grep -v grep | grep -v 'mdserver-web'| awk '{print $2}'"
data = mw.execShell(cmd)
if data[0] == '':
return 'stop'
return 'start'
def start():
file = initDreplace()
data = mw.execShell(file + ' start')
if data[1] == '':
return 'ok'
return data[1]
def stop():
file = initDreplace()
data = mw.execShell(file + ' stop')
# print data
if data[1] == '':
return 'ok'
return data[1]
def restart():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return data[1]
def reload():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return data[1]
def getPathFile():
return getServerDir() + '/bin/conf/zimg.lua'
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def initdStatus():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
def initdInstall():
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
mw.execShell('chmod +x ' + initd_bin)
if not app_debug:
mw.execShell('chkconfig --add ' + getPluginName())
return 'ok'
def initdUinstall():
if not app_debug:
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
os.remove(initd_bin)
return 'ok'
def getLog():
return getServerDir() + '/bin/log/zimg.log'
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 == 'conf':
print(getPathFile())
elif func == 'initd_status':
print(initdStatus())
elif func == 'initd_install':
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'run_log':
print(getLog())
else:
print('error')

@ -1,15 +0,0 @@
{
"title":"zimg",
"tip":"soft",
"name":"zimg",
"type":"其他插件",
"ps":"轻量级图片服务器软件",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/zimg",
"path": "server/zimg",
"author":"midoks",
"home":"https://github.com/buaazp/zimg",
"date":"2021-04-13",
"pid": "5"
}

@ -1,50 +0,0 @@
#!/bin/sh
# chkconfig: 2345 55 25
# description: zimg Service
### BEGIN INIT INFO
# Provides: zimg
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts zimg
# Description: starts the MDW-Web
### END INIT INFO
app_start(){
# aria2c -D
cd {$SERVER_PATH}/zimg/bin
./zimg -d {$SERVER_PATH}/zimg/bin/conf/zimg.lua </dev/null &>/dev/null
echo "zimg started"
}
app_stop(){
echo "Stopping ..."
arr=`ps -ef | grep "zimg" | grep -v 'grep' | grep -v '/bin/sh'|grep -v 'index.py' | awk '{print $2}'`
echo $arr
for p in ${arr[@]}
do
kill -9 $p &>/dev/null
done
echo "zimg stopped"
}
case "$1" in
start)
app_start
;;
stop)
app_stop
;;
restart|reload)
app_stop
sleep 0.3
app_start
;;
*)
echo "Please use start or stop as first argument"
;;
esac

@ -1,100 +0,0 @@
#!/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")
zimgSourceDir=${serverPath}/source/zimg
install_tmp=${rootPath}/tmp/mw_install.pl
sysName=`uname`
echo "use system: ${sysName}"
if [ ${sysName} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
# install package
if [ "${OSNAME}" == "centos" ] || [ "${OSNAME}" == "fedora" ]; then
yum install nasm -y
fi
if [ "${OSNAME}" == "debian" ] || [ "${OSNAME}" == "ubuntu" ]; then
apt install nasm -y
fi
Install_libjpeg_turbo(){
mkdir -p $zimgSourceDir/libjpeg-turbo
cd $zimgSourceDir/libjpeg-turbo
if [ ! -d $zimgSourceDir/libjpeg-turbo ];then
wget https://downloads.sourceforge.net/project/libjpeg-turbo/1.3.1/libjpeg-turbo-1.3.1.tar.gz
tar zxvf libjpeg-turbo-1.3.1.tar.gz
cd libjpeg-turbo-1.3.1
./configure --prefix=/usr/local --with-jpeg8
make && make install
fi
}
Install_zimg_source(){
mkdir -p $zimgSourceDir
cd $zimgSourceDir
if [ ! -d $zimgSourceDir/zimg ];then
git clone https://github.com/buaazp/zimg -b master --depth=1
cd zimg
make
fi
if [ -f $zimgSourceDir/zimg/bin/zimg ];then
cp -r $zimgSourceDir/zimg/bin $serverPath/zimg
fi
}
Install_zimg()
{
isStart=""
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/zimg
echo '1.0' > $serverPath/zimg/version.pl
if [ "macos" == "${OSNAME}" ];then
echo 'macosx unavailable' > $install_tmp
else
if [ ! -f $serverPath/zimg/bin ];then
Install_libjpeg_turbo
Install_zimg_source
fi
fi
echo 'Install complete' > $install_tmp
}
Uninstall_zimg()
{
rm -rf $serverPath/zimg
echo "Uninstall completed" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_zimg
else
Uninstall_zimg
fi

@ -1,92 +0,0 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function lpPost(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:'aria2', 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 lpAsyncPost(method,args){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
} else {
_args = JSON.stringify(args);
}
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
return syncPost('/plugins/run', {name:'l2tp', func:method, args:_args});
}
function userList(){
lpPost('user_list', '' ,function(data){
var rdata = $.parseJSON(data['data']);
if (!rdata['status']){
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
var list = rdata['data'];
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>用户</th>';
con += '<th>密码</th>';
con += '<th>操作(<a class="btlink" onclick="addUser()">添加</a>)</th>';
con += '</tr></thead>';
con += '<tbody>';
for (var i = 0; i < list.length; i++) {
con += '<tr>'+
'<td>' + list[i]['user']+'</td>' +
'<td>' + list[i]['pwd']+'</td>' +
'<td><a class="btlink" onclick="modUser(\''+list[i]['user']+'\')">改密</a>|<a class="btlink" onclick="delUser(\''+list[i]['user']+'\')">删除</a></td></tr>';
}
con += '</tbody>';
con += '</table></div>';
$(".soft-man-con").html(con);
});
}
function readme(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>使用时,查看对应的端口</li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}
Loading…
Cancel
Save