From 9819aaba95ba01e9a3009cd0df7e41a16af62d61 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Mon, 20 Apr 2026 22:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=85=B7=E5=87=BD?= =?UTF-8?q?=E6=95=B0,=20=E4=BA=A4=E4=BA=92=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/utils/base.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/utils/base.sh b/bin/utils/base.sh index 5ba8929..45471b2 100644 --- a/bin/utils/base.sh +++ b/bin/utils/base.sh @@ -137,6 +137,7 @@ check_config_file(){ fi } +# 重启docker容器 restart_docker() { local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../" # 脚本文件夹绝对路径 @@ -159,4 +160,18 @@ restart_docker() { echo "正在重启容器..." docker-compose -f $script_dir/../docker-compose.yml down docker-compose -f $script_dir/../docker-compose.yml up -d +} + +# 展示当前值并询问用户新输入的值 +# 用法: ask_update "提示语" "当前值(当前配置文件的值)" +# 示例: +# new_port=$(ask_update "请输入新的端口号" "$(jq -r '.inbounds[0].port' $config_dir/config.json)") +ask_update() { + local prompt="$1" # 提示语 + local current_value="$2" + local input + + read -p "${prompt} [当前: ${current_value}]: " input + # 用户直接回车则保留当前值,否则使用新输入 + echo "${input:-$current_value}" } \ No newline at end of file