重构代码, 改为函数形式

This commit is contained in:
Olia Lisa 2025-11-22 16:51:09 +08:00
parent dd80d3601b
commit 0c884a87fc
3 changed files with 50 additions and 33 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash
update_docker_images(){
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
docker_compose_file="$script_dir/../docker-compose.yml" # docker-compose.yml文件路径
@ -20,3 +22,6 @@ docker image prune -f
echo "正在启动容器.."
docker-compose -f $docker_compose_file up -d
}
update_docker_images

View File

@ -1,5 +1,7 @@
#!/bin/bash
update_key(){
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir="$script_dir/../conf"
source $script_dir/utils/jq_util.sh
@ -14,3 +16,8 @@ private_key=$(grep "Private" $config_dir/key.txt | awk -F ': ' '{print $2}')
modify_json_file "$config_dir/config.json" ".inbounds[0].streamSettings.realitySettings.privateKey" "$private_key"
echo "生成和设置密钥成功."
}
update_key

View File

@ -1,5 +1,7 @@
#!/bin/bash
update_uuid(){
script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径
config_dir="$script_dir/../conf"
@ -12,3 +14,6 @@ uuid=$(docker run --rm teddysun/xray:latest xray uuid)
modify_json_file "$config_dir/config.json" ".inbounds[0].settings.clients[0].id" "$uuid"
echo "设置UUID成功."
}
update_uuid