Files
youlegames/codes/agent/game-docker/docker/dlweb/docker-entrypoint.sh
2026-04-10 16:44:13 +08:00

122 lines
6.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -e
# ============================================
# DLWEB 服务启动入口脚本
# 在 Apache 启动前替换静态 JS/HTML 文件中的硬编码域名
# ============================================
echo "[entrypoint] Replacing hardcoded domains in JS/HTML files..."
# 从环境变量读取,提供默认值
# DLWEB_API_BASE_URL 和 DLWEB_SDK_API_URL 从 API_DOMAIN / DLWEB_DOMAIN 自动推导
DLWEB_API_BASE_URL="https://${API_DOMAIN:-api.daoqijuyou77.cn}"
DLWEB_SETTLE_URL="${DLWEB_SETTLE_URL:-http://dlsettle.daoqijuyou77.cn/mobile/}"
DLWEB_AVATAR_URL="${DLWEB_AVATAR_URL:-https://dlwebv3.tscce.cn/images/noavatar.png}"
DLWEB_SDK_API_URL="https://${DLWEB_DOMAIN:-dlapi.daoqijuyou77.cn}"
DLWEB_SDK_API2_URL="${DLWEB_SDK_API2_URL:-https://api2.tscce.cn}"
DLWEB_PROXY_URL="${DLWEB_PROXY_URL:-https://proxytest.tscce.cn}"
DLWEB_DL_API_V3_URL="${DLWEB_DL_API_V3_URL:-https://dlapiv3.tscce.cn}"
DLWEB_WEB_DOMAIN="${DLWEB_WEB_DOMAIN:-https://dlwebv3.tscce.cn}"
DLWEB_SETTLE_FULL_URL="${DLWEB_SETTLE_FULL_URL:-http://dlsettle.tscce.cn}"
DLWEB_OPERATE_URL="${DLWEB_OPERATE_URL:-https://operate.daoqijuyou77.cn}"
DLWEB_PROXY_77_URL="${DLWEB_PROXY_77_URL:-https://proxytest.daoqijuyou77.cn}"
SITE_GAME_SERVICE_URL="${SITE_GAME_SERVICE_URL:-http://ylyxservice1.daoqijuyou77.cn:1089/index.html}"
DLWEB_DOWNLOAD_CDN_URL="${DLWEB_DOWNLOAD_CDN_URL:-http://tsqiniu1.tscce.cn}"
DLWEB_GAME_IMAGE_URL="${DLWEB_GAME_IMAGE_URL:-http://tsgames.daoqijuyou77.cn}"
DLWEB_SKYGAMES_URL="${DLWEB_SKYGAMES_URL:-https://skygames.tscce.cn}"
JS_DIR="/var/www/html/api/web2/js"
COMP_DIR="/var/www/html/api/web2/components"
HTML_DIR="/var/www/html/api/web2"
# ---- function.js ----
FUNC_JS="$JS_DIR/function.js"
if [ -f "$FUNC_JS" ]; then
# API URL 和 回调地址
sed -i "s|'https://dlapi.daoqijuyou77.cn/Index.php'|'${DLWEB_API_BASE_URL}/Index.php'|g" "$FUNC_JS"
sed -i "s|'https://dlapi.daoqijuyou77.cn/web2/notify.html'|'${DLWEB_API_BASE_URL}/web2/notify.html'|g" "$FUNC_JS"
# 结算地址
sed -i "s|'http://dlsettle.daoqijuyou77.cn/mobile/'|'${DLWEB_SETTLE_URL}'|g" "$FUNC_JS"
sed -i "s|'http://dlsettle.tscce.cn/mobile/'|'${DLWEB_SETTLE_URL}'|g" "$FUNC_JS"
sed -i "s|'https://proxytest.tscce.cn/settle/mobile/'|'${DLWEB_PROXY_URL}/settle/mobile/'|g" "$FUNC_JS"
# 头像,SDK API 地址
sed -i "s|https://dlwebv3.tscce.cn/images/noavatar.png|${DLWEB_AVATAR_URL}|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/source/login/login.php|${DLWEB_SDK_API_URL}/source/login/login.php|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/api/user|${DLWEB_SDK_API_URL}/api/user|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/source/pay/pay.php|${DLWEB_SDK_API_URL}/source/pay/pay.php|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/source/pay/notify.php|${DLWEB_SDK_API_URL}/source/pay/notify.php|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/api/weixin/wx_share_info|${DLWEB_SDK_API_URL}/api/weixin/wx_share_info|g" "$FUNC_JS"
sed -i "s|https://api.daoqijuyou77.cn/api/login/ylnn|${DLWEB_SDK_API_URL}/api/login/ylnn|g" "$FUNC_JS"
echo "[entrypoint] Updated: $FUNC_JS"
fi
# ---- function-a.js ----
FUNC_A_JS="$JS_DIR/function-a.js"
if [ -f "$FUNC_A_JS" ]; then
sed -i "s|'https://dlapi.daoqijuyou77.cn/Index.php'|'${DLWEB_API_BASE_URL}/Index.php'|g" "$FUNC_A_JS"
sed -i "s|'https://dlapi.daoqijuyou77.cn/web2/notify.html'|'${DLWEB_API_BASE_URL}/web2/notify.html'|g" "$FUNC_A_JS"
sed -i "s|https://dlwebv3.tscce.cn/images/noavatar.png|${DLWEB_AVATAR_URL}|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/source/login/login.php|${DLWEB_SDK_API2_URL}/source/login/login.php|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/api/user|${DLWEB_SDK_API2_URL}/api/user|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/source/pay/pay_1.php|${DLWEB_SDK_API2_URL}/source/pay/pay_1.php|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/source/pay/notify.php|${DLWEB_SDK_API2_URL}/source/pay/notify.php|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/api/weixin/wx_share_info|${DLWEB_SDK_API2_URL}/api/weixin/wx_share_info|g" "$FUNC_A_JS"
sed -i "s|https://api2.tscce.cn/api/login/ylnn|${DLWEB_SDK_API2_URL}/api/login/ylnn|g" "$FUNC_A_JS"
echo "[entrypoint] Updated: $FUNC_A_JS"
fi
# ---- tangjian.js ----
TJ_JS="$JS_DIR/tangjian.js"
if [ -f "$TJ_JS" ]; then
sed -i "s|'https://proxytest.tscce.cn/api/Index.php'|'${DLWEB_PROXY_URL}/api/Index.php'|g" "$TJ_JS"
sed -i "s|'https://dlapiv3.tscce.cn/Index.php'|'${DLWEB_DL_API_V3_URL}/Index.php'|g" "$TJ_JS"
echo "[entrypoint] Updated: $TJ_JS"
fi
# ---- public_method.js ----
PM_JS="$JS_DIR/public_method.js"
if [ -f "$PM_JS" ]; then
sed -i "s|http://ylyxservice1.daoqijuyou77.cn:1089/index.html|${SITE_GAME_SERVICE_URL}|g" "$PM_JS"
echo "[entrypoint] Updated: $PM_JS"
fi
# ---- common_mixin.js ----
CM_JS="$COMP_DIR/common_mixin.js"
if [ -f "$CM_JS" ]; then
sed -i "s|https://dlwebv3.tscce.cn/images/noavatar.png|${DLWEB_AVATAR_URL}|g" "$CM_JS"
echo "[entrypoint] Updated: $CM_JS"
fi
# ---- HTML 文件 ----
# links.html
LINKS_HTML="$HTML_DIR/links.html"
if [ -f "$LINKS_HTML" ]; then
sed -i "s|https://dlapi.daoqijuyou77.cn|${DLWEB_API_BASE_URL}|g" "$LINKS_HTML"
sed -i "s|https://operate.daoqijuyou77.cn|${DLWEB_OPERATE_URL}|g" "$LINKS_HTML"
sed -i "s|https://proxytest.daoqijuyou77.cn|${DLWEB_PROXY_77_URL}|g" "$LINKS_HTML"
echo "[entrypoint] Updated: $LINKS_HTML"
fi
# download.html
DOWNLOAD_HTML="$HTML_DIR/download.html"
if [ -f "$DOWNLOAD_HTML" ]; then
sed -i "s|http://tsgames.daoqijuyou77.cn|${DLWEB_GAME_IMAGE_URL}|g" "$DOWNLOAD_HTML"
sed -i "s|http://tsqiniu1.tscce.cn|${DLWEB_DOWNLOAD_CDN_URL}|g" "$DOWNLOAD_HTML"
sed -i "s|https://skygames.tscce.cn|${DLWEB_SKYGAMES_URL}|g" "$DOWNLOAD_HTML"
echo "[entrypoint] Updated: $DOWNLOAD_HTML"
fi
# agent_list_admin.html
ADMIN_HTML="$HTML_DIR/agent_list_admin.html"
if [ -f "$ADMIN_HTML" ]; then
sed -i "s|http://proxytest.tscce.cn/settle/managebak|${DLWEB_PROXY_URL}/settle/managebak|g" "$ADMIN_HTML"
sed -i "s|http://dlsettle.tscce.cn/managebak|${DLWEB_SETTLE_FULL_URL}/managebak|g" "$ADMIN_HTML"
echo "[entrypoint] Updated: $ADMIN_HTML"
fi
echo "[entrypoint] Domain replacement complete. Starting Apache..."
# 启动 Apache前台运行
exec apache2-foreground