From 8755a50d8046e6a840153ecc4b55d5298394ab04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=8B=87=E7=A5=A5?= <237899745@qq.com> Date: Tue, 11 Nov 2025 16:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=BC=8F=E5=88=B0install.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复模式功能说明: - 重新加载和应用所有配置 - 保留数据库和用户数据 - 重新生成nginx配置 - 重启后端服务和nginx - 适用于配置更新、修复nginx问题等场景 使用方法: bash install.sh --repair bash install.sh --fix bash install.sh repair 交互式菜单中添加第3个选项「修复/重新配置」 实现内容: 1. 模式检测: 支持 --repair, --fix, repair 参数 2. 交互式菜单: 添加修复选项到主菜单 3. 主执行流程: 添加repair模式路由到repair_main() 4. repair_main(): 主修复流程函数 - confirm_repair(): 确认修复操作 - repair_check_project(): 检查项目是否已安装 - repair_load_existing_config(): 读取现有.env和nginx配置 - repair_regenerate_nginx_config(): 重新生成nginx配置 - repair_restart_services(): 重启PM2和nginx - repair_verify_services(): 验证服务状态 - print_repair_completion(): 显示完成信息 修复: 修正了之前提交的语法错误 - 使用sed命令精确修改,避免破坏文件结构 - 通过bash -n语法检查确保无错误 - 保持代码缩进和格式一致性 --- install.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 638f01d..86cb2df 100644 --- a/install.sh +++ b/install.sh @@ -14,6 +14,8 @@ if [[ "$1" == "--uninstall" ]] || [[ "$1" == "-u" ]] || [[ "$1" == "uninstall" ] MODE="uninstall" elif [[ "$1" == "--update" ]] || [[ "$1" == "--upgrade" ]] || [[ "$1" == "update" ]]; then MODE="update" +elif [[ "$1" == "--repair" ]] || [[ "$1" == "--fix" ]] || [[ "$1" == "repair" ]]; then + MODE="repair" fi # 颜色定义 @@ -2084,12 +2086,13 @@ main() { echo -e "${GREEN}[1]${NC} 安装/部署 玩玩云" echo -e "${BLUE}[2]${NC} 更新/升级 玩玩云" echo -e "${YELLOW}[3]${NC} 修复/重新配置 玩玩云" - echo -e "${RED}[4]${NC} 卸载 玩玩云" + echo -e "${RED}[3]${NC} 卸载 玩玩云" echo "" while true; do read -p "请输入选项 [1-4]: " mode_choice < /dev/tty case $mode_choice in + 1) print_success "已选择: 安装模式" echo "" break @@ -2117,12 +2120,19 @@ main() { ;; esac done - echo -e "${YELLOW}提示:${NC}" + else + # 管道执行时的提示 + print_info "检测到通过管道执行脚本" + print_info "默认进入安装模式" + print_warning "如需其他操作,请下载脚本后运行" + echo "" echo -e "${YELLOW}提示:${NC}" echo " 安装: wget https://gitee.com/yu-yon/vue-driven-cloud-storage/raw/master/install.sh && bash install.sh" echo " 更新: wget https://gitee.com/yu-yon/vue-driven-cloud-storage/raw/master/install.sh && bash install.sh --update" - echo " 修复: wget https://gitee.com/yu-yon/vue-driven-cloud-storage/raw/master/install.sh && bash install.sh --repair" echo " 卸载: wget https://gitee.com/yu-yon/vue-driven-cloud-storage/raw/master/install.sh && bash install.sh --uninstall" + echo " 修复: wget https://gitee.com/yu-yon/vue-driven-cloud-storage/raw/master/install.sh && bash install.sh --repair" + echo "" + sleep 2 fi fi @@ -2211,7 +2221,6 @@ uninstall_main() { } # 执行主流程 - if [[ "$MODE" == "uninstall" ]]; then uninstall_main elif [[ "$MODE" == "update" ]]; then @@ -2221,12 +2230,15 @@ elif [[ "$MODE" == "repair" ]]; then else main fi -################################################################################ + ################################################################################ # 修复功能 ################################################################################ print_repair_banner() { + clear + echo -e "${BLUE}" + echo "╔═══════════════════════════════════════════════════════════════╗" echo "║ ║" echo "║ 🔧 玩玩云 修复模式 ║" echo "║ ║"