├── LICENSE ├── README.md └── xray_2go.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 eooce 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xray-argo无交互一键四协议安装脚本 2 | 最好用的一键xray-argo脚本,一键四协议无交互安装脚本! 3 | * vless-grpc-reality | vless-ws-tls(argo) | vmess-ws-tls(argo) | vmess-xhttp 4 | 5 | ### 支持系统列表: 6 | >Debian 7 | >Ubuntu 8 | >CentOS 9 | >Alpine 10 | >Fedora 11 | >Alma-linux 12 | >Rocky-linux 13 | >Amazom-linux 14 | 15 | *** 16 | * xhttp目前支持的客户端较少,需更新V2rayN到新版,splithttp已启用,改为xhttp 17 | * 可选环境变量:UUID PORT CFIP CFPORT 自定义变量放脚本前面运行即可 18 | * NAT小鸡需带PORT变量运行并确保PORT之后的1个端口可用,或运行完后更改订阅端口和grpc-reality端口 19 | 20 | ``` 21 | bash <(curl -Ls https://github.com/eooce/xray-2go/raw/main/xray_2go.sh) 22 | ``` 23 | 24 | 带变量运行示例,修改为自己需要定义的参数 25 | ``` 26 | PORT=8888 CFIP=www.visa.com.tw CFPORT=8443 bash <(curl -Ls https://github.com/eooce/xray-2go/raw/main/xray_2go.sh) 27 | ``` 28 | 29 | # 免责声明 30 | * 本程序仅供学习了解, 非盈利目的,请于下载后 24 小时内删除, 不得用作任何商业用途, 文字、数据及图片均有所属版权, 如转载须注明来源。 31 | * 使用本程序必循遵守部署免责声明,使用本程序必循遵守部署服务器所在地、所在国家和用户所在国家的法律法规, 程序作者不对使用者任何不当行为负责。 32 | -------------------------------------------------------------------------------- /xray_2go.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 定义颜色 4 | re="\033[0m" 5 | red="\033[1;91m" 6 | green="\e[1;32m" 7 | yellow="\e[1;33m" 8 | purple="\e[1;35m" 9 | skybule="\e[1;36m" 10 | red() { echo -e "\e[1;91m$1\033[0m"; } 11 | green() { echo -e "\e[1;32m$1\033[0m"; } 12 | yellow() { echo -e "\e[1;33m$1\033[0m"; } 13 | purple() { echo -e "\e[1;35m$1\033[0m"; } 14 | skyblue() { echo -e "\e[1;36m$1\033[0m"; } 15 | reading() { read -p "$(red "$1")" "$2"; } 16 | 17 | # 定义常量 18 | server_name="xray" 19 | work_dir="/etc/xray" 20 | config_dir="${work_dir}/config.json" 21 | client_dir="${work_dir}/url.txt" 22 | # 定义环境变量 23 | export UUID=${UUID:-$(cat /proc/sys/kernel/random/uuid)} 24 | export PORT=${PORT:-$(shuf -i 1000-60000 -n 1)} 25 | export ARGO_PORT=${ARGO_PORT:-'8080'} 26 | export CFIP=${CFIP:-'www.visa.com.tw'} 27 | export CFPORT=${CFPORT:-'443'} 28 | 29 | # 检查是否为root下运行 30 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 31 | 32 | # 检查 xray 是否已安装 33 | check_xray() { 34 | if [ -f "${work_dir}/${server_name}" ]; then 35 | if [ -f /etc/alpine-release ]; then 36 | rc-service xray status | grep -q "started" && green "running" && return 0 || yellow "not running" && return 1 37 | else 38 | [ "$(systemctl is-active xray)" = "active" ] && green "running" && return 0 || yellow "not running" && return 1 39 | fi 40 | else 41 | red "not installed" 42 | return 2 43 | fi 44 | } 45 | 46 | # 检查 argo 是否已安装 47 | check_argo() { 48 | if [ -f "${work_dir}/argo" ]; then 49 | if [ -f /etc/alpine-release ]; then 50 | rc-service tunnel status | grep -q "started" && green "running" && return 0 || yellow "not running" && return 1 51 | else 52 | [ "$(systemctl is-active tunnel)" = "active" ] && green "running" && return 0 || yellow "not running" && return 1 53 | fi 54 | else 55 | red "not installed" 56 | return 2 57 | fi 58 | } 59 | 60 | # 检查 caddy 是否已安装 61 | check_caddy() { 62 | if command -v caddy &>/dev/null; then 63 | if [ -f /etc/alpine-release ]; then 64 | rc-service caddy status | grep -q "started" && green "running" && return 0 || yellow "not running" && return 1 65 | else 66 | [ "$(systemctl is-active caddy)" = "active" ] && green "running" && return 0 || yellow "not running" && return 1 67 | fi 68 | else 69 | red "not installed" 70 | return 2 71 | fi 72 | } 73 | 74 | #根据系统类型安装、卸载依赖 75 | manage_packages() { 76 | if [ $# -lt 2 ]; then 77 | red "Unspecified package name or action" 78 | return 1 79 | fi 80 | 81 | action=$1 82 | shift 83 | 84 | for package in "$@"; do 85 | if [ "$action" == "install" ]; then 86 | if command -v "$package" &>/dev/null; then 87 | green "${package} already installed" 88 | continue 89 | fi 90 | yellow "正在安装 ${package}..." 91 | if command -v apt &>/dev/null; then 92 | DEBIAN_FRONTEND=noninteractive apt install -y "$package" 93 | elif command -v dnf &>/dev/null; then 94 | dnf install -y "$package" 95 | elif command -v yum &>/dev/null; then 96 | yum install -y "$package" 97 | elif command -v apk &>/dev/null; then 98 | apk update 99 | apk add "$package" 100 | else 101 | red "Unknown system!" 102 | return 1 103 | fi 104 | elif [ "$action" == "uninstall" ]; then 105 | if ! command -v "$package" &>/dev/null; then 106 | yellow "${package} is not installed" 107 | continue 108 | fi 109 | yellow "正在卸载 ${package}..." 110 | if command -v apt &>/dev/null; then 111 | apt remove -y "$package" && apt autoremove -y 112 | elif command -v dnf &>/dev/null; then 113 | dnf remove -y "$package" && dnf autoremove -y 114 | elif command -v yum &>/dev/null; then 115 | yum remove -y "$package" && yum autoremove -y 116 | elif command -v apk &>/dev/null; then 117 | apk del "$package" 118 | else 119 | red "Unknown system!" 120 | return 1 121 | fi 122 | else 123 | red "Unknown action: $action" 124 | return 1 125 | fi 126 | done 127 | 128 | return 0 129 | } 130 | 131 | # 获取ip 132 | get_realip() { 133 | ip=$(curl -s --max-time 2 ipv4.ip.sb) 134 | if [ -z "$ip" ]; then 135 | ipv6=$(curl -s --max-time 2 ipv6.ip.sb) 136 | echo "[$ipv6]" 137 | else 138 | if echo "$(curl -s http://ipinfo.io/org)" | grep -qE 'Cloudflare|UnReal|AEZA|Andrei'; then 139 | ipv6=$(curl -s --max-time 2 ipv6.ip.sb) 140 | echo "[$ipv6]" 141 | else 142 | echo "$ip" 143 | fi 144 | fi 145 | } 146 | 147 | # 下载并安装 xray,cloudflared 148 | install_xray() { 149 | clear 150 | purple "正在安装Xray-2go中,请稍等..." 151 | ARCH_RAW=$(uname -m) 152 | case "${ARCH_RAW}" in 153 | 'x86_64') ARCH='amd64'; ARCH_ARG='64' ;; 154 | 'x86' | 'i686' | 'i386') ARCH='386'; ARCH_ARG='32' ;; 155 | 'aarch64' | 'arm64') ARCH='arm64'; ARCH_ARG='arm64-v8a' ;; 156 | 'armv7l') ARCH='armv7'; ARCH_ARG='arm32-v7a' ;; 157 | 's390x') ARCH='s390x' ;; 158 | *) red "不支持的架构: ${ARCH_RAW}"; exit 1 ;; 159 | esac 160 | 161 | # 下载sing-box,cloudflared 162 | [ ! -d "${work_dir}" ] && mkdir -p "${work_dir}" && chmod 777 "${work_dir}" 163 | curl -sLo "${work_dir}/${server_name}.zip" "https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-${ARCH_ARG}.zip" 164 | curl -sLo "${work_dir}/qrencode" "https://github.com/eooce/test/releases/download/${ARCH}/qrencode-linux-${ARCH}" 165 | curl -sLo "${work_dir}/argo" "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-${ARCH}" 166 | unzip "${work_dir}/${server_name}.zip" -d "${work_dir}/" > /dev/null 2>&1 && chmod +x ${work_dir}/${server_name} ${work_dir}/argo ${work_dir}/qrencode 167 | rm -rf "${work_dir}/${server_name}.zip" "${work_dir}/geosite.dat" "${work_dir}/geoip.dat" "${work_dir}/README.md" "${work_dir}/LICENSE" 168 | 169 | # 生成随机UUID和密码 170 | password=$(< /dev/urandom tr -dc 'A-Za-z0-9' | head -c 24) 171 | GRPC_PORT=$((PORT + 1)) 172 | 173 | # 关闭防火墙 174 | iptables -F > /dev/null 2>&1 && iptables -P INPUT ACCEPT > /dev/null 2>&1 && iptables -P FORWARD ACCEPT > /dev/null 2>&1 && iptables -P OUTPUT ACCEPT > /dev/null 2>&1 175 | command -v ip6tables &> /dev/null && ip6tables -F > /dev/null 2>&1 && ip6tables -P INPUT ACCEPT > /dev/null 2>&1 && ip6tables -P FORWARD ACCEPT > /dev/null 2>&1 && ip6tables -P OUTPUT ACCEPT > /dev/null 2>&1 176 | 177 | output=$(/etc/xray/xray x25519) 178 | private_key=$(echo "$output" | grep "Private key" | awk '{print $3}') 179 | public_key=$(echo "$output" | grep "Public key" | awk '{print $3}') 180 | 181 | # 生成配置文件 182 | cat > "${config_dir}" << EOF 183 | { 184 | "log": { "access": "/dev/null", "error": "/dev/null", "loglevel": "none" }, 185 | "inbounds": [ 186 | { 187 | "port": $ARGO_PORT, 188 | "protocol": "vless", 189 | "settings": { 190 | "clients": [{ "id": "$UUID", "flow": "xtls-rprx-vision" }], 191 | "decryption": "none", 192 | "fallbacks": [ 193 | { "dest": 3001 }, { "path": "/vless-argo", "dest": 3002 }, 194 | { "path": "/vmess-argo", "dest": 3003 }, { "path": "", "dest": 3004 } 195 | ] 196 | }, 197 | "streamSettings": { "network": "tcp" } 198 | }, 199 | { 200 | "port": 3001, "listen": "127.0.0.1", "protocol": "vless", 201 | "settings": { "clients": [{ "id": "$UUID" }], "decryption": "none" }, 202 | "streamSettings": { "network": "tcp", "security": "none" } 203 | }, 204 | { 205 | "port": 3002, "listen": "127.0.0.1", "protocol": "vless", 206 | "settings": { "clients": [{ "id": "$UUID", "level": 0 }], "decryption": "none" }, 207 | "streamSettings": { "network": "ws", "security": "none", "wsSettings": { "path": "/vless-argo" } }, 208 | "sniffing": { "enabled": true, "destOverride": ["http", "tls", "quic"], "metadataOnly": false } 209 | }, 210 | { 211 | "port": 3003, "listen": "127.0.0.1", "protocol": "vmess", 212 | "settings": { "clients": [{ "id": "$UUID", "alterId": 0 }] }, 213 | "streamSettings": { "network": "ws", "wsSettings": { "path": "/vmess-argo" } }, 214 | "sniffing": { "enabled": true, "destOverride": ["http", "tls", "quic"], "metadataOnly": false } 215 | }, 216 | { 217 | "port": 3004, "listen": "127.0.0.1", "protocol": "vmess", 218 | "settings": {"clients": [{"id": "$UUID", "alterId": 0, "security": "auto"}]}, 219 | "streamSettings": {"network": "xhttp", "security": "none", "xhttpSettings": {"host": "", "path": ""}}, 220 | "sniffing": {"enabled": true, "destOverride": ["http", "tls", "quic"], "metadataOnly": false} 221 | }, 222 | { 223 | "listen":"::","port":$GRPC_PORT,"protocol":"vless","settings":{"clients":[{"id":"$UUID"}],"decryption":"none"},"streamSettings":{"network":"grpc","security":"reality","realitySettings":{"dest":"www.iij.ad.jp:443","serverNames":["www.iij.ad.jp"],"privateKey":"$private_key","shortIds":[""]},"grpcSettings":{"serviceName":"grpc"}},"sniffing":{"enabled":true,"destOverride":["http","tls","quic"]}} 224 | ], 225 | "dns": { "servers": ["https+local://8.8.8.8/dns-query"] }, 226 | "outbounds": [ 227 | { 228 | "protocol": "freedom", 229 | "tag": "direct" 230 | }, 231 | { 232 | "protocol": "blackhole", 233 | "tag": "block" 234 | } 235 | ] 236 | } 237 | EOF 238 | } 239 | # debian/ubuntu/centos 守护进程 240 | main_systemd_services() { 241 | cat > /etc/systemd/system/xray.service << EOF 242 | [Unit] 243 | Description=Xray Service 244 | Documentation=https://github.com/XTLS/Xray-core 245 | After=network.target nss-lookup.target 246 | Wants=network-online.target 247 | 248 | [Service] 249 | Type=simple 250 | NoNewPrivileges=yes 251 | ExecStart=$work_dir/xray run -c $config_dir 252 | Restart=on-failure 253 | RestartPreventExitStatus=23 254 | 255 | [Install] 256 | WantedBy=multi-user.target 257 | EOF 258 | 259 | cat > /etc/systemd/system/tunnel.service << EOF 260 | [Unit] 261 | Description=Cloudflare Tunnel 262 | After=network.target 263 | 264 | [Service] 265 | Type=simple 266 | NoNewPrivileges=yes 267 | TimeoutStartSec=0 268 | ExecStart=/etc/xray/argo tunnel --url http://localhost:$ARGO_PORT --no-autoupdate --edge-ip-version auto --protocol http2 269 | StandardOutput=append:/etc/xray/argo.log 270 | Restart=on-failure 271 | RestartSec=5s 272 | 273 | [Install] 274 | WantedBy=multi-user.target 275 | 276 | EOF 277 | if [ -f /etc/centos-release ]; then 278 | yum install -y chrony 279 | systemctl start chronyd 280 | systemctl enable chronyd 281 | chronyc -a makestep 282 | yum update -y ca-certificates 283 | bash -c 'echo "0 0" > /proc/sys/net/ipv4/ping_group_range' 284 | fi 285 | bash -c 'echo "0 0" > /proc/sys/net/ipv4/ping_group_range' 286 | systemctl daemon-reload 287 | systemctl enable xray 288 | systemctl start xray 289 | systemctl enable tunnel 290 | systemctl start tunnel 291 | } 292 | # 适配alpine 守护进程 293 | alpine_openrc_services() { 294 | cat > /etc/init.d/xray << 'EOF' 295 | #!/sbin/openrc-run 296 | 297 | description="Xray service" 298 | command="/etc/xray/xray" 299 | command_args="run -c /etc/xray/config.json" 300 | command_background=true 301 | pidfile="/var/run/xray.pid" 302 | EOF 303 | 304 | cat > /etc/init.d/tunnel << 'EOF' 305 | #!/sbin/openrc-run 306 | 307 | description="Cloudflare Tunnel" 308 | command="/bin/sh" 309 | command_args="-c '/etc/xray/argo tunnel --url http://localhost:8080 --no-autoupdate --edge-ip-version auto --protocol http2 > /etc/xray/argo.log 2>&1'" 310 | command_background=true 311 | pidfile="/var/run/tunnel.pid" 312 | EOF 313 | 314 | chmod +x /etc/init.d/xray 315 | chmod +x /etc/init.d/tunnel 316 | 317 | rc-update add xray default 318 | rc-update add tunnel default 319 | 320 | } 321 | 322 | 323 | get_info() { 324 | clear 325 | IP=$(get_realip) 326 | 327 | isp=$(curl -s --max-time 2 https://speed.cloudflare.com/meta | awk -F\" '{print $26"-"$18}' | sed -e 's/ /_/g' || echo "vps") 328 | 329 | if [ -f "${work_dir}/argo.log" ]; then 330 | for i in {1..5}; do 331 | purple "第 $i 次尝试获取ArgoDoamin中..." 332 | argodomain=$(sed -n 's|.*https://\([^/]*trycloudflare\.com\).*|\1|p' "${work_dir}/argo.log") 333 | [ -n "$argodomain" ] && break 334 | sleep 2 335 | done 336 | else 337 | restart_argo 338 | sleep 6 339 | argodomain=$(sed -n 's|.*https://\([^/]*trycloudflare\.com\).*|\1|p' "${work_dir}/argo.log") 340 | fi 341 | 342 | green "\nArgoDomain:${purple}$argodomain${re}\n" 343 | 344 | cat > ${work_dir}/url.txt < ${work_dir}/sub.txt 356 | yellow "\n温馨提醒:如果是NAT机,reality端口和订阅端口需使用可用端口范围内的端口,否则reality协议不通,无法订阅\n" 357 | green "节点订阅链接:http://$IP:$PORT/$password\n\n订阅链接适用于V2rayN,Nekbox,karing,Sterisand,Loon,小火箭,圈X等\n" 358 | green "订阅二维码" 359 | $work_dir/qrencode "http://$IP:$PORT/$password" 360 | echo "" 361 | } 362 | 363 | # 处理ubuntu系统中没有caddy源的问题 364 | install_caddy () { 365 | if [ -f /etc/os-release ] && (grep -q "Ubuntu" /etc/os-release || grep -q "Debian GNU/Linux 11" /etc/os-release); then 366 | purple "安装依赖中...\n" 367 | apt install -y debian-keyring debian-archive-keyring apt-transport-https 368 | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | tee /etc/apt/trusted.gpg.d/caddy-stable.asc 369 | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list 370 | rm /etc/apt/trusted.gpg.d/caddy-stable.asc /usr/share/keyrings/caddy-archive-keyring.gpg 2>/dev/null 371 | curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/gpg.key | gpg --dearmor -o /usr/share/keyrings/caddy-archive-keyring.gpg 372 | echo "deb [signed-by=/usr/share/keyrings/caddy-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | tee /etc/apt/sources.list.d/caddy-stable.list 373 | DEBIAN_FRONTEND=noninteractive apt update -y && manage_packages install caddy 374 | else 375 | manage_packages install caddy 376 | fi 377 | } 378 | 379 | # caddy订阅配置 380 | add_caddy_conf() { 381 | [ -f /etc/caddy/Caddyfile ] && cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak 382 | rm -rf /etc/caddy/Caddyfile 383 | cat > /etc/caddy/Caddyfile << EOF 384 | { 385 | auto_https off 386 | log { 387 | output file /var/log/caddy/caddy.log { 388 | roll_size 10MB 389 | roll_keep 10 390 | roll_keep_for 720h 391 | } 392 | } 393 | } 394 | 395 | :$PORT { 396 | handle /$password { 397 | root * /etc/xray 398 | try_files /sub.txt 399 | file_server browse 400 | header Content-Type "text/plain; charset=utf-8" 401 | } 402 | 403 | handle { 404 | respond "404 Not Found" 404 405 | } 406 | } 407 | EOF 408 | 409 | /usr/bin/caddy validate --config /etc/caddy/Caddyfile > /dev/null 2>&1 410 | 411 | if [ $? -eq 0 ]; then 412 | if [ -f /etc/alpine-release ]; then 413 | rc-service caddy restart 414 | else 415 | systemctl daemon-reload 416 | systemctl restart caddy 417 | fi 418 | else 419 | [ -f /etc/alpine-release ] && rc-service caddy restart > /dev/null 2>&1 || red "Caddy 配置文件验证失败,订阅功能可能无法使用,但不影响节点使用\nissues 反馈:https://github.com/eooce/xray-argo/issues\n" 420 | fi 421 | } 422 | 423 | 424 | # 启动 xray 425 | start_xray() { 426 | if [ ${check_xray} -eq 1 ]; then 427 | yellow "\n正在启动 ${server_name} 服务\n" 428 | if [ -f /etc/alpine-release ]; then 429 | rc-service xray start 430 | else 431 | systemctl daemon-reload 432 | systemctl start "${server_name}" 433 | fi 434 | if [ $? -eq 0 ]; then 435 | green "${server_name} 服务已成功启动\n" 436 | else 437 | red "${server_name} 服务启动失败\n" 438 | fi 439 | elif [ ${check_xray} -eq 0 ]; then 440 | yellow "xray 正在运行\n" 441 | sleep 1 442 | menu 443 | else 444 | yellow "xray 尚未安装!\n" 445 | sleep 1 446 | menu 447 | fi 448 | } 449 | 450 | # 停止 xray 451 | stop_xray() { 452 | if [ ${check_xray} -eq 0 ]; then 453 | yellow "\n正在停止 ${server_name} 服务\n" 454 | if [ -f /etc/alpine-release ]; then 455 | rc-service xray stop 456 | else 457 | systemctl stop "${server_name}" 458 | fi 459 | if [ $? -eq 0 ]; then 460 | green "${server_name} 服务已成功停止\n" 461 | else 462 | red "${server_name} 服务停止失败\n" 463 | fi 464 | 465 | elif [ ${check_xray} -eq 1 ]; then 466 | yellow "xray 未运行\n" 467 | sleep 1 468 | menu 469 | else 470 | yellow "xray 尚未安装!\n" 471 | sleep 1 472 | menu 473 | fi 474 | } 475 | 476 | # 重启 xray 477 | restart_xray() { 478 | if [ ${check_xray} -eq 0 ]; then 479 | yellow "\n正在重启 ${server_name} 服务\n" 480 | if [ -f /etc/alpine-release ]; then 481 | rc-service ${server_name} restart 482 | else 483 | systemctl daemon-reload 484 | systemctl restart "${server_name}" 485 | fi 486 | if [ $? -eq 0 ]; then 487 | green "${server_name} 服务已成功重启\n" 488 | else 489 | red "${server_name} 服务重启失败\n" 490 | fi 491 | elif [ ${check_xray} -eq 1 ]; then 492 | yellow "xray 未运行\n" 493 | sleep 1 494 | menu 495 | else 496 | yellow "xray 尚未安装!\n" 497 | sleep 1 498 | menu 499 | fi 500 | } 501 | 502 | # 启动 argo 503 | start_argo() { 504 | if [ ${check_argo} -eq 1 ]; then 505 | yellow "\n正在启动 Argo 服务\n" 506 | if [ -f /etc/alpine-release ]; then 507 | rc-service tunnel start 508 | else 509 | systemctl daemon-reload 510 | systemctl start tunnel 511 | fi 512 | if [ $? -eq 0 ]; then 513 | green "Argo 服务已成功重启\n" 514 | else 515 | red "Argo 服务重启失败\n" 516 | fi 517 | elif [ ${check_argo} -eq 0 ]; then 518 | green "Argo 服务正在运行\n" 519 | sleep 1 520 | menu 521 | else 522 | yellow "Argo 尚未安装!\n" 523 | sleep 1 524 | menu 525 | fi 526 | } 527 | 528 | # 停止 argo 529 | stop_argo() { 530 | if [ ${check_argo} -eq 0 ]; then 531 | yellow "\n正在停止 Argo 服务\n" 532 | if [ -f /etc/alpine-release ]; then 533 | rc-service stop start 534 | else 535 | systemctl daemon-reload 536 | systemctl stop tunnel 537 | fi 538 | if [ $? -eq 0 ]; then 539 | green "Argo 服务已成功停止\n" 540 | else 541 | red "Argo 服务停止失败\n" 542 | fi 543 | elif [ ${check_argo} -eq 1 ]; then 544 | yellow "Argo 服务未运行\n" 545 | sleep 1 546 | menu 547 | else 548 | yellow "Argo 尚未安装!\n" 549 | sleep 1 550 | menu 551 | fi 552 | } 553 | 554 | # 重启 argo 555 | restart_argo() { 556 | if [ ${check_argo} -eq 0 ]; then 557 | yellow "\n正在重启 Argo 服务\n" 558 | rm /etc/xray/argo.log 2>/dev/null 559 | if [ -f /etc/alpine-release ]; then 560 | rc-service tunnel restart 561 | else 562 | systemctl daemon-reload 563 | systemctl restart tunnel 564 | fi 565 | if [ $? -eq 0 ]; then 566 | green "Argo 服务已成功重启\n" 567 | else 568 | red "Argo 服务重启失败\n" 569 | fi 570 | elif [ ${check_argo} -eq 1 ]; then 571 | yellow "Argo 服务未运行\n" 572 | sleep 1 573 | menu 574 | else 575 | yellow "Argo 尚未安装!\n" 576 | sleep 1 577 | menu 578 | fi 579 | } 580 | 581 | # 启动 caddy 582 | start_caddy() { 583 | if command -v caddy &>/dev/null; then 584 | yellow "\n正在启动 caddy 服务\n" 585 | if [ -f /etc/alpine-release ]; then 586 | rc-service caddy start 587 | else 588 | systemctl daemon-reload 589 | systemctl start caddy 590 | fi 591 | if [ $? -eq 0 ]; then 592 | green "caddy 服务已成功启动\n" 593 | else 594 | red "caddy 启动失败\n" 595 | fi 596 | else 597 | yellow "caddy 尚未安装!\n" 598 | sleep 1 599 | menu 600 | fi 601 | } 602 | 603 | # 重启 caddy 604 | restart_caddy() { 605 | if command -v caddy &>/dev/null; then 606 | yellow "\n正在重启 caddy 服务\n" 607 | if [ -f /etc/alpine-release ]; then 608 | rc-service caddy restart 609 | else 610 | systemctl restart caddy 611 | fi 612 | if [ $? -eq 0 ]; then 613 | green "caddy 服务已成功重启\n" 614 | else 615 | red "caddy 重启失败\n" 616 | fi 617 | else 618 | yellow "caddy 尚未安装!\n" 619 | sleep 1 620 | menu 621 | fi 622 | } 623 | 624 | # 卸载 xray 625 | uninstall_xray() { 626 | reading "确定要卸载 xray-2go 吗? (y/n): " choice 627 | case "${choice}" in 628 | y|Y) 629 | yellow "正在卸载 xray" 630 | if [ -f /etc/alpine-release ]; then 631 | rc-service xray stop 632 | rc-service tunnel stop 633 | rm /etc/init.d/xray /etc/init.d/tunnel 634 | rc-update del xray default 635 | rc-update del tunnel default 636 | else 637 | # 停止 xray和 argo 服务 638 | systemctl stop "${server_name}" 639 | systemctl stop tunnel 640 | # 禁用 xray 服务 641 | systemctl disable "${server_name}" 642 | systemctl disable tunnel 643 | 644 | # 重新加载 systemd 645 | systemctl daemon-reload || true 646 | fi 647 | # 删除配置文件和日志 648 | rm -rf "${work_dir}" || true 649 | rm -rf /etc/systemd/system/xray.service /etc/systemd/system/tunnel.service 2>/dev/null 650 | 651 | # 卸载caddy 652 | reading "\n是否卸载 caddy?${green}(卸载请输入 ${yellow}y${re} ${green}回车将跳过卸载caddy) (y/n): ${re}" choice 653 | case "${choice}" in 654 | y|Y) 655 | manage_packages uninstall caddy 656 | ;; 657 | *) 658 | yellow "取消卸载caddy\n" 659 | ;; 660 | esac 661 | 662 | green "\nXray_2go 卸载成功\n" 663 | ;; 664 | *) 665 | purple "已取消卸载操作\n" 666 | ;; 667 | esac 668 | } 669 | 670 | # 创建快捷指令 671 | create_shortcut() { 672 | cat > "$work_dir/2go.sh" << EOF 673 | #!/usr/bin/env bash 674 | 675 | bash <(curl -Ls https://github.com/eooce/xray-2go/raw/main/xray_2go.sh) \$1 676 | EOF 677 | chmod +x "$work_dir/2go.sh" 678 | ln -sf "$work_dir/2go.sh" /usr/bin/2go 679 | if [ -s /usr/bin/2go ]; then 680 | green "\n快捷指令 2go 创建成功\n" 681 | else 682 | red "\n快捷指令创建失败\n" 683 | fi 684 | } 685 | 686 | # 适配alpine运行argo报错用户组和dns的问题 687 | change_hosts() { 688 | sh -c 'echo "0 0" > /proc/sys/net/ipv4/ping_group_range' 689 | sed -i '1s/.*/127.0.0.1 localhost/' /etc/hosts 690 | sed -i '2s/.*/::1 localhost/' /etc/hosts 691 | } 692 | 693 | # 变更配置 694 | change_config() { 695 | clear 696 | echo "" 697 | green "1. 修改UUID" 698 | skyblue "------------" 699 | green "2. 修改grpc-reality端口" 700 | skyblue "------------" 701 | green "3. 修改grpc-reality伪装域名" 702 | skyblue "------------" 703 | purple "${purple}4. 返回主菜单" 704 | skyblue "------------" 705 | reading "请输入选择: " choice 706 | case "${choice}" in 707 | 1) 708 | reading "\n请输入新的UUID: " new_uuid 709 | [ -z "$new_uuid" ] && new_uuid=$(cat /proc/sys/kernel/random/uuid) && green "\n生成的UUID为:$new_uuid" 710 | sed -i "s/[a-fA-F0-9]\{8\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{12\}/$new_uuid/g" $config_dir 711 | restart_xray 712 | sed -i "s/[a-fA-F0-9]\{8\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{12\}/$new_uuid/g" $client_dir 713 | content=$(cat "$client_dir") 714 | vmess_urls=$(grep -o 'vmess://[^ ]*' "$client_dir") 715 | vmess_prefix="vmess://" 716 | for vmess_url in $vmess_urls; do 717 | encoded_vmess="${vmess_url#"$vmess_prefix"}" 718 | decoded_vmess=$(echo "$encoded_vmess" | base64 --decode) 719 | updated_vmess=$(echo "$decoded_vmess" | jq --arg new_uuid "$new_uuid" '.id = $new_uuid') 720 | encoded_updated_vmess=$(echo "$updated_vmess" | base64 | tr -d '\n') 721 | new_vmess_url="$vmess_prefix$encoded_updated_vmess" 722 | content=$(echo "$content" | sed "s|$vmess_url|$new_vmess_url|") 723 | done 724 | echo "$content" > "$client_dir" 725 | base64 -w0 $client_dir > /etc/xray/sub.txt 726 | while IFS= read -r line; do yellow "$line"; done < $client_dir 727 | green "\nUUID已修改为:${purple}${new_uuid}${re} ${green}请更新订阅或手动更改所有节点的UUID${re}\n" 728 | ;; 729 | 2) 730 | reading "\n请输入grpc-reality端口 (回车跳过将使用随机端口): " new_port 731 | [ -z "$new_port" ] && new_port=$(shuf -i 2000-65000 -n 1) 732 | until [[ -z $(netstat -tuln | grep -w tcp | awk '{print $4}' | sed 's/.*://g' | grep -w "$new_port") ]]; do 733 | if [[ -n $(netstat -tuln | grep -w tcp | awk '{print $4}' | sed 's/.*://g' | grep -w "$new_port") ]]; then 734 | echo -e "${red}${new_port}端口已经被其他程序占用,请更换端口重试${re}" 735 | reading "请输入新的订阅端口(1-65535):" new_port 736 | [[ -z $new_port ]] && new_port=$(shuf -i 2000-65000 -n 1) 737 | fi 738 | done 739 | sed -i "41s/\"port\":\s*[0-9]\+/\"port\": $new_port/" /etc/xray/config.json 740 | restart_xray 741 | sed -i '1s/\(vless:\/\/[^@]*@[^:]*:\)[0-9]\{1,\}/\1'"$new_port"'/' $client_dir 742 | base64 -w0 $client_dir > /etc/xray/sub.txt 743 | while IFS= read -r line; do yellow "$line"; done < ${work_dir}/url.txt 744 | green "\nGRPC-reality端口已修改成:${purple}$new_port${re} ${green}请更新订阅或手动更改grpc-reality节点端口${re}\n" 745 | ;; 746 | 3) 747 | clear 748 | green "\n1. bgk.jp\n\n2. www.joom.com\n\n3. www.stengg.com\n\n4. www.nazhumi.com\n" 749 | reading "\n请输入新的Reality伪装域名(可自定义输入,回车留空将使用默认1): " new_sni 750 | if [ -z "$new_sni" ]; then 751 | new_sni="bgk.jp" 752 | elif [[ "$new_sni" == "1" ]]; then 753 | new_sni="bgk.jp" 754 | elif [[ "$new_sni" == "2" ]]; then 755 | new_sni="www.joom.com" 756 | elif [[ "$new_sni" == "3" ]]; then 757 | new_sni="www.stengg.com" 758 | elif [[ "$new_sni" == "4" ]]; then 759 | new_sni="www.nazhumi.com" 760 | else 761 | new_sni="$new_sni" 762 | fi 763 | jq --arg new_sni "$new_sni" '.inbounds[5].streamSettings.realitySettings.dest = ($new_sni + ":443") | .inbounds[5].streamSettings.realitySettings.serverNames = [$new_sni]' /etc/xray/config.json > /etc/xray/config.json.tmp && mv /etc/xray/config.json.tmp /etc/xray/config.json 764 | restart_xray 765 | sed -i "1s/\(vless:\/\/[^\?]*\?\([^\&]*\&\)*sni=\)[^&]*/\1$new_sni/" $client_dir 766 | sed -i "1s/\(vless:\/\/[^\?]*\?\([^\&]*\&\)*authority=\)[^&]*/\1$new_sni/" $client_dir 767 | base64 -w0 $client_dir > /etc/xray/sub.txt 768 | while IFS= read -r line; do yellow "$line"; done < ${work_dir}/url.txt 769 | echo "" 770 | green "\nReality sni已修改为:${purple}${new_sni}${re} ${green}请更新订阅或手动更改reality节点的sni域名${re}\n" 771 | ;; 772 | 4) menu ;; 773 | *) read "无效的选项!" ;; 774 | esac 775 | } 776 | 777 | disable_open_sub() { 778 | if [ ${check_xray} -eq 0 ]; then 779 | clear 780 | echo "" 781 | green "1. 关闭节点订阅" 782 | skyblue "------------" 783 | green "2. 开启节点订阅" 784 | skyblue "------------" 785 | green "3. 更换订阅端口" 786 | skyblue "------------" 787 | purple "4. 返回主菜单" 788 | skyblue "------------" 789 | reading "请输入选择: " choice 790 | case "${choice}" in 791 | 1) 792 | if command -v caddy &>/dev/null; then 793 | if [ -f /etc/alpine-release ]; then 794 | rc-service caddy status | grep -q "started" && rc-service caddy stop || red "caddy not running" 795 | else 796 | [ "$(systemctl is-active caddy)" = "active" ] && systemctl stop caddy || red "ngixn not running" 797 | fi 798 | else 799 | yellow "caddy is not installed" 800 | fi 801 | 802 | green "\n已关闭节点订阅\n" 803 | ;; 804 | 2) 805 | green "\n已开启节点订阅\n" 806 | server_ip=$(get_realip) 807 | password=$(tr -dc A-Za-z < /dev/urandom | head -c 32) 808 | sed -i "s/\/[a-zA-Z0-9]\+/\/$password/g" /etc/caddy/Caddyfile 809 | sub_port=$(port=$(grep -oP ':\K[0-9]+' /etc/caddy/Caddyfile); if [ "$port" -eq 80 ]; then echo ""; else echo "$port"; fi) 810 | start_caddy 811 | (port=$(grep -oP ':\K[0-9]+' /etc/caddy/Caddyfile); if [ "$port" -eq 80 ]; then echo ""; else green "订阅端口:$port"; fi); link=$(if [ -z "$sub_port" ]; then echo "http://$server_ip/$password"; else echo "http://$server_ip:$sub_port/$password"; fi); green "\n新的节点订阅链接:$link\n" 812 | ;; 813 | 814 | 3) 815 | reading "请输入新的订阅端口(1-65535):" sub_port 816 | [ -z "$sub_port" ] && sub_port=$(shuf -i 2000-65000 -n 1) 817 | until [[ -z $(netstat -tuln | grep -w tcp | awk '{print $4}' | sed 's/.*://g' | grep -w "$sub_port") ]]; do 818 | if [[ -n $(netstat -tuln | grep -w tcp | awk '{print $4}' | sed 's/.*://g' | grep -w "$sub_port") ]]; then 819 | echo -e "${red}${new_port}端口已经被其他程序占用,请更换端口重试${re}" 820 | reading "请输入新的订阅端口(1-65535):" sub_port 821 | [[ -z $sub_port ]] && sub_port=$(shuf -i 2000-65000 -n 1) 822 | fi 823 | done 824 | sed -i "s/:[0-9]\+/:$sub_port/g" /etc/caddy/Caddyfile 825 | path=$(sed -n 's/.*handle \/\([^ ]*\).*/\1/p' /etc/caddy/Caddyfile) 826 | server_ip=$(get_realip) 827 | restart_caddy 828 | green "\n订阅端口更换成功\n" 829 | green "新的订阅链接为:http://$server_ip:$sub_port/$path\n" 830 | ;; 831 | 4) menu ;; 832 | *) red "无效的选项!" ;; 833 | esac 834 | else 835 | yellow "xray—2go 尚未安装!" 836 | sleep 1 837 | menu 838 | fi 839 | } 840 | 841 | # xray 管理 842 | manage_xray() { 843 | green "1. 启动xray服务" 844 | skyblue "-------------------" 845 | green "2. 停止xray服务" 846 | skyblue "-------------------" 847 | green "3. 重启xray服务" 848 | skyblue "-------------------" 849 | purple "4. 返回主菜单" 850 | skyblue "------------" 851 | reading "\n请输入选择: " choice 852 | case "${choice}" in 853 | 1) start_xray ;; 854 | 2) stop_xray ;; 855 | 3) restart_xray ;; 856 | 4) menu ;; 857 | *) red "无效的选项!" ;; 858 | esac 859 | } 860 | 861 | # Argo 管理 862 | manage_argo() { 863 | if [ ${check_argo} -eq 2 ]; then 864 | yellow "Argo 尚未安装!" 865 | sleep 1 866 | menu 867 | else 868 | clear 869 | echo "" 870 | green "1. 启动Argo服务" 871 | skyblue "------------" 872 | green "2. 停止Argo服务" 873 | skyblue "------------" 874 | green "3. 添加Argo固定隧道" 875 | skyblue "----------------" 876 | green "4. 切换回Argo临时隧道" 877 | skyblue "------------------" 878 | green "5. 重新获取Argo临时域名" 879 | skyblue "-------------------" 880 | purple "6. 返回主菜单" 881 | skyblue "-----------" 882 | reading "\n请输入选择: " choice 883 | case "${choice}" in 884 | 1) start_argo ;; 885 | 2) stop_argo ;; 886 | 3) 887 | clear 888 | yellow "\n固定隧道可为json或token,固定隧道端口为8080,自行在cf后台设置\n\njson在f佬维护的站点里获取,获取地址:${purple}https://fscarmen.cloudflare.now.cc${re}\n" 889 | reading "\n请输入你的argo域名: " argo_domain 890 | green "你的Argo域名为:$argo_domain" 891 | ArgoDomain=$argo_domain 892 | reading "\n请输入你的argo密钥(token或json): " argo_auth 893 | if [[ $argo_auth =~ TunnelSecret ]]; then 894 | echo $argo_auth > ${work_dir}/tunnel.json 895 | cat > ${work_dir}/tunnel.yml << EOF 896 | tunnel: $(cut -d\" -f12 <<< "$argo_auth") 897 | credentials-file: ${work_dir}/tunnel.json 898 | protocol: http2 899 | 900 | ingress: 901 | - hostname: $ArgoDomain 902 | service: http://localhost:8080 903 | originRequest: 904 | noTLSVerify: true 905 | - service: http_status:404 906 | EOF 907 | if [ -f /etc/alpine-release ]; then 908 | sed -i '/^command_args=/c\command_args="-c '\''/etc/xray/argo tunnel --edge-ip-version auto --config /etc/xray/tunnel.yml run 2>&1'\''"' /etc/init.d/tunnel 909 | else 910 | sed -i '/^ExecStart=/c ExecStart=/bin/sh -c "/etc/xray/argo tunnel --edge-ip-version auto --config /etc/xray/tunnel.yml run 2>&1"' /etc/systemd/system/tunnel.service 911 | fi 912 | restart_argo 913 | add_split_url 914 | change_argo_domain 915 | elif [[ $argo_auth =~ ^[A-Z0-9a-z=]{120,250}$ ]]; then 916 | if [ -f /etc/alpine-release ]; then 917 | sed -i "/^command_args=/c\command_args=\"-c '/etc/xray/argo tunnel --edge-ip-version auto --no-autoupdate --protocol http2 run --token $argo_auth 2>&1'\"" /etc/init.d/tunnel 918 | else 919 | 920 | sed -i '/^ExecStart=/c ExecStart=/bin/sh -c "/etc/xray/argo tunnel --edge-ip-version auto --no-autoupdate --protocol http2 run --token '$argo_auth' 2>&1"' /etc/systemd/system/tunnel.service 921 | fi 922 | restart_argo 923 | add_split_url 924 | change_argo_domain 925 | else 926 | yellow "你输入的argo域名或token不匹配,请重新输入" 927 | manage_argo 928 | fi 929 | ;; 930 | 4) 931 | clear 932 | if [ -f /etc/alpine-release ]; then 933 | alpine_openrc_services 934 | else 935 | main_systemd_services 936 | fi 937 | get_quick_tunnel 938 | change_argo_domain 939 | ;; 940 | 941 | 5) 942 | if [ -f /etc/alpine-release ]; then 943 | if grep -Fq -- '--url http://localhost:8080' /etc/init.d/tunnel; then 944 | get_quick_tunnel 945 | change_argo_domain 946 | else 947 | yellow "当前使用固定隧道,无法获取临时隧道" 948 | sleep 2 949 | menu 950 | fi 951 | else 952 | if grep -q 'ExecStart=.*--url http://localhost:8080' /etc/systemd/system/tunnel.service; then 953 | get_quick_tunnel 954 | change_argo_domain 955 | else 956 | yellow "当前使用固定隧道,无法获取临时隧道" 957 | sleep 2 958 | menu 959 | fi 960 | fi 961 | ;; 962 | 6) menu ;; 963 | *) red "无效的选项!" ;; 964 | esac 965 | fi 966 | } 967 | 968 | # 获取argo临时隧道 969 | get_quick_tunnel() { 970 | restart_argo 971 | yellow "获取临时argo域名中,请稍等...\n" 972 | sleep 3 973 | if [ -f /etc/xray/argo.log ]; then 974 | for i in {1..5}; do 975 | get_argodomain=$(sed -n 's|.*https://\([^/]*trycloudflare\.com\).*|\1|p' /etc/xray/argo.log) 976 | [ -n "$get_argodomain" ] && break 977 | sleep 2 978 | done 979 | else 980 | restart_argo 981 | sleep 6 982 | get_argodomain=$(sed -n 's|.*https://\([^/]*trycloudflare\.com\).*|\1|p' /etc/xray/argo.log) 983 | fi 984 | green "ArgoDomain:${purple}$get_argodomain${re}\n" 985 | ArgoDomain=$get_argodomain 986 | } 987 | 988 | # 更新Argo域名到订阅 989 | change_argo_domain() { 990 | sed -i "3s/sni=[^&]*/sni=$ArgoDomain/; 3s/host=[^&]*/host=$ArgoDomain/" /etc/xray/url.txt 991 | content=$(cat "$client_dir") 992 | vmess_urls=$(grep -o 'vmess://[^ ]*' "$client_dir") 993 | vmess_prefix="vmess://" 994 | for vmess_url in $vmess_urls; do 995 | encoded_vmess="${vmess_url#"$vmess_prefix"}" 996 | decoded_vmess=$(echo "$encoded_vmess" | base64 --decode) 997 | updated_vmess=$(echo "$decoded_vmess" | jq --arg new_domain "$ArgoDomain" '.host = $new_domain | .sni = $new_domain') 998 | encoded_updated_vmess=$(echo "$updated_vmess" | base64 | tr -d '\n') 999 | new_vmess_url="$vmess_prefix$encoded_updated_vmess" 1000 | content=$(echo "$content" | sed "s|$vmess_url|$new_vmess_url|") 1001 | done 1002 | echo "$content" > "$client_dir" 1003 | base64 -w0 ${work_dir}/url.txt > ${work_dir}/sub.txt 1004 | 1005 | while IFS= read -r line; do echo -e "${purple}$line"; done < "$client_dir" 1006 | 1007 | green "\n节点已更新,更新订阅或手动复制以上节点\n" 1008 | } 1009 | 1010 | # 查看节点信息和订阅链接 1011 | check_nodes() { 1012 | if [ ${check_xray} -eq 0 ]; then 1013 | while IFS= read -r line; do purple "${purple}$line"; done < ${work_dir}/url.txt 1014 | server_ip=$(get_realip) 1015 | sub_port=$(sed -n 's/.*:\([0-9]\+\).*/\1/p' /etc/caddy/Caddyfile) 1016 | lujing=$(sed -n 's/.*handle \/\([a-zA-Z0-9]\+\).*/\1/p' /etc/caddy/Caddyfile) 1017 | green "\n\n节点订阅链接:http://$server_ip:$sub_port/$lujing\n" 1018 | else 1019 | yellow "Xray-2go 尚未安装或未运行,请先安装或启动Xray-2go" 1020 | sleep 1 1021 | menu 1022 | fi 1023 | } 1024 | 1025 | # 捕获 Ctrl+C 信号 1026 | trap 'red "已取消操作"; exit' INT 1027 | 1028 | # 主菜单 1029 | menu() { 1030 | while true; do 1031 | check_xray &>/dev/null; check_xray=$? 1032 | check_caddy &>/dev/null; check_caddy=$? 1033 | check_argo &>/dev/null; check_argo=$? 1034 | check_xray_status=$(check_xray) > /dev/null 2>&1 1035 | check_caddy_status=$(check_caddy) > /dev/null 2>&1 1036 | check_argo_status=$(check_argo) > /dev/null 2>&1 1037 | clear 1038 | echo "" 1039 | purple "=== 老王Xray-2go一键安装脚本 ===\n" 1040 | purple " Xray 状态: ${check_xray_status}\n" 1041 | purple " Argo 状态: ${check_argo_status}\n" 1042 | purple "Caddy 状态: ${check_caddy_status}\n" 1043 | green "1. 安装Xray-2go" 1044 | red "2. 卸载Xray-2go" 1045 | echo "===============" 1046 | green "3. Xray-2go管理" 1047 | green "4. Argo隧道管理" 1048 | echo "===============" 1049 | green "5. 查看节点信息" 1050 | green "6. 修改节点配置" 1051 | green "7. 管理节点订阅" 1052 | echo "===============" 1053 | purple "8. ssh综合工具箱" 1054 | purple "9. 安装singbox四合一" 1055 | echo "===============" 1056 | red "0. 退出脚本" 1057 | echo "===========" 1058 | reading "请输入选择(0-9): " choice 1059 | echo "" 1060 | case "${choice}" in 1061 | 1) 1062 | if [ ${check_xray} -eq 0 ]; then 1063 | yellow "Xray-2go 已经安装!" 1064 | else 1065 | install_caddy 1066 | manage_packages install jq unzip iptables openssl coreutils 1067 | install_xray 1068 | 1069 | if [ -x "$(command -v systemctl)" ]; then 1070 | main_systemd_services 1071 | elif [ -x "$(command -v rc-update)" ]; then 1072 | alpine_openrc_services 1073 | change_hosts 1074 | rc-service xray restart 1075 | rc-service tunnel restart 1076 | else 1077 | echo "Unsupported init system" 1078 | exit 1 1079 | fi 1080 | 1081 | sleep 3 1082 | get_info 1083 | add_caddy_conf 1084 | create_shortcut 1085 | fi 1086 | ;; 1087 | 2) uninstall_xray ;; 1088 | 3) manage_xray ;; 1089 | 4) manage_argo ;; 1090 | 5) check_nodes ;; 1091 | 6) change_config ;; 1092 | 7) disable_open_sub ;; 1093 | 8) clear && curl -fsSL https://raw.githubusercontent.com/eooce/ssh_tool/main/ssh_tool.sh -o ssh_tool.sh && chmod +x ssh_tool.sh && ./ssh_tool.sh ;; 1094 | 9) clear && bash <(curl -Ls https://raw.githubusercontent.com/eooce/sing-box/main/sing-box.sh) ;; 1095 | 0) exit 0 ;; 1096 | *) red "无效的选项,请输入 0 到 9" ;; 1097 | esac 1098 | read -n 1 -s -r -p $'\033[1;91m按任意键继续...\033[0m' 1099 | done 1100 | } 1101 | menu 1102 | --------------------------------------------------------------------------------