pull/125/head
midoks 3 years ago
parent 7b3e719843
commit d99d1d03d1
  1. 24
      plugins/op_waf/index.py
  2. 3
      plugins/op_waf/install.sh

@ -186,7 +186,7 @@ def status():
def contentReplace(content): def contentReplace(content):
service_path = mw.getServerDir() service_path = mw.getServerDir()
waf_path = mw.getServerDir() + "/openresty/nginx/conf/waf" waf_path = getServerDir() + "/waf"
content = content.replace('{$ROOT_PATH}', mw.getRootDir()) content = content.replace('{$ROOT_PATH}', mw.getRootDir())
content = content.replace('{$SERVER_PATH}', service_path) content = content.replace('{$SERVER_PATH}', service_path)
content = content.replace('{$WAF_PATH}', waf_path) content = content.replace('{$WAF_PATH}', waf_path)
@ -195,20 +195,21 @@ def contentReplace(content):
def initDreplace(): def initDreplace():
path = mw.getServerDir() + "/openresty/nginx/conf" path = getServerDir()
if not os.path.exists(path + '/waf'): if not os.path.exists(path + '/waf'):
sdir = getPluginDir() + '/waf' sdir = getPluginDir() + '/waf'
cmd = 'cp -rf ' + sdir + ' ' + path cmd = 'cp -rf ' + sdir + ' ' + path
mw.execShell(cmd) mw.execShell(cmd)
config = mw.getServerDir() + '/openresty/nginx/conf/waf/config.json' config = path + '/waf/config.json'
content = mw.readFile(config) content = mw.readFile(config)
content = json.loads(content) content = json.loads(content)
content['reqfile_path'] = mw.getServerDir(
) + "/openresty/nginx/conf/waf/html" wfDir = path + "/waf/html"
content['reqfile_path'] = wfDir
mw.writeFile(config, mw.getJson(content)) mw.writeFile(config, mw.getJson(content))
config = mw.getServerDir() + "/openresty/nginx/conf/waf/lua/init.lua" config = path + "/waf/lua/init.lua"
content = mw.readFile(config) content = mw.readFile(config)
content = contentReplace(content) content = contentReplace(content)
mw.writeFile(config, content) mw.writeFile(config, content)
@ -230,18 +231,13 @@ def start():
path = getConf() path = getConf()
conf = mw.readFile(path) conf = mw.readFile(path)
conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;") conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;")
mw.writeFile(path, conf) mw.writeFile(path, conf)
mw.restartWeb() mw.restartWeb()
return 'ok' return 'ok'
def stop(): def stop():
path = mw.getServerDir() + "/openresty/nginx/conf/waf"
if os.path.exists(path):
cmd = 'rm -rf ' + path
mw.execShell(cmd)
path = getConf() path = getConf()
conf = mw.readFile(path) conf = mw.readFile(path)
conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;") conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;")
@ -265,12 +261,12 @@ def reload():
def getJsonPath(name): def getJsonPath(name):
path = mw.getServerDir() + "/openresty/nginx/conf/waf/" + name + ".json" path = getServerDir() + "/waf/" + name + ".json"
return path return path
def getRuleJsonPath(name): def getRuleJsonPath(name):
path = mw.getServerDir() + "/openresty/nginx/conf/waf/rule/" + name + ".json" path = getServerDir() + "/waf/rule/" + name + ".json"
return path return path

@ -16,9 +16,6 @@ Install_of(){
echo '正在安装脚本文件...' > $install_tmp echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/op_waf mkdir -p $serverPath/op_waf
if [ -f $serverPath/openresty ];then
mkdir -p $serverPath/openresty/nginx/conf/waf
fi
echo '0.1' > $serverPath/op_waf/version.pl echo '0.1' > $serverPath/op_waf/version.pl
echo 'install ok' > $install_tmp echo 'install ok' > $install_tmp
} }

Loading…
Cancel
Save