mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2026-03-21 22:06:45 +08:00
Support docker containers
This commit is contained in:
5
start.sh
5
start.sh
@ -88,6 +88,7 @@ URL="${CLASH_URL:-}"
|
||||
|
||||
# 清理可能的 CRLF(Windows 写 .env 很常见)
|
||||
URL="$(printf '%s' "$URL" | tr -d '\r')"
|
||||
URL="$(printf '%s' "$URL" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
||||
|
||||
#让 bash 子进程能拿到
|
||||
export CLASH_URL="$URL"
|
||||
@ -97,6 +98,10 @@ if [ -z "$URL" ] && [ "${SYSTEMD_MODE:-false}" != "true" ]; then
|
||||
echo "[ERR] CLASH_URL 为空(未配置订阅地址)"
|
||||
exit 2
|
||||
fi
|
||||
if [ -n "$URL" ] && ! printf '%s' "$URL" | grep -Eq '^https?://'; then
|
||||
echo "[ERR] CLASH_URL 格式无效:必须以 http:// 或 https:// 开头" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 获取 CLASH_SECRET 值:优先 .env;其次读取旧 config;占位符视为无效;最后生成随机值
|
||||
Secret="${CLASH_SECRET:-}"
|
||||
|
||||
Reference in New Issue
Block a user