diff --git a/install.sh b/install.sh index 973952e..58f05e8 100755 --- a/install.sh +++ b/install.sh @@ -360,15 +360,22 @@ config_only() { print_message "✅ 配置完成!" "$GREEN" } -# 检查是否为交互式调用 -if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then +# 主执行逻辑 +main() { # 如果有参数,直接运行完整安装 if [[ $# -gt 0 && $1 == "--full" ]]; then full_install exit 0 fi - # 显示菜单 + # 如果是通过 curl 管道执行(非交互式),默认运行完整安装 + if [[ ! -t 0 ]]; then + print_message "🔍 检测到非交互式执行,运行完整安装..." "$YELLOW" + full_install + exit 0 + fi + + # 交互式菜单 while true; do show_menu @@ -398,4 +405,9 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then ;; esac done +} + +# 只有在脚本被直接执行时才运行主函数 +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then + main "$@" fi \ No newline at end of file