This commit is contained in:
midoks
2023-02-11 02:52:02 +08:00
parent e4c5212ac4
commit ec7ae65f7d
2 changed files with 31 additions and 32 deletions
+24 -24
View File
@@ -325,7 +325,8 @@ def restartWeb():
def initDreplace(): def initDreplace():
root_worker_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
root_access_dir = mw.getServerDir() + '/web_conf/nginx/lua/access_by_lua_file'
path = getServerDir() path = getServerDir()
if not os.path.exists(path + '/waf/lua'): if not os.path.exists(path + '/waf/lua'):
sdir = getPluginDir() + '/waf' sdir = getPluginDir() + '/waf'
@@ -348,20 +349,22 @@ def initDreplace():
content['reqfile_path'] = wfDir content['reqfile_path'] = wfDir
mw.writeFile(config, mw.getJson(content)) mw.writeFile(config, mw.getJson(content))
config = path + "/waf/lua/init.lua"
content = mw.readFile(config)
content = contentReplace(content)
mw.writeFile(config, content)
config_common = path + "/waf/lua/common.lua" config_common = path + "/waf/lua/common.lua"
content = mw.readFile(config_common) content = mw.readFile(config_common)
content = contentReplace(content) content = contentReplace(content)
mw.writeFile(config_common, content) mw.writeFile(config_common, content)
dst_init_worker = root_worker_dir + '/opwaf_init_worker.lua'
init_worker = path + "/waf/lua/init_worker.lua" init_worker = path + "/waf/lua/init_worker.lua"
content = mw.readFile(init_worker) content = mw.readFile(init_worker)
content = contentReplace(content) content = contentReplace(content)
mw.writeFile(init_worker, content) mw.writeFile(dst_init_worker, content)
access_file = root_access_dir + '/opwaf_init.lua'
config = path + "/waf/lua/init.lua"
content = mw.readFile(config)
content = contentReplace(content)
mw.writeFile(access_file, content)
waf_conf = dstWafConf() waf_conf = dstWafConf()
if not os.path.exists(waf_conf): if not os.path.exists(waf_conf):
@@ -396,15 +399,8 @@ def status():
def start(): def start():
initDreplace() initDreplace()
path = mw.getServerDir() + '/web_conf/nginx/lua/lua.conf' mw.opLuaInitWorkerFile()
init_worker_lua = getServerDir() + '/waf/lua/init_worker.lua' mw.opLuaInitAccessFile()
init_lua = getServerDir() + '/waf/lua/init.lua'
conf = mw.readFile(path)
conf = re.sub('init_worker_by_lua_file (.*);',
"init_worker_by_lua_file " + init_worker_lua + ";", conf)
conf = re.sub('access_by_lua_file (.*);',
"access_by_lua_file " + init_lua + ";", conf)
mw.writeFile(path, conf)
import tool_task import tool_task
tool_task.createBgTask() tool_task.createBgTask()
@@ -414,15 +410,16 @@ def start():
def stop(): def stop():
root_worker_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
root_access_dir = mw.getServerDir() + '/web_conf/nginx/lua/access_by_lua_file'
path = mw.getServerDir() + '/web_conf/nginx/lua/lua.conf' dst_init_worker = root_worker_dir + '/opwaf_init_worker.lua'
empty_lua = mw.getServerDir() + '/web_conf/nginx/lua/empty.lua' if os.path.exists(dst_init_worker):
conf = mw.readFile(path) os.remove(dst_init_worker)
conf = re.sub('init_worker_by_lua_file (.*);',
"init_worker_by_lua_file " + empty_lua + ";", conf) access_file = root_access_dir + '/opwaf_init.lua'
conf = re.sub('access_by_lua_file (.*);', if os.path.exists(access_file):
"access_by_lua_file " + empty_lua + ";", conf) os.remove(access_file)
mw.writeFile(path, conf)
wafconf = dstWafConf() wafconf = dstWafConf()
if os.path.exists(wafconf): if os.path.exists(wafconf):
@@ -431,6 +428,9 @@ def stop():
import tool_task import tool_task
tool_task.removeBgTask() tool_task.removeBgTask()
mw.opLuaInitWorkerFile()
mw.opLuaInitAccessFile()
restartWeb() restartWeb()
return 'ok' return 'ok'
+7 -8
View File
@@ -24,7 +24,7 @@ else
fi fi
Install_of(){ Install_App(){
echo '正在安装脚本文件...' > $install_tmp echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source/op_waf mkdir -p $serverPath/source/op_waf
@@ -41,7 +41,9 @@ Install_of(){
cd $serverPath/source/op_waf && tar xvf luarocks-3.5.0.tar.gz cd $serverPath/source/op_waf && tar xvf luarocks-3.5.0.tar.gz
# cd luarocks-3.9.1 && ./configure && make bootstrap # cd luarocks-3.9.1 && ./configure && make bootstrap
cd luarocks-3.5.0 && ./configure --prefix=$serverPath/op_waf/luarocks --with-lua-include=$serverPath/openresty/luajit/include/luajit-2.1 --with-lua-bin=$serverPath/openresty/luajit/bin cd luarocks-3.5.0 && ./configure --prefix=$serverPath/op_waf/luarocks \
--with-lua-include=$serverPath/openresty/luajit/include/luajit-2.1 \
--with-lua-bin=$serverPath/openresty/luajit/bin
make -I${serverPath}/openresty/luajit/bin make -I${serverPath}/openresty/luajit/bin
make install make install
fi fi
@@ -85,13 +87,10 @@ Install_of(){
echo 'install ok' > $install_tmp echo 'install ok' > $install_tmp
cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py start cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py start
# cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py restart # cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py restart
} }
Uninstall_of(){ Uninstall_App(){
cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py stop cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py stop
if [ "$?" == "0" ];then if [ "$?" == "0" ];then
@@ -102,7 +101,7 @@ Uninstall_of(){
action=$1 action=$1
if [ "${1}" == 'install' ];then if [ "${1}" == 'install' ];then
Install_of Install_App
else else
Uninstall_of Uninstall_App
fi fi