From 417d1b4f8383fe892ac25d5a90784dd295df1df8 Mon Sep 17 00:00:00 2001 From: wnlen <62139570+wnlen@users.noreply.github.com> Date: Thu, 15 Jan 2026 16:25:09 +0800 Subject: [PATCH] Update install.sh --- install.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 3950b35..634dd8a 100755 --- a/install.sh +++ b/install.sh @@ -361,6 +361,54 @@ else warn "未检测到 systemd,已跳过服务单元生成" fi +# ========================= +# Shell 代理快捷命令 +# 生成:/etc/profile.d/clash-for-linux.sh +# ========================= +PROFILED_FILE="/etc/profile.d/clash-for-linux.sh" + +install_profiled() { + local http_port="${MIXED_PORT:-7890}" + # 兼容你后面可能支持 auto:auto 就先用 7890 + [ "$http_port" = "auto" ] && http_port="7890" + + # 只写 IPv4 loopback,避免某些环境 ::1 解析问题 + sudo tee "$PROFILED_FILE" >/dev/null <}" + echo "https_proxy=\${https_proxy:-}" + echo "all_proxy=\${all_proxy:-}" +} +EOF + + sudo chmod 644 "$PROFILED_FILE" +} + +install_profiled || true + # ========================= # 安装 clashctl 命令 # ========================= @@ -452,8 +500,15 @@ fi # 下一步 # ========================= section "下一步开启代理(可选)" -log " $(cmd "source /etc/profile.d/clash-for-linux.sh")" -log " $(cmd "proxy_on")" + +PROFILED_FILE="/etc/profile.d/clash-for-linux.sh" + +if [ -f "$PROFILED_FILE" ]; then + log " $(cmd "source $PROFILED_FILE")" + log " $(cmd "proxy_on")" +else + log " (未安装 Shell 代理快捷命令,跳过)" +fi # ========================= # 启动后快速诊断