v1.1.5 修复: 支持管道执行时的模式选择
问题修复: - 修复 curl | bash 执行时无法显示交互选择的问题 - 添加终端检测 (使用 -t 0 和 /dev/tty 检测) - 管道执行时显示友好提示并自动进入安装模式 - 提示用户下载脚本后运行以使用交互选择 改进说明: - 交互式终端: 显示选择界面 [1] 安装 [2] 卸载 - 管道执行: 显示提示信息并默认安装 - 提供卸载命令说明 技术细节: - 使用 [[ -t 0 ]] 检测标准输入是否是终端 - 使用 [[ -c /dev/tty ]] 检测 /dev/tty 可用性 - 两个条件任一满足即可使用交互模式
This commit is contained in:
62
install.sh
62
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
|
||||
|
||||
# 系统检测
|
||||
|
||||
Reference in New Issue
Block a user