-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwait-for-ollama.sh
More file actions
executable file
·32 lines (26 loc) · 1.02 KB
/
wait-for-ollama.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
echo "✋ Waiting for Ollama at $OLLAMA_URL..."
until curl -s "$OLLAMA_URL/api/tags" > /dev/null; do
sleep 1
done
echo "✅ Ollama is ready."
pull_model() {
local model_name="$1"
echo "🔍 Checking if model '$model_name' is available..."
if curl -s "$OLLAMA_URL/api/tags" | grep -q "\"name\":\"$model_name\""; then
echo "✅ Model '$model_name' is already available."
else
echo "📥 Model '$model_name' not found. Pulling it now..."
curl -X POST "$OLLAMA_URL/api/pull" -H "Content-Type: application/json" -d "{\"name\":\"$model_name\"}"
echo ""
echo "✅ Model '$model_name' has been pulled successfully."
fi
}
# Pull the default models
pull_model "$DEFAULT_MODEL"
pull_model "$DEFAULT_IMAGE_MODEL"
# Warm up ollama with the default model
echo "🤖 Warming up Ollama with $DEFAULT_MODEL..."
curl -s "$OLLAMA_URL/api/generate" -X POST -H "Content-Type: application/json" -d "{\"model\":\"$DEFAULT_MODEL\", \"prompt\":\"Hello, Ollama!\"}" > /dev/null
echo "✅ Ollama is warmed up."
exec "$@"