mirror of https://github.com/midoks/mdserver-web
pull/109/head
parent
7c6ecf2bc3
commit
1ef8fc4f4d
After Width: | Height: | Size: 463 B |
@ -0,0 +1,24 @@ |
||||
<div class="bt-form"> |
||||
<div class="bt-w-main"> |
||||
<div class="bt-w-menu"> |
||||
<p class="bgw" onclick="pluginService('clean');">服务</p> |
||||
<p onclick="pluginConfig('clean');">配置修改</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"> |
||||
pluginService('clean'); |
||||
|
||||
|
||||
function pRead(){ |
||||
var readme = '<ul class="help-info-text c7">'; |
||||
readme += '<li>python3 /www/server/mdserver-web/clean/index.py clean</li>'; |
||||
readme += '</ul>'; |
||||
|
||||
$('.soft-man-con').html(readme); |
||||
} |
||||
</script> |
@ -0,0 +1,113 @@ |
||||
# coding:utf-8 |
||||
|
||||
import sys |
||||
import io |
||||
import os |
||||
import time |
||||
|
||||
sys.path.append(os.getcwd() + "/class/core") |
||||
import mw |
||||
|
||||
app_debug = False |
||||
if mw.isAppleSystem(): |
||||
app_debug = True |
||||
|
||||
|
||||
def getPluginName(): |
||||
return 'clean' |
||||
|
||||
|
||||
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() + "/clean.conf" |
||||
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 status(): |
||||
if os.path.exists(getConf()): |
||||
return "start" |
||||
return 'stop' |
||||
|
||||
|
||||
def start(): |
||||
file = initDreplace() |
||||
data = mw.execShell(file + ' start') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return 'fail' |
||||
|
||||
|
||||
def stop(): |
||||
file = initDreplace() |
||||
data = mw.execShell(file + ' stop') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return 'fail' |
||||
|
||||
|
||||
def reload(): |
||||
file = initDreplace() |
||||
data = mw.execShell(file + ' reload') |
||||
if data[1] == '': |
||||
return 'ok' |
||||
return 'fail' |
||||
|
||||
|
||||
def cleanLog(): |
||||
# 清理日志 |
||||
rootDir = "/var/log" |
||||
print("clean start") |
||||
mw.execShell("rm -rf /var/log/cron-*") |
||||
mw.execShell("rm -rf /var/log/maillog-*") |
||||
mw.execShell("rm -rf /var/log/secure-*") |
||||
mw.execShell("rm -rf /var/log/spooler-*") |
||||
print("clean end") |
||||
|
||||
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(getConf()) |
||||
elif func == 'clean': |
||||
cleanLog() |
||||
else: |
||||
print('error') |
@ -0,0 +1,16 @@ |
||||
{ |
||||
"title":"日志清理", |
||||
"tip":"soft", |
||||
"name":"clean", |
||||
"type":"运行环境", |
||||
"ps":"日志清理", |
||||
"versions":"1.0", |
||||
"updates":"1.0", |
||||
"shell":"install.sh", |
||||
"checks":"server/clean", |
||||
"path": "server/clean", |
||||
"author":"clean", |
||||
"home":"https://github.com/midoks", |
||||
"date":"2021-11-23", |
||||
"pid": "4" |
||||
} |
@ -0,0 +1,39 @@ |
||||
#!/bin/bash |
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
||||
export PATH |
||||
|
||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 5.0.4 |
||||
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 5.0.4 |
||||
|
||||
curPath=`pwd` |
||||
rootPath=$(dirname "$curPath") |
||||
rootPath=$(dirname "$rootPath") |
||||
serverPath=$(dirname "$rootPath") |
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl |
||||
VERSION=$2 |
||||
|
||||
|
||||
Install_app() |
||||
{ |
||||
echo '正在安装脚本文件...' > $install_tmp |
||||
mkdir -p $serverPath/clean |
||||
|
||||
echo "" > $serverPath/clean/clean.conf |
||||
|
||||
echo "${VERSION}" > $serverPath/clean/version.pl |
||||
echo '安装完成' > $install_tmp |
||||
} |
||||
|
||||
Uninstall_app() |
||||
{ |
||||
rm -rf $serverPath/clean |
||||
echo "Uninstall_clean" > $install_tmp |
||||
} |
||||
|
||||
action=$1 |
||||
if [ "${1}" == 'install' ];then |
||||
Install_app |
||||
else |
||||
Uninstall_app |
||||
fi |
Loading…
Reference in new issue