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

View File

@ -325,7 +325,8 @@ def restartWeb():
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()
if not os.path.exists(path + '/waf/lua'):
sdir = getPluginDir() + '/waf'
@ -348,20 +349,22 @@ def initDreplace():
content['reqfile_path'] = wfDir
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"
content = mw.readFile(config_common)
content = contentReplace(content)
mw.writeFile(config_common, content)
dst_init_worker = root_worker_dir + '/opwaf_init_worker.lua'
init_worker = path + "/waf/lua/init_worker.lua"
content = mw.readFile(init_worker)
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()
if not os.path.exists(waf_conf):
@ -396,15 +399,8 @@ def status():
def start():
initDreplace()
path = mw.getServerDir() + '/web_conf/nginx/lua/lua.conf'
init_worker_lua = getServerDir() + '/waf/lua/init_worker.lua'
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)
mw.opLuaInitWorkerFile()
mw.opLuaInitAccessFile()
import tool_task
tool_task.createBgTask()
@ -414,15 +410,16 @@ def start():
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'
empty_lua = mw.getServerDir() + '/web_conf/nginx/lua/empty.lua'
conf = mw.readFile(path)
conf = re.sub('init_worker_by_lua_file (.*);',
"init_worker_by_lua_file " + empty_lua + ";", conf)
conf = re.sub('access_by_lua_file (.*);',
"access_by_lua_file " + empty_lua + ";", conf)
mw.writeFile(path, conf)
dst_init_worker = root_worker_dir + '/opwaf_init_worker.lua'
if os.path.exists(dst_init_worker):
os.remove(dst_init_worker)
access_file = root_access_dir + '/opwaf_init.lua'
if os.path.exists(access_file):
os.remove(access_file)
wafconf = dstWafConf()
if os.path.exists(wafconf):
@ -431,6 +428,9 @@ def stop():
import tool_task
tool_task.removeBgTask()
mw.opLuaInitWorkerFile()
mw.opLuaInitAccessFile()
restartWeb()
return 'ok'

View File

@ -24,7 +24,7 @@ else
fi
Install_of(){
Install_App(){
echo '正在安装脚本文件...' > $install_tmp
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 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 install
fi
@ -85,13 +87,10 @@ Install_of(){
echo 'install ok' > $install_tmp
cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py start
# cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py restart
}
Uninstall_of(){
Uninstall_App(){
cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py stop
if [ "$?" == "0" ];then
@ -102,7 +101,7 @@ Uninstall_of(){
action=$1
if [ "${1}" == 'install' ];then
Install_of
Install_App
else
Uninstall_of
Uninstall_App
fi