#!/bin/bash echo "Starting Ollama server..." ollama serve & OLLAMA_PID=$! sleep 2 # Give the server a moment to start echo "Waiting for Ollama server to be active..." for i in {1..30}; do ollama_list_output=$(ollama list 2>&1) echo "ollama list output: $ollama_list_output" if echo "$ollama_list_output" | grep 'NAME' > /dev/null; then echo "Ollama server is active." break fi echo "Ollama server is not yet active..." sleep 1 done # Try pulling the model up to 3 times if it fails for attempt in {1..3}; do echo "Attempt $attempt: Pulling gemma3:27b-it-qat..." if ollama pull gemma3:27b-it-qat; then echo "Model pulled successfully." break else echo "Model pull failed, retrying..." sleep 2 fi done echo "Stopping Ollama server..." kill $OLLAMA_PID wait $OLLAMA_PID