diff --git a/cp_scripts_alchemy_macos.sh b/cp_scripts_alchemy_macos.sh index a0a04df..252de4c 100755 --- a/cp_scripts_alchemy_macos.sh +++ b/cp_scripts_alchemy_macos.sh @@ -21,10 +21,18 @@ cp conf/alchemy/*.conf $openresty_sub_config_dir openresty_install_path=$(openresty -V 2>&1 | tr '\n' '\f' | sed -r 's/.*--prefix=(.*)[[:space:]]--with-cc.*/\1/') openresty_lua_scripts_dir=$openresty_install_path/scripts echo $openresty_lua_scripts_dir - +# -- Make scripts dir mkdir -p $openresty_lua_scripts_dir - +# -- Copy scripts file cp scripts/*.lua $openresty_lua_scripts_dir +# -- Replace scripts path in file +replaced_scripts_path=$(echo $openresty_lua_scripts_dir | sed 's_/_\\/_g') +echo "$replaced_scripts_path" +sed -i -e "s/\$script_path/$replaced_scripts_path/" \ + "$openresty_lua_scripts_dir"/combine.lua \ + "$openresty_lua_scripts_dir"/convert_audio.lua \ + "$openresty_lua_scripts_dir"/test_upyun_upload.lua \ + "$openresty_lua_scripts_dir"/upyun_upload.lua # Reload openresty openresty -t diff --git a/cp_scripts_local_macos.sh b/cp_scripts_local_macos.sh index d289af6..4f9e3aa 100755 --- a/cp_scripts_local_macos.sh +++ b/cp_scripts_local_macos.sh @@ -21,10 +21,18 @@ cp conf/local_macos/*.conf $openresty_sub_config_dir openresty_install_path=$(openresty -V 2>&1 | tr '\n' '\f' | sed -r 's/.*--prefix=(.*)[[:space:]]--with-cc.*/\1/') openresty_lua_scripts_dir=$openresty_install_path/scripts echo $openresty_lua_scripts_dir - +# -- Make scripts dir mkdir -p $openresty_lua_scripts_dir - +# -- Copy scripts file cp scripts/*.lua $openresty_lua_scripts_dir +# -- Replace scripts path in file +replaced_scripts_path=$(echo $openresty_lua_scripts_dir | sed 's_/_\\/_g') +echo "$replaced_scripts_path" +sed -i -e "s/\$script_path/$replaced_scripts_path/" \ + "$openresty_lua_scripts_dir"/combine.lua \ + "$openresty_lua_scripts_dir"/convert_audio.lua \ + "$openresty_lua_scripts_dir"/test_upyun_upload.lua \ + "$openresty_lua_scripts_dir"/upyun_upload.lua # Reload openresty openresty -t diff --git a/cp_scripts_moicen_macos.sh b/cp_scripts_moicen_macos.sh index 8d42106..46a80a0 100755 --- a/cp_scripts_moicen_macos.sh +++ b/cp_scripts_moicen_macos.sh @@ -21,10 +21,18 @@ cp conf/moicen/*.conf $openresty_sub_config_dir openresty_install_path=$(openresty -V 2>&1 | tr '\n' '\f' | sed -r 's/.*--prefix=(.*)[[:space:]]--with-cc.*/\1/') openresty_lua_scripts_dir=$openresty_install_path/scripts echo $openresty_lua_scripts_dir - +# -- Make scripts dir mkdir -p $openresty_lua_scripts_dir - +# -- Copy scripts file cp scripts/*.lua $openresty_lua_scripts_dir +# -- Replace scripts path in file +replaced_scripts_path=$(echo $openresty_lua_scripts_dir | sed 's_/_\\/_g') +echo "$replaced_scripts_path" +sed -i -e "s/\$script_path/$replaced_scripts_path/" \ + "$openresty_lua_scripts_dir"/combine.lua \ + "$openresty_lua_scripts_dir"/convert_audio.lua \ + "$openresty_lua_scripts_dir"/test_upyun_upload.lua \ + "$openresty_lua_scripts_dir"/upyun_upload.lua # Reload openresty openresty -t diff --git a/scripts/combine.lua b/scripts/combine.lua index 220493a..d7b1984 100644 --- a/scripts/combine.lua +++ b/scripts/combine.lua @@ -1,5 +1,7 @@ -- 指定模块引用目录,否则无法加载同目录下的其他文件 -package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +package.path = package.path .. ';$script_path/?.lua'; + local uuid = require "resty.jit-uuid" local cjson = require "cjson" local upyun_upload = require("upyun_upload") diff --git a/scripts/convert_audio.lua b/scripts/convert_audio.lua index 3932d27..b9e7c03 100644 --- a/scripts/convert_audio.lua +++ b/scripts/convert_audio.lua @@ -1,5 +1,7 @@ -- 指定模块引用目录,否则无法加载同目录下的其他文件 -package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +package.path = package.path .. ';$script_path/?.lua'; + local cjson = require "cjson" local uuid = require "resty.jit-uuid" local http = require "resty.http" diff --git a/scripts/test_upyun_upload.lua b/scripts/test_upyun_upload.lua index 2f4957d..1a7a135 100644 --- a/scripts/test_upyun_upload.lua +++ b/scripts/test_upyun_upload.lua @@ -1,4 +1,7 @@ -package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +-- 指定模块引用目录,否则无法加载同目录下的其他文件 +--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +package.path = package.path .. ';$script_path/?.lua'; + local yun = require("upyun") local cjson = require "cjson" diff --git a/scripts/upyun_upload.lua b/scripts/upyun_upload.lua index 8c7ea82..0073a82 100644 --- a/scripts/upyun_upload.lua +++ b/scripts/upyun_upload.lua @@ -1,5 +1,6 @@ -- 指定模块引用目录,否则无法加载同目录下的其他文件 -package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua'; +package.path = package.path .. ';$script_path/?.lua'; local upyun_upload = {}