From 0c884a87fc05c7cf88aa2c4175893d662be67e17 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sat, 22 Nov 2025 16:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=87=BD=E6=95=B0=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/update_docker_images.sh | 35 ++++++++++++++++++++--------------- bin/update_key.sh | 27 +++++++++++++++++---------- bin/update_uuid.sh | 21 +++++++++++++-------- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/bin/update_docker_images.sh b/bin/update_docker_images.sh index aabc64a..7cbdb9d 100644 --- a/bin/update_docker_images.sh +++ b/bin/update_docker_images.sh @@ -1,22 +1,27 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 -docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径 -# 检查是否存在 docker-compose.yml 文件 -if [ ! -f $docker_compose_file ]; then - echo "Error: docker-compose.yml 文件不存在." - exit 1 -fi +update_docker_images(){ + script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 + docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径 -echo "正在关闭容器.." -docker-compose -f $docker_compose_file down + # 检查是否存在 docker-compose.yml 文件 + if [ ! -f $docker_compose_file ]; then + echo "Error: docker-compose.yml 文件不存在." + exit 1 + fi -echo "正在更新镜像.." -docker-compose -f $docker_compose_file pull + echo "正在关闭容器.." + docker-compose -f $docker_compose_file down -echo "正在删除未使用的镜像..." -docker image prune -f + echo "正在更新镜像.." + docker-compose -f $docker_compose_file pull -echo "正在启动容器.." -docker-compose -f $docker_compose_file up -d + echo "正在删除未使用的镜像..." + docker image prune -f + + echo "正在启动容器.." + docker-compose -f $docker_compose_file up -d +} + +update_docker_images diff --git a/bin/update_key.sh b/bin/update_key.sh index b7baf1c..1d6917b 100644 --- a/bin/update_key.sh +++ b/bin/update_key.sh @@ -1,16 +1,23 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 -config_dir="$script_dir/../conf" -source $script_dir/utils/jq_util.sh +update_key(){ -# 使用docker运行xray镜像生成密钥文件 -docker run --rm teddysun/xray:latest /usr/bin/xray x25519 > $config_dir/key.txt + script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 + config_dir="$script_dir/../conf" + source $script_dir/utils/jq_util.sh -# 获取私钥 -private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}') + # 使用docker运行xray镜像生成密钥文件 + docker run --rm teddysun/xray:latest /usr/bin/xray x25519 > $config_dir/key.txt -# 修改config.json密钥属性 -modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.privateKey" "$private_key" + # 获取私钥 + private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}') -echo "生成和设置密钥成功." + # 修改config.json密钥属性 + modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.privateKey" "$private_key" + + echo "生成和设置密钥成功." + +} + + +update_key \ No newline at end of file diff --git a/bin/update_uuid.sh b/bin/update_uuid.sh index 9960ff1..9d602fb 100644 --- a/bin/update_uuid.sh +++ b/bin/update_uuid.sh @@ -1,14 +1,19 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 -config_dir="$script_dir/../conf" +update_uuid(){ -source $script_dir/utils/jq_util.sh + script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 + config_dir="$script_dir/../conf" -# 生成 UUID -uuid=$(docker run --rm teddysun/xray:latest xray uuid) + source $script_dir/utils/jq_util.sh -#修改 UUID -modify_json_file "$config_dir/config.json" ".inbounds[0].settings.clients[0].id" "$uuid" + # 生成 UUID + uuid=$(docker run --rm teddysun/xray:latest xray uuid) -echo "设置UUID成功." + #修改 UUID + modify_json_file "$config_dir/config.json" ".inbounds[0].settings.clients[0].id" "$uuid" + + echo "设置UUID成功." +} + +update_uuid