#!/bin/bash # ═══════════════════════════════════════════════ # 🔺 Sovereign: TCS-0002∞ | Root: SYS-GLW-0001 # 📜 Copyright: 国作登字-2026-A-00037559 # ═══════════════════════════════════════════════ # server/proxy/setup/install-xray.sh # 🌐 Xray-core安装 + BBR加速 + 防火墙配置 # # 在SG服务器(ZY-SVR-002)上执行 # 安装Xray-core并启用BBR TCP加速 # # 用法: bash install-xray.sh # ═══════════════════════════════════════════════ set -uo pipefail # 注意: 不使用 set -e,手动处理关键步骤错误 echo "════════════════════════════════════════" echo "🌐 铸渊专线 · Xray-core 安装" echo "════════════════════════════════════════" # ── 1. 系统更新 ────────────────────────────── echo "[1/6] 系统更新..." apt-get update -y || { echo "❌ apt-get update 失败"; exit 1; } apt-get upgrade -y || echo "⚠️ apt-get upgrade 部分失败,继续安装" # ── 2. 安装Xray-core ──────────────────────── echo "[2/6] 安装Xray-core..." if command -v xray &>/dev/null; then echo " Xray已安装: $(xray version | head -1)" else # 使用XTLS官方安装脚本 (https://github.com/XTLS/Xray-install) # 安装脚本自带GPG签名验证,确保二进制完整性 bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install if command -v xray &>/dev/null; then echo " Xray安装完成: $(xray version | head -1)" else echo "❌ Xray安装失败" exit 1 fi fi # ── 3. 启用BBR TCP加速 ────────────────────── echo "[3/6] 配置BBR TCP加速..." if sysctl net.ipv4.tcp_congestion_control 2>/dev/null | grep -q bbr; then echo " BBR已启用" else # 检查是否已添加过BBR配置,避免重复追加 if ! grep -q "铸渊专线 BBR加速" /etc/sysctl.conf 2>/dev/null; then cat >> /etc/sysctl.conf <