From 4eb55e029ffdbdaecec67a5be1736001c9599331 Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Wed, 14 Jan 2026 22:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E5=B0=86=E4=B8=80=E9=94=AE=E8=84=9A=E6=9C=AC=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E4=B8=BAmain=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 134 ++++++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/install.sh b/install.sh index 0599b1f..aeaaeb9 100644 --- a/install.sh +++ b/install.sh @@ -1,10 +1,9 @@ #!/bin/bash -script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 -source "${script_dir}/utils/base.sh" - - install(){ + local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 + source "${script_dir}/utils/base.sh" + if ! command -v curl >/dev/null 2>&1; then install_package curl fi @@ -30,65 +29,72 @@ install(){ fi } -# 显示菜单 -echo "请选择一个操作:" -echo "1. 一键部署" -echo "2. 生成配置 / 重置配置" -echo "3. 查看分享链接" -echo "4. 启动容器" -echo "5. 停止容器" -echo "6. 更新镜像" -echo "7. 修改域名" -echo "8. 修改端口" +main(){ + local script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录 + source "${script_dir}/utils/base.sh" -# 读取用户选择 -read -p "输入您的选择: " choice + # 显示菜单 + echo "请选择一个操作:" + echo "1. 一键部署" + echo "2. 生成配置 / 重置配置" + echo "3. 查看分享链接" + echo "4. 启动容器" + echo "5. 停止容器" + echo "6. 更新镜像" + echo "7. 修改域名" + echo "8. 修改端口" -# 根据用户选择执行相应的操作 -case $choice in - 1) - # 一键部署 - install - bash ./bin/create_config.sh - bash ./bin/run.sh - bash ./bin/print_share_link.sh - ;; - 2) - # 生成配置 - bash ./bin/create_config.sh - ;; - 3) - # 查看分享链接 - check_config_file - bash ./bin/print_share_link.sh - ;; - 4) - # 启动容器 - bash ./bin/run.sh - bash ./bin/print_share_link.sh - ;; - 5) - # 停止容器 - echo "正在停止容器.." - docker-compose -f ./docker-compose.yml down - ;; - 6) - # 更新镜像 - bash ./bin/update_docker_images.sh - ;; - 7) - # 修改域名 - check_config_file - bash ./bin/update_domain.sh - restart_docker - ;; - 8) - # 修改端口 - check_config_file - bash ./bin/update_port.sh - restart_docker - ;; - *) - echo "无效的选择, 请重新选择." - ;; -esac + # 读取用户选择 + read -p "输入您的选择: " choice + + # 根据用户选择执行相应的操作 + case $choice in + 1) + # 一键部署 + install + bash ./bin/create_config.sh + bash ./bin/run.sh + bash ./bin/print_share_link.sh + ;; + 2) + # 生成配置 + bash ./bin/create_config.sh + ;; + 3) + # 查看分享链接 + check_config_file + bash ./bin/print_share_link.sh + ;; + 4) + # 启动容器 + bash ./bin/run.sh + bash ./bin/print_share_link.sh + ;; + 5) + # 停止容器 + echo "正在停止容器.." + docker-compose -f ./docker-compose.yml down + ;; + 6) + # 更新镜像 + bash ./bin/update_docker_images.sh + ;; + 7) + # 修改域名 + check_config_file + bash ./bin/update_domain.sh + restart_docker + ;; + 8) + # 修改端口 + check_config_file + bash ./bin/update_port.sh + restart_docker + ;; + *) + echo "无效的选择, 请重新选择." + ;; + esac +} + +main \ No newline at end of file