Update install.sh

This commit is contained in:
wnlen
2026-01-15 16:25:09 +08:00
parent e0b0c54021
commit 417d1b4f83

View File

@ -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}"
# 兼容你后面可能支持 autoauto 就先用 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 命令
# =========================
@ -452,8 +500,15 @@ fi
# 下一步
# =========================
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")"
else
log " (未安装 Shell 代理快捷命令,跳过)"
fi
# =========================
# 启动后快速诊断