pull/504/head
Mr Chen 2 years ago
parent 5894323eec
commit 5e7e7af1a7
  1. 3
      plugins/lvs/index.html
  2. 75
      plugins/lvs/index.py
  3. 2
      plugins/lvs/info.json

@ -2,7 +2,8 @@
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('lvs');">服务</p>
<!-- <p onclick="pluginConfigTpl('lvs');">配置修改</p> -->
<p onclick="pluginInitD('lvs');">自启动</p>
<p onclick="pluginConfig('lvs');">配置修改</p>
<!-- <p onclick="pluginLogs('lvs','','run_log',30);">运行日志</p> -->
</div>
<div class="bt-w-con pd15">

@ -19,6 +19,9 @@ if mw.isAppleSystem():
def getPluginName():
return 'lvs'
def getIpvsadm():
return 'ipvsadm'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
@ -57,33 +60,9 @@ def checkArgs(data, ck=[]):
return (True, mw.returnJson(True, 'ok'))
def configTpl():
path = getPluginDir() + '/tpl'
pathFile = os.listdir(path)
tmp = []
for one in pathFile:
file = path + '/' + one
tmp.append(file)
return mw.getJson(tmp)
def readConfigTpl():
args = getArgs()
data = checkArgs(args, ['file'])
if not data[0]:
return data[1]
content = mw.readFile(args['file'])
content = contentReplace(content)
return mw.returnJson(True, 'ok', content)
def contentReplace(content):
service_path = mw.getServerDir()
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$SERVER_APP}', service_path + '/'+getPluginName())
return content
def getConf():
path = '/etc/default/ipvsadm'
return path
def status():
@ -133,6 +112,40 @@ def restart():
def reload():
return haOp('reload')
def initdStatus():
current_os = mw.getOs()
if current_os == 'darwin':
return "Apple Computer does not support"
if current_os.startswith('freebsd'):
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
shell_cmd = 'systemctl status ' + \
getPluginName() + ' | grep loaded | grep "enabled;"'
data = mw.execShell(shell_cmd)
if data[0] == '':
return 'fail'
return 'ok'
def initdInstall():
current_os = mw.getOs()
if current_os == 'darwin':
return "Apple Computer does not support"
mw.execShell('systemctl enable ' + getIpvsadm())
return 'ok'
def initdUinstall():
current_os = mw.getOs()
if current_os == 'darwin':
return "Apple Computer does not support"
mw.execShell('systemctl disable ' + getIpvsadm())
return 'ok'
def runLog():
path = getConf()
@ -155,5 +168,13 @@ if __name__ == "__main__":
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())
else:
print('error')

@ -1,6 +1,6 @@
{
"sort": 7,
"ps": "LVS超强负载均衡",
"ps": "LVS超强负载均衡,通过ipvsadm管理",
"name": "lvs",
"title": "LVS",
"shell": "install.sh",

Loading…
Cancel
Save