From 3715554dc28ecb925af0a70864326a1178c37b4b Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Thu, 15 Jan 2026 12:25:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E9=A1=B9=E7=9B=AE=E5=85=A5=E5=8F=A3=E4=B8=BA?= =?UTF-8?q?install.sh.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/create_config.sh | 9 --------- bin/gen_self_tls.sh | 8 -------- bin/print_share_link.sh | 1 - bin/run.sh | 2 -- bin/update_docker_images.sh | 3 +-- bin/update_domain.sh | 6 ------ bin/update_password.sh | 5 ----- bin/update_port.sh | 5 ----- bin/update_uuid.sh | 5 ----- bin/utils/jq_util.sh | 2 -- install.sh | 35 ++++++++++++++++++++++------------- 11 files changed, 23 insertions(+), 58 deletions(-) diff --git a/bin/create_config.sh b/bin/create_config.sh index 9b6cab5..a1b366d 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -1,10 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - create_config_with_tls_cert() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 @@ -106,7 +101,3 @@ create_config(){ esac } - -create_config - - diff --git a/bin/gen_self_tls.sh b/bin/gen_self_tls.sh index ab73d21..9e9823b 100644 --- a/bin/gen_self_tls.sh +++ b/bin/gen_self_tls.sh @@ -1,11 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - - # 生成自签名证书 gen_self_tls() { local domain="${1:-bing.com}" @@ -27,5 +21,3 @@ gen_self_tls() { modify_json_file "$config_file" "inbounds[0].tls.server_name" "$domain" } -# 调用函数,传入第一个参数作为域名 -gen_self_tls "${1:-bing.com}" diff --git a/bin/print_share_link.sh b/bin/print_share_link.sh index 2f08ac7..b9098b8 100644 --- a/bin/print_share_link.sh +++ b/bin/print_share_link.sh @@ -56,4 +56,3 @@ print_share_link() { echo -e "\033[0m" } -print_share_link # 输出分享链接 diff --git a/bin/run.sh b/bin/run.sh index 5bab5a9..fe8fb1a 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,6 +1,5 @@ #!/bin/bash - run() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 @@ -14,4 +13,3 @@ run() { docker-compose -f "$script_dir/../docker-compose.yml" up -d } -run # 启动容器 diff --git a/bin/update_docker_images.sh b/bin/update_docker_images.sh index d0bb342..55cdcca 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 @@ -24,4 +24,3 @@ update_docker_images(){ docker-compose -f $docker_compose_file up -d } -update_docker_images diff --git a/bin/update_domain.sh b/bin/update_domain.sh index 3ef6ade..f38e7c7 100644 --- a/bin/update_domain.sh +++ b/bin/update_domain.sh @@ -1,11 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - - # 修改域名 update_domain(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 diff --git a/bin/update_password.sh b/bin/update_password.sh index ac2a18d..ae1e48a 100644 --- a/bin/update_password.sh +++ b/bin/update_password.sh @@ -1,10 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - # 更新密码的函数 update_password() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 diff --git a/bin/update_port.sh b/bin/update_port.sh index b4ef62e..1ab7c46 100644 --- a/bin/update_port.sh +++ b/bin/update_port.sh @@ -1,10 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - # 查找随机空闲端口 # 用途: # 在指定端口范围内,随机选择一个当前未被监听(TCP/UDP)的端口 diff --git a/bin/update_uuid.sh b/bin/update_uuid.sh index abfe9fe..7e7bf28 100644 --- a/bin/update_uuid.sh +++ b/bin/update_uuid.sh @@ -1,10 +1,5 @@ #!/bin/bash -# 导入依赖脚本文件 -for f in $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/utils/*.sh; do - source "$f" -done - update_uuid(){ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 local config_file="$script_dir/../config/config.json" diff --git a/bin/utils/jq_util.sh b/bin/utils/jq_util.sh index c0da451..9a1842b 100644 --- a/bin/utils/jq_util.sh +++ b/bin/utils/jq_util.sh @@ -1,8 +1,6 @@ #!/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 90ad345..7cf156a 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,13 @@ #!/bin/bash -source "$(dirname "$0")/bin/utils/base.sh" -source "$(dirname "$0")/bin/utils/jq_util.sh" + +# 导入依赖脚本文件 +BASE_DIR="$(cd "$(dirname "$0")" && pwd)" +for f in "$BASE_DIR"/bin/utils/*.sh; do + [ -f "$f" ] && source "$f" +done +for f in "$BASE_DIR"/bin/*.sh; do + [ -f "$f" ] && source "$f" +done install(){ if ! command -v curl >/dev/null 2>&1; then @@ -12,17 +19,18 @@ install(){ fi if ! command -v jq >/dev/null 2>&1; then - echo 安装jq... install_package jq fi if ! command -v docker >/dev/null 2>&1; then echo 安装docker... + sleep 1 curl -fsSL https://get.docker.com | bash -s docker fi if ! command -v docker-compose >/dev/null 2>&1; then echo 安装docker-compose... + sleep 1 wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-x86_64 chmod +x /usr/local/bin/docker-compose fi @@ -42,6 +50,7 @@ main(){ echo "8. 更新镜像" # 读取用户选择 + local choice read -p "输入您的选择: " choice # 根据用户选择执行相应的操作 @@ -49,36 +58,36 @@ main(){ 1) # 一键部署 install - bash ./bin/create_config.sh - bash ./bin/run.sh - bash ./bin/print_share_link.sh + create_config + run + printf_share_link ;; 2) # 生成配置 / 重置配置 - bash ./bin/create_config.sh + create_config ;; 3) # 查看分享链接 check_config_file - bash ./bin/print_share_link.sh + printf_share_link ;; 4) # 修改域名 check_config_file - bash ./bin/update_domain.sh + update_domain restart_docker ;; 5) # 修改端口 check_config_file - bash ./bin/update_port.sh + update_port restart_docker ;; 6) # 启动容器 check_config_file - bash ./bin/run.sh - bash ./bin/print_share_link.sh + run + printf_share_link ;; 7) # 停止容器 @@ -86,7 +95,7 @@ main(){ ;; 8) # 更新镜像 - bash ./bin/update_docker_images.sh + update_docker_images restart_docker ;; *)