mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2026-02-04 10:11:28 +08:00
Update install.sh
This commit is contained in:
57
install.sh
57
install.sh
@ -361,6 +361,54 @@ else
|
|||||||
warn "未检测到 systemd,已跳过服务单元生成"
|
warn "未检测到 systemd,已跳过服务单元生成"
|
||||||
fi
|
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 <<EOF
|
||||||
|
# Clash for Linux proxy helpers
|
||||||
|
# Auto-generated by clash-for-linux installer.
|
||||||
|
|
||||||
|
# Default proxy endpoint (HTTP)
|
||||||
|
export CLASH_HTTP_PROXY="http://127.0.0.1:${http_port}"
|
||||||
|
# Default proxy endpoint (SOCKS5)
|
||||||
|
export CLASH_SOCKS_PROXY="socks5://127.0.0.1:${http_port}"
|
||||||
|
|
||||||
|
proxy_on() {
|
||||||
|
export http_proxy="\$CLASH_HTTP_PROXY"
|
||||||
|
export https_proxy="\$CLASH_HTTP_PROXY"
|
||||||
|
export all_proxy="\$CLASH_SOCKS_PROXY"
|
||||||
|
export HTTP_PROXY="\$CLASH_HTTP_PROXY"
|
||||||
|
export HTTPS_PROXY="\$CLASH_HTTP_PROXY"
|
||||||
|
export ALL_PROXY="\$CLASH_SOCKS_PROXY"
|
||||||
|
echo "[OK] Proxy enabled: \$CLASH_HTTP_PROXY"
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy_off() {
|
||||||
|
unset http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY
|
||||||
|
echo "[OK] Proxy disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy_status() {
|
||||||
|
echo "http_proxy=\${http_proxy:-<empty>}"
|
||||||
|
echo "https_proxy=\${https_proxy:-<empty>}"
|
||||||
|
echo "all_proxy=\${all_proxy:-<empty>}"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo chmod 644 "$PROFILED_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_profiled || true
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# 安装 clashctl 命令
|
# 安装 clashctl 命令
|
||||||
# =========================
|
# =========================
|
||||||
@ -452,8 +500,15 @@ fi
|
|||||||
# 下一步
|
# 下一步
|
||||||
# =========================
|
# =========================
|
||||||
section "下一步开启代理(可选)"
|
section "下一步开启代理(可选)"
|
||||||
log " $(cmd "source /etc/profile.d/clash-for-linux.sh")"
|
|
||||||
|
PROFILED_FILE="/etc/profile.d/clash-for-linux.sh"
|
||||||
|
|
||||||
|
if [ -f "$PROFILED_FILE" ]; then
|
||||||
|
log " $(cmd "source $PROFILED_FILE")"
|
||||||
log " $(cmd "proxy_on")"
|
log " $(cmd "proxy_on")"
|
||||||
|
else
|
||||||
|
log " (未安装 Shell 代理快捷命令,跳过)"
|
||||||
|
fi
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# 启动后快速诊断
|
# 启动后快速诊断
|
||||||
|
|||||||
Reference in New Issue
Block a user