From 29365de75a213cac1d3af0c4aa3578ad8b23c356 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Wed, 14 Jan 2026 23:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=AF=BC=E5=85=A5=E4=BE=9D=E8=B5=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=AF=AD=E5=8F=A5=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/create_config.sh | 2 +- bin/gen_self_tls.sh | 4 +--- bin/print_share_link.sh | 3 ++- bin/update_domain.sh | 6 +++--- bin/update_password.sh | 3 +-- bin/update_port.sh | 2 +- bin/update_uuid.sh | 1 + bin/utils/jq_util.sh | 3 +++ install.sh | 8 ++------ 9 files changed, 15 insertions(+), 17 deletions(-) diff --git a/bin/create_config.sh b/bin/create_config.sh index 2cc6976..64f8de5 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -1,4 +1,5 @@ #!/bin/bash +source "$(dirname "$0")/bin/utils/base.sh" create_config_with_tls_cert() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 @@ -64,7 +65,6 @@ create_self_tls_config() { bash "$script_dir/gen_self_tls.sh" "bing.com" green "成功创建配置" - } create_config(){ diff --git a/bin/gen_self_tls.sh b/bin/gen_self_tls.sh index 4ccdde1..ed9b5c5 100644 --- a/bin/gen_self_tls.sh +++ b/bin/gen_self_tls.sh @@ -1,4 +1,5 @@ #!/bin/bash +source "$(dirname "$0")/bin/utils/jq_util.sh" # 生成自签名证书 gen_self_tls() { @@ -7,9 +8,6 @@ gen_self_tls() { local key_dir="$script_dir/../tls/self-tls" local config_file="$script_dir/../config/config.json" - # 导入utils文件夹中的jq_util.sh脚本 - source "$script_dir/utils/jq_util.sh" - # 创建存放证书的目录 mkdir -p "$key_dir" diff --git a/bin/print_share_link.sh b/bin/print_share_link.sh index 47bc26f..668e440 100644 --- a/bin/print_share_link.sh +++ b/bin/print_share_link.sh @@ -1,9 +1,10 @@ #!/bin/bash +source "$(dirname "$0")/bin/utils/base.sh" + print_share_link() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 local config_dir=$(readlink -f "$script_dir/../config") - source "${script_dir}/utils/base.sh" # 检查jq是否安装 check_jq diff --git a/bin/update_domain.sh b/bin/update_domain.sh index b3153c8..8590cb8 100644 --- a/bin/update_domain.sh +++ b/bin/update_domain.sh @@ -1,10 +1,11 @@ #!/bin/bash +source "$(dirname "$0")/utils/base.sh" +source "$(dirname "$0")/utils/jq_util.sh" + # 修改域名 update_domain(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - source "$script_dir/utils/jq_util.sh" - source "$script_dir/utils/base.sh" local config_file="$script_dir/../config/config.json" # 检查jq是否安装 @@ -36,5 +37,4 @@ update_domain(){ } - update_domain diff --git a/bin/update_password.sh b/bin/update_password.sh index 2664b55..d05d7d8 100644 --- a/bin/update_password.sh +++ b/bin/update_password.sh @@ -1,12 +1,11 @@ #!/bin/bash +source "$(dirname "$0")/utils/base.sh" # 更新密码的函数 update_password() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 local config_file="$script_dir/../config/config.json" - # 加载工具脚本 - source "$script_dir/utils/base.sh" # 生成一个长度为16的随机密码 local new_password=$(gen_password 16) diff --git a/bin/update_port.sh b/bin/update_port.sh index 45cfd62..f2d9b99 100644 --- a/bin/update_port.sh +++ b/bin/update_port.sh @@ -1,4 +1,5 @@ #!/bin/bash +source "$(dirname "$0")/utils/jq_util.sh" # 查找随机空闲端口 @@ -78,7 +79,6 @@ update_port(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 local config_dir="$script_dir/../config" - source "$script_dir/utils/jq_util.sh" local port=$(find_free_port) modify_json_file "$config_dir/config.json" ".inbounds[0].listen_port" "$port" diff --git a/bin/update_uuid.sh b/bin/update_uuid.sh index 7e7bf28..bfeed9f 100644 --- a/bin/update_uuid.sh +++ b/bin/update_uuid.sh @@ -1,4 +1,5 @@ #!/bin/bash +source "$(dirname "$0")/utils/jq_util.sh" update_uuid(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 diff --git a/bin/utils/jq_util.sh b/bin/utils/jq_util.sh index c2b8370..c0da451 100644 --- a/bin/utils/jq_util.sh +++ b/bin/utils/jq_util.sh @@ -1,5 +1,8 @@ #!/bin/bash + + + # 修改json文件的属性值 # 案例1:modify_json_file "/foo/bar.json" "person.name" "张三" # 案例2:modify_json_file "/foo/bar.json" "servers" '["a.com", "b.com"]' diff --git a/install.sh b/install.sh index deddab9..90ad345 100644 --- a/install.sh +++ b/install.sh @@ -1,9 +1,8 @@ #!/bin/bash +source "$(dirname "$0")/bin/utils/base.sh" +source "$(dirname "$0")/bin/utils/jq_util.sh" install(){ - local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 - source "${script_dir}/utils/base.sh" - if ! command -v curl >/dev/null 2>&1; then install_package curl fi @@ -31,9 +30,6 @@ install(){ main(){ - local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 - source "${script_dir}/utils/base.sh" - # 显示菜单 echo "请选择一个操作:" echo "1. 一键部署"