From f85766154c4410c132091a7e82f2b2a85b3b473e Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Thu, 15 Jan 2026 14:02:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BD=E6=95=B0=E9=87=8C=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E9=87=8F,=20=E6=94=B9=E4=B8=BA=E5=B1=80=E9=83=A8=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/create_config.sh | 1 + bin/update_docker_images.sh | 2 +- bin/update_key.sh | 2 +- bin/update_xhttp_path.sh | 1 + bin/utils/base.sh | 7 ++++--- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/create_config.sh b/bin/create_config.sh index b81fe18..170ce1c 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -66,6 +66,7 @@ create_config(){ echo "请选择配置文件类型:" echo "1. 创建reality配置" echo "2. 创建xhttp_reality配置" + local choice read -p "请输入选择 (1 或 2): " choice case $choice in 1) create_reality_config ;; diff --git a/bin/update_docker_images.sh b/bin/update_docker_images.sh index af396be..0e37849 100644 --- a/bin/update_docker_images.sh +++ b/bin/update_docker_images.sh @@ -3,7 +3,7 @@ update_docker_images(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径 - docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径 + local docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径 # 检查是否存在 docker-compose.yml 文件 if [ ! -f $docker_compose_file ]; then diff --git a/bin/update_key.sh b/bin/update_key.sh index 390b875..0ea3630 100644 --- a/bin/update_key.sh +++ b/bin/update_key.sh @@ -8,7 +8,7 @@ update_key(){ docker run --rm teddysun/xray:latest /usr/bin/xray x25519 > $config_dir/key.txt # 获取私钥 - private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}') + local private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}') # 修改config.json密钥属性 modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.privateKey" "$private_key" diff --git a/bin/update_xhttp_path.sh b/bin/update_xhttp_path.sh index be99e32..8ab58ac 100644 --- a/bin/update_xhttp_path.sh +++ b/bin/update_xhttp_path.sh @@ -6,6 +6,7 @@ update_xhttp_path(){ local config_dir="$script_dir/../conf" local path_length="$(( RANDOM % 4 + 8 ))" + local uuid=$(cat /proc/sys/kernel/random/uuid) local xhttp_path="/"$(docker run --rm teddysun/xray:latest xray uuid | tr -d '-' | cut -c 1-$path_length) # 修改config.json的xhttp_path diff --git a/bin/utils/base.sh b/bin/utils/base.sh index 94827f4..34d7d5a 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -75,7 +75,7 @@ install_package() { fi echo "安装 $package_name..." - package_manager=$(get_package_manager) + local package_manager=$(get_package_manager) if [ "$package_manager" == "apt-get" ]; then sudo apt-get update sudo apt-get install -y "$package_name" @@ -98,7 +98,7 @@ check_config(){ fi # 如果配置未初始化 - uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_file") + local uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_file") if [ "$uuid" = "你的UUID" ] || [ -z "$uuid" ]; then echo "请先'创建配置'" exit 1 @@ -117,6 +117,7 @@ restart_docker() { # 如果容器未运行,提示启动 local running_count=$(docker-compose -f $script_dir/../docker-compose.yml ps -q | wc -l) if [ "$running_count" -eq 0 ]; then + local choice read -p "容器未启动,是否启动容器?(y/n): " choice case "$choice" in Y|y) @@ -133,4 +134,4 @@ restart_docker() { echo "正在重启容器..." docker-compose -f $script_dir/../docker-compose.yml down docker-compose -f $script_dir/../docker-compose.yml up -d -} \ No newline at end of file +}