Files
3x-ui-agent/install-master.sh
T

53 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# 3x-ui-agent 主控一键安装脚本
# 用法: bash install-master.sh
# 要求: Debian/Ubuntu/CentOS amd64, root 运行
set -e
RED='\033[0;31m'; GREEN='\033[0;32m'; NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
[[ $EUID -ne 0 ]] && error "请用 root 运行"
ARCH=$(uname -m)
[[ "$ARCH" != "x86_64" && "$ARCH" != "amd64" ]] && error "只支持 amd64, 当前: $ARCH"
# 二进制下载地址(GitHub release,替换为实际地址)
XUI_URL="${XUI_URL:-https://github.com/imamoxilin/3x-ui-diy/releases/download/v3.7.0-agent.1/x-ui-linux-amd64}"
XRAY_VER="26.6.27"
info "创建目录..."
mkdir -p /usr/local/x-ui/bin /etc/x-ui
info "下载主控二进制..."
curl -fL -o /usr/local/x-ui/x-ui "$XUI_URL" || error "主控下载失败"
chmod +x /usr/local/x-ui/x-ui
info "下载 xray v${XRAY_VER}..."
cd /usr/local/x-ui/bin
curl -fL -o Xray-linux-64.zip "https://github.com/XTLS/Xray-core/releases/download/v${XRAY_VER}/Xray-linux-64.zip" || error "xray 下载失败"
unzip -o -q Xray-linux-64.zip xray && mv xray xray-linux-amd64 && chmod +x xray-linux-amd64
rm -f Xray-linux-64.zip
info "下载 geo 文件..."
curl -fL -o geoip.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" || error "geoip 下载失败"
curl -fL -o geosite.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" || error "geosite 下载失败"
info "启动主控..."
cd /usr/local/x-ui
pkill -f "/usr/local/x-ui/x-ui" 2>/dev/null; sleep 1
nohup ./x-ui > /tmp/xui.log 2>&1 &
sleep 5
if ss -tlnp 2>/dev/null | grep -q ":2053"; then
info "主控启动成功!"
echo ""
echo " 面板地址: http://$(hostname -I | awk '{print $1}'):2053"
echo " 默认账号: admin / admin"
echo " 请登录后立即修改密码"
else
error "启动失败,查看日志: cat /tmp/xui.log"
fi