diff --git a/install.sh b/install.sh index ba3e24a..b280ddf 100755 --- a/install.sh +++ b/install.sh @@ -185,13 +185,22 @@ case "$AI_CHOICE" in else info "Ollama already installed" fi - # Wait for Ollama to be ready - for i in $(seq 1 10); do - if ollama --version &>/dev/null; then break; fi + # Wait for Ollama server to be ready (API endpoint, not just CLI) + info "Waiting for Ollama server..." + for i in $(seq 1 15); do + if curl -sf http://127.0.0.1:11434/api/tags > /dev/null 2>&1; then + info "Ollama server is ready" + break + fi sleep 2 done info "Pulling model $AI_MODEL (this may take a while)..." - sudo_if ollama pull "$AI_MODEL" 2>&1 | tail -3 + # Pull as the ollama user so models are in the right place + if id -u ollama &>/dev/null; then + sudo -u ollama ollama pull "$AI_MODEL" 2>&1 | tail -3 + else + ollama pull "$AI_MODEL" 2>&1 | tail -3 + fi AI_BASE_URL="http://localhost:11434" ;; *)