fix: update.sh 迁移A修正heredoc写法
这个提交包含在:
父节点
7abf1e1f26
当前提交
65858594e7
@ -511,21 +511,23 @@ fi
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
_nginx_conf="$ROOT_DIR/config/nginx/conf.d/xuqm.conf"
|
_nginx_conf="$ROOT_DIR/config/nginx/conf.d/xuqm.conf"
|
||||||
if [ -f "$_nginx_conf" ] && ! grep -q 'api/auth/register' "$_nginx_conf"; then
|
if [ -f "$_nginx_conf" ] && ! grep -q 'api/auth/register' "$_nginx_conf"; then
|
||||||
python3 - "$_nginx_conf" <<\'PYEOF\'
|
_PATCH_PY="$(mktemp /tmp/xuqm-nginx-patch-XXXXXX.py)"
|
||||||
|
cat > "$_PATCH_PY" << 'NGINX_PATCH_PY'
|
||||||
import re, sys
|
import re, sys
|
||||||
content = open(sys.argv[1]).read()
|
path = sys.argv[1]
|
||||||
block = """ # 私有化部署:精确拦截用户自注册(必须在通用 /api/ 之前)
|
content = open(path).read()
|
||||||
location = /api/auth/register {
|
block = (
|
||||||
add_header Content-Type \'application/json; charset=utf-8\' always;
|
' # \u79c佖化部署:精确拦截用户自注册(必须在通用 /api/ 之前)\n'
|
||||||
return 403 \'{"code":403,"status":"1","data":null,"message":"私有化部署已禁用用户自注册"}\';
|
' location = /api/auth/register {\n'
|
||||||
}
|
" add_header Content-Type 'application/json; charset=utf-8' always;\n"
|
||||||
|
' return 403 \'{"code":403,"status":"1","data":null,"message":"\u79c佖化部署已禁用用户自注册"}\';\n'
|
||||||
"""
|
' }\n\n'
|
||||||
content = re.sub(r"( # 核心 API)", block + r"\1", content, count=1)
|
)
|
||||||
open(sys.argv[1], \'w\').write(content)
|
content = re.sub(r'( # 核心 API)', block + r'\1', content, count=1)
|
||||||
PYEOF
|
open(path, 'w').write(content)
|
||||||
ok "nginx conf 已补充用户注册拦截规则"
|
NGINX_PATCH_PY
|
||||||
# 重载 nginx 容器使配置生效
|
python3 "$_PATCH_PY" "$_nginx_conf" && ok "nginx conf 已补充用户注册拦截规则" || warn "nginx conf 修改失败,请手动添加"
|
||||||
|
rm -f "$_PATCH_PY"
|
||||||
docker exec xuqm-private-nginx-1 nginx -s reload 2>/dev/null && ok "nginx 已 reload" || warn "nginx reload 失败,将在容器重启后生效"
|
docker exec xuqm-private-nginx-1 nginx -s reload 2>/dev/null && ok "nginx 已 reload" || warn "nginx reload 失败,将在容器重启后生效"
|
||||||
else
|
else
|
||||||
ok "nginx 用户注册拦截规则已存在,跳过"
|
ok "nginx 用户注册拦截规则已存在,跳过"
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户