diff --git a/install.sh b/install.sh index fd62f98..f11569a 100644 --- a/install.sh +++ b/install.sh @@ -1715,31 +1715,45 @@ main() { # 如果没有通过命令行参数指定模式,则显示交互式选择 if [[ "$MODE" == "install" ]] && [[ "$1" != "--skip-mode-select" ]]; then - print_step "请选择操作模式" - echo "" - echo -e "${GREEN}[1]${NC} 安装/部署 玩玩云" - echo -e "${RED}[2]${NC} 卸载 玩玩云" - echo "" + # 检测是否可以使用交互式输入 + if [[ -t 0 ]] || [[ -c /dev/tty ]]; then + print_step "请选择操作模式" + echo "" + echo -e "${GREEN}[1]${NC} 安装/部署 玩玩云" + echo -e "${RED}[2]${NC} 卸载 玩玩云" + echo "" - while true; do - read -p "请输入选项 [1-2]: " mode_choice < /dev/tty - case $mode_choice in - 1) - print_success "已选择: 安装模式" - echo "" - break - ;; - 2) - print_info "切换到卸载模式..." - echo "" - uninstall_main - exit 0 - ;; - *) - print_error "无效选项,请重新选择" - ;; - esac - done + while true; do + read -p "请输入选项 [1-2]: " mode_choice < /dev/tty + case $mode_choice in + 1) + print_success "已选择: 安装模式" + echo "" + break + ;; + 2) + print_info "切换到卸载模式..." + echo "" + uninstall_main + exit 0 + ;; + *) + print_error "无效选项,请重新选择" + ;; + esac + done + else + # 管道执行时的提示 + print_info "检测到通过管道执行脚本" + print_info "默认进入安装模式" + print_warning "如需卸载,请下载脚本后运行: bash install.sh --uninstall" + 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 --uninstall" + echo "" + sleep 2 + fi fi # 系统检测