From f334002761bbee0d7bf3070e4efa3660c68b0326 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Wed, 14 Jan 2026 00:24:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=B9=E5=99=A8=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E7=A1=AE=E8=AE=A4=E6=8F=90=E7=A4=BA=EF=BC=8C=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/run.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/bin/run.sh b/bin/run.sh index 5051c43..dce79cc 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,23 +1,29 @@ #!/bin/bash run(){ - local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" # 脚本文件夹绝对路径 - local config_dir=$(readlink -f "$script_dir/../conf") # 配置文件绝对路径 + local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + local docker_compose_file="$script_dir/../docker-compose.yml" - # 如果配置文件不存在或者空白 - 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 + local running_count=$(docker-compose -f "$docker_compose_file" ps -q --filter "status=running" | wc -l) - ## 启动docker容器 - docker-compose -f $script_dir/../docker-compose.yml up -d + if [ "$running_count" -gt 0 ]; then + read -p "容器已启动,是否重启容器?(y/n): " choice + case "$choice" in + Y|y) + echo "正在重启容器..." + docker-compose -f "$docker_compose_file" down + docker-compose -f "$docker_compose_file" up -d + return + ;; + *) + echo "已取消操作" + exit 0 + ;; + esac + fi + docker-compose -f "$docker_compose_file" up -d } + run