#!/bin/bash # 1. Start the Ollama server in the background ollama serve & # 2. Record the Process ID (PID) PID=$! # 3. Wait for the server to wake up (checks every second) echo "Waiting for Ollama to start..." until curl -s http://localhost:7860/api/tags > /dev/null; do sleep 1 done # 4. Pull Gemma 4 (Using the E2B version to ensure it fits in Free Tier RAM) # Change 'gemma4:e2b' to 'gemma4' if you have a paid GPU Space echo "Pulling Gemma 4 model..." ollama pull gemma4:e2b # 5. Tell the user it's ready echo "Model pulled! API is ready at port 7860." # 6. Wait for the background process to finish (keeps the container alive) wait $PID