From ccd3968acd1186b0a57faa60582a4615e0e76969 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Sun, 11 Jan 2026 16:43:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=84=9A=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE=E6=A3=80=E6=9F=A5=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/run.sh | 34 ++++++++++++++++++---------------- install.sh | 49 ++++++++++++++++++++++--------------------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/bin/run.sh b/bin/run.sh index adc77b6..4ec95e9 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,21 +1,23 @@ #!/bin/bash -script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 -config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 +run(){ + local script_dir=$(cd "$(dirname "$0")"; pwd) # 脚本文件绝对路径 + local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 -# 如果配置文件不存在或者空白 -if [ ! -e "$config_dir/config.json" ] || [ ! -s "$config_dir/config.json" ] ; then - bash "$script_dir/create_config.sh" -fi -# 如果配置未初始化 -uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_dir/config.json") -if [ "$uuid" = "你的UUID" ] || [ -z "$uuid" ]; then - # 执行初始化脚本 - bash "$script_dir/create_config.sh" -fi + # 如果配置文件不存在或者空白 + if [ ! -e "$config_dir/config.json" ] || [ ! -s "$config_dir/config.json" ] ; then + bash "$script_dir/create_config.sh" + fi + # 如果配置未初始化 + local uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_dir/config.json") + if [ "$uuid" = "你的UUID" ] || [ -z "$uuid" ]; then + # 执行初始化脚本 + bash "$script_dir/create_config.sh" + fi -## 启动docker容器 -docker-compose -f $script_dir/../docker-compose.yml up -d + ## 启动docker容器 + docker-compose -f $script_dir/../docker-compose.yml up -d -# 打印分享链接 -bash $script_dir/print_share_link.sh +} + +run diff --git a/install.sh b/install.sh index 2ef8cbb..2d1484f 100644 --- a/install.sh +++ b/install.sh @@ -78,70 +78,65 @@ main(){ # 显示菜单 echo "请选择一个操作:" - echo "0. 安装依赖" - echo "1. 创建配置 / 重置配置" - echo "2. 启动容器" + echo "1. 一键部署" + echo "2. 创建配置 / 重置配置" echo "3. 查看分享链接" - echo "4. 停止容器" - echo "5. 更新镜像" - echo "6. 修改端口" - echo "7. 修改Reality目标域名" - echo "8. 退出" + echo "4. 启动容器" + echo "5. 停止容器" + echo "6. 更新镜像" + echo "7. 修改端口" + echo "8. 修改Reality目标域名" # 读取用户选择 read -p "输入您的选择: " choice # 根据用户选择执行相应的操作 case $choice in - 0) - # 安装依赖 + 1) + # 一键部署 install_dependencies + bash $script_dir/run.sh + bash $script_dir/print_share_link.sh ;; - 1) + 2) # 创建配置 / 重置配置 check_dependencies bash $script_dir/create_config.sh ;; - 2) - # 启动容器 - echo "启动容器.." - check_dependencies - bash $script_dir/run.sh - ;; 3) # 查看分享链接 - echo "查看分享链接.." check_dependencies check_config bash $script_dir/print_share_link.sh ;; 4) - # 停止容器 - echo "正在停止容器.." - docker-compose -f ./docker-compose.yml down + # 启动容器 + check_dependencies + bash $script_dir/run.sh + bash $script_dir/print_share_link.sh ;; 5) + # 停止容器 + docker-compose -f ./docker-compose.yml down + ;; + 6) # 更新镜像 bash $script_dir/update_docker_images.sh ;; - 6) + 7) # 修改端口 check_dependencies check_config bash $script_dir/update_port.sh restart_docker ;; - 7) + 8) # 修改Reality目标域名 check_dependencies check_config bash $script_dir/update_reality_dest.sh restart_docker ;; - 8) - # 退出 - echo "退出程序." - ;; *) echo "无效的选择, 请重新选择." ;;