diff --git a/bin/create_config.sh b/bin/create_config.sh index 5eb71c8..ca104ff 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -1,5 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" create_config_with_tls_cert() { @@ -10,13 +9,13 @@ create_config_with_tls_cert() { cp "$config_dir/template/tls_cert_config.json" "$config_file" # 设置端口 - bash "$script_dir/update_port.sh" + change_port # 设置密码 - bash "$script_dir/update_password.sh" + update_password # 设置混淆密码 - bash "$script_dir/update_obfs_password.sh" + update_obfs_password # 获取邮箱 read -p "请输入你的邮箱(可留空): " user_email @@ -57,16 +56,16 @@ create_self_tls_config() { cp "$config_dir/template/self_cert_config.json" "$config_dir/config.json" # 设置端口 - bash "$script_dir/update_port.sh" + change_port # 设置密码 - bash "$script_dir/update_password.sh" + update_password # 设置混淆密码 - bash "$script_dir/update_obfs_password.sh" - + update_obfs_password + # 生成自签名证书和设置域名 - bash "$script_dir/gen_self_tls.sh" "bing.com" + gen_self_tls "bing.com" green "创建配置成功" } @@ -109,6 +108,3 @@ create_config(){ ;; esac } - - -create_config diff --git a/bin/gen_self_tls.sh b/bin/gen_self_tls.sh index bd29d92..d9dada8 100644 --- a/bin/gen_self_tls.sh +++ b/bin/gen_self_tls.sh @@ -1,5 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/jq_util.sh" # 生成自签名证书 @@ -20,6 +19,3 @@ gen_self_tls() { local config_file="$script_dir/../config/config.json" modify_json_file "$config_file" "masquerade.proxy.url" "https://$domain" } - -# 调用函数,传入第一个参数作为域名 -gen_self_tls "${1:-bing.com}" diff --git a/bin/print_share_link.sh b/bin/print_share_link.sh index 35cf9b3..3f75c79 100644 --- a/bin/print_share_link.sh +++ b/bin/print_share_link.sh @@ -1,5 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" print_share_link() { @@ -55,5 +54,3 @@ print_share_link() { echo "分享链接: $share_link" echo -e "\033[0m" } - -print_share_link # 输出分享链接 diff --git a/bin/run.sh b/bin/run.sh index a0ab2bc..fdbb778 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -12,7 +12,5 @@ run() { # 启动docker容器 docker-compose -f "$compose_file" up -d - -} -run # 启动容器 +} diff --git a/bin/update_docker_images.sh b/bin/update_docker_images.sh index 19d6bf7..a220acd 100644 --- a/bin/update_docker_images.sh +++ b/bin/update_docker_images.sh @@ -23,6 +23,3 @@ update_docker_images() { echo "正在启动容器.." docker-compose -f "$docker_compose_file" up -d } - -# 调用函数 -update_docker_images \ No newline at end of file diff --git a/bin/update_domain.sh b/bin/update_domain.sh index 36da317..1734916 100644 --- a/bin/update_domain.sh +++ b/bin/update_domain.sh @@ -1,6 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" -source "$(dirname "$0")/utils/jq_util.sh" # 修改域名 @@ -31,6 +29,3 @@ update_domain(){ echo "修改域名成功" } - - -update_domain diff --git a/bin/update_obfs_password.sh b/bin/update_obfs_password.sh index d6d2619..5dcb379 100644 --- a/bin/update_obfs_password.sh +++ b/bin/update_obfs_password.sh @@ -1,6 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" -source "$(dirname "$0")/utils/jq_util.sh" # 更新密码的函数 update_obfs_password() { @@ -18,6 +16,3 @@ update_obfs_password() { echo "更新混淆密码成功" } - -# 调用函数 -update_obfs_password diff --git a/bin/update_password.sh b/bin/update_password.sh index b1f0430..5180e89 100644 --- a/bin/update_password.sh +++ b/bin/update_password.sh @@ -1,6 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" -source "$(dirname "$0")/utils/jq_util.sh" # 更新密码的函数 update_password() { @@ -18,6 +16,3 @@ update_password() { echo "设置密码成功" } - -# 调用函数 -update_password diff --git a/bin/update_port.sh b/bin/update_port.sh index 8b13dcd..64e95fd 100644 --- a/bin/update_port.sh +++ b/bin/update_port.sh @@ -1,6 +1,4 @@ #!/bin/bash -source "$(dirname "$0")/utils/base.sh" -source "$(dirname "$0")/utils/jq_util.sh" # 查找随机空闲端口 # 用途: @@ -84,5 +82,3 @@ change_port(){ modify_json_file "$config_file" ".listen" ":$port" echo "已分配新的空闲端口, 设置端口成功" } - -change_port diff --git a/install.sh b/install.sh index 2937497..65c0500 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,13 @@ #!/bin/bash -source ./bin/utils/base.sh -source ./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 @@ -48,23 +54,23 @@ main(){ 1) # 一键部署 install - bash ./bin/create_config.sh - bash ./bin/run.sh - bash ./bin/print_share_link.sh + create_config + run + print_share_link ;; 2) # 生成配置 - bash ./bin/create_config.sh + create_config ;; 3) # 查看分享链接 check_config_file - bash ./bin/print_share_link.sh + print_share_link ;; 4) # 启动容器 - bash ./bin/run.sh - bash ./bin/print_share_link.sh + run + print_share_link ;; 5) # 停止容器 @@ -72,18 +78,18 @@ main(){ ;; 6) # 更新镜像 - bash ./bin/update_docker_images.sh + update_docker_images ;; 7) # 修改域名 check_config_file - bash ./bin/update_domain.sh + update_domain restart_docker ;; 8) # 修改端口 check_config_file - bash ./bin/update_port.sh + change_port restart_docker ;; *)