-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #405 from midoks/dev
0.14.2
- Loading branch information
Showing
25 changed files
with
1,330 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,3 +177,5 @@ debug.out | |
|
||
|
||
|
||
mdioks.session-journal | ||
*.session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(''); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.