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