Update index.py

pull/618/head
Mr Chen 10 months ago
parent 7bf0611d67
commit 7fa0200889
  1. 49
      plugins/zabbix/index.py

@ -131,50 +131,11 @@ def initDreplace():
file_tpl = getInitDTpl()
service_path = os.path.dirname(os.getcwd())
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
file_bin = initD_path + '/' + getPluginName()
# initd replace
if not os.path.exists(file_bin):
content = mw.readFile(file_tpl)
content = content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(file_bin, content)
mw.execShell('chmod +x ' + file_bin)
# log
dataLog = getServerDir() + '/data'
if not os.path.exists(dataLog):
mw.execShell('chmod +x ' + file_bin)
# config replace
dst_conf = getServerDir() + '/redis.conf'
dst_conf_init = getServerDir() + '/init.pl'
if not os.path.exists(dst_conf_init):
conf_content = mw.readFile(getConfTpl())
conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
conf_content = conf_content.replace(
'{$REDIS_PASS}', mw.getRandomString(10))
mw.writeFile(dst_conf, conf_content)
mw.writeFile(dst_conf_init, 'ok')
# systemd
systemDir = mw.systemdCfgDir()
systemService = systemDir + '/' + getPluginName() + '.service'
if os.path.exists(systemDir) and not os.path.exists(systemService):
systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl'
service_path = mw.getServerDir()
se_content = mw.readFile(systemServiceTpl)
se_content = se_content.replace('{$SERVER_PATH}', service_path)
mw.writeFile(systemService, se_content)
mw.execShell('systemctl daemon-reload')
return file_bin
def redisOp(method):
def zOp(method):
file = initDreplace()
current_os = mw.getOs()
@ -197,15 +158,15 @@ def redisOp(method):
def start():
return redisOp('start')
return zOp('start')
def stop():
return redisOp('stop')
return zOp('stop')
def restart():
status = redisOp('restart')
status = zOp('restart')
log_file = runLog()
mw.execShell("echo '' > " + log_file)
@ -213,7 +174,7 @@ def restart():
def reload():
return redisOp('reload')
return zOp('reload')
def getPort():

Loading…
Cancel
Save