Skip to content

Commit

Permalink
Merge pull request #405 from midoks/dev
Browse files Browse the repository at this point in the history
0.14.2
  • Loading branch information
midoks authored May 2, 2023
2 parents cff1d5e + 9355433 commit fe04e02
Show file tree
Hide file tree
Showing 25 changed files with 1,330 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ debug.out



mdioks.session-journal
*.session
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.14.1
### 版本更新 0.14.2

* 安装优化。
* 加入OP负载均衡插件。
* 网站防篡改程序(测试中)。
* 加入TgClient插件
* 网站防篡改程序(测试中)
* Docker(测试中)

### JSDelivr安装地址

Expand Down
2 changes: 1 addition & 1 deletion class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class config_api:

__version = '0.14.1'
__version = '0.14.2'
__api_addr = 'data/api.json'

def __init__(self):
Expand Down
Binary file added plugins/docker/ico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions plugins/docker/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="bt-form">
<div class='plugin_version'></div>
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('docker');">服务</p>
<p onclick="pluginInitD('docker');">自启动</p>
<p onclick="dockerList();">容器列表</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
resetPluginWinHeight(400);
$.getScript( "/plugins/file?name=docker&f=js/docker.js", function(){
pluginService('docker', $('.plugin_version').attr('version'));
});
</script>
169 changes: 169 additions & 0 deletions plugins/docker/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# coding:utf-8

import sys
import io
import os
import time
import re

sys.path.append(os.getcwd() + "/class/core")
import mw

app_debug = False
if mw.isAppleSystem():
app_debug = True


def getPluginName():
return 'docker'


def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()


def getServerDir():
return mw.getServerDir() + '/' + getPluginName()


def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()


def getConf():
path = getServerDir() + "/redis.conf"
return path


def getConfTpl():
path = getPluginDir() + "/config/redis.conf"
return path


def getInitDTpl():
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
return path


def getArgs():
args = sys.argv[3:]
tmp = {}
args_len = len(args)

if args_len == 1:
t = args[0].strip('{').strip('}')
if t.strip() == '':
tmp = []
else:
t = t.split(':')
tmp[t[0]] = t[1]
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 status():
data = mw.execShell(
"ps -ef|grep dockerd |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")

if data[0] == '':
return 'stop'
return 'start'


def initDreplace():
return ''


def dockerOp(method):
file = initDreplace()

if not mw.isAppleSystem():
data = mw.execShell('systemctl ' + method + ' docker')
if data[1] == '':
return 'ok'
return data[1]
return 'fail'


def start():
return dockerOp('start')


def stop():
return dockerOp('stop')


def restart():
status = dockerOp('restart')

log_file = runLog()
mw.execShell("echo '' > " + log_file)
return status


def reload():
return dockerOp('reload')


def initdStatus():
if mw.isAppleSystem():
return "Apple Computer does not support"

shell_cmd = 'systemctl status ' + \
getPluginName() + ' | grep loaded | grep "enabled;"'
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
return 'ok'


def initdInstall():
if mw.isAppleSystem():
return "Apple Computer does not support"

mw.execShell('systemctl enable ' + getPluginName())
return 'ok'


def initdUinstall():
if mw.isAppleSystem():
return "Apple Computer does not support"

mw.execShell('systemctl disable ' + getPluginName())
return 'ok'


def runLog():
return getServerDir() + '/data/redis.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 == 'initd_status':
print(initdStatus())
elif func == 'initd_install':
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'conf':
print(getConf())
elif func == 'run_log':
print(runLog())
else:
print('error')
18 changes: 18 additions & 0 deletions plugins/docker/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"sort": 7,
"ps": "Docker 是一个开源的应用容器引擎(开发测试中)",
"name": "docker",
"title": "Docker",
"shell": "install.sh",
"versions":["1.0"],
"updates":["1.0"],
"tip": "soft",
"checks": "server/docker",
"path": "server/docker",
"display": 1,
"author": "Zend",
"date": "2017-04-01",
"home": "https://docker.io",
"type": 0,
"pid": "2"
}
77 changes: 77 additions & 0 deletions plugins/docker/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/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")

# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh uninstall 1.0
# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh install 1.0

install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=$2

Install_Docker()
{
which docker
if [ "$?" == "0" ];then
echo '安装已经完成docker' > $install_tmp
exit 0
fi

echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source

if [ ! -d $serverPath/docker ];then
curl -fsSL https://get.docker.com | bash
mkdir -p $serverPath/docker
fi

if [ -d $serverPath/docker ];then
echo "${VERSION}" > $serverPath/docker/version.pl
echo '安装完成' > $install_tmp

cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py initd_install
fi
}

Uninstall_Docker()
{
CMD=yum
which apt
if [ "$?" == "0" ];then
CMD=apt
fi

if [ -f /usr/lib/systemd/system/docker.service ];then
systemctl stop docker
systemctl disable docker
rm -rf /usr/lib/systemd/system/docker.service
systemctl daemon-reload
fi

$CMD remove -y docker docker-ce-cli containerd.io
# docker-client \
# docker-client-latest \
# docker-common \
# docker-latest \
# docker-latest-logrotate \
# docker-logrotate \
# docker-selinux \
# docker-engine-selinux \
# docker-engine \
# docker-ce

rm -rf $serverPath/docker
echo "Uninstall_Docker" > $install_tmp
}

action=$1
if [ "${1}" == 'install' ];then
Install_Docker
else
Uninstall_Docker
fi
60 changes: 60 additions & 0 deletions plugins/docker/js/docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
function dPost(method, version, args,callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });

var req_data = {};
req_data['name'] = 'docker';
req_data['func'] = method;
req_data['version'] = version;

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) {
layer.close(loadT);
if (!data.status){
//错误展示10S
layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']});
return;
}

if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}

function dPostCallbak(method, version, args,callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });

var req_data = {};
req_data['name'] = 'docker';
req_data['func'] = method;
args['version'] = version;

if (typeof(args) == 'string'){
req_data['args'] = JSON.stringify(toArrayObject(args));
} else {
req_data['args'] = JSON.stringify(args);
}

$.post('/plugins/callback', req_data, 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 dockerList(){
$(".soft-man-con").html('');
}


2 changes: 1 addition & 1 deletion plugins/tgbot/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"install_pre_inspection":true,
"uninstall_pre_inspection":true,
"display": 1,
"author": "midokos",
"author": "midoks",
"date": "2023-03-06",
"home": "https://core.telegram.org/bots/api",
"depend_doc1":"https://github.com/eternnoir/pyTelegramBotAPI",
Expand Down
Loading

0 comments on commit fe04e02

Please sign in to comment.