-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathollama-init.sh
More file actions
47 lines (40 loc) · 1.08 KB
/
ollama-init.sh
File metadata and controls
47 lines (40 loc) · 1.08 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
# Start Ollama server in background
echo "Starting Ollama server..."
ollama serve > /tmp/ollama.log 2>&1 &
SERVER_PID=$!
# Wait for server to be ready
echo "Waiting for Ollama API to be ready..."
for i in {1..60}; do
if curl -sf http://localhost:11434/api/tags > /dev/null 2>&1; then
echo "Ollama server is ready!"
break
fi
if [ $i -eq 60 ]; then
echo "Timeout waiting for Ollama server" >&2
cat /tmp/ollama.log >&2
exit 1
fi
sleep 1
done
MODELS="${OLLAMA_MODELS:-llama3.2:3b den dengcao/Qwen3-Embedding-0.6B:Q8_0}"
echo "Pulling models: $MODELS"
for model in $MODELS; do
echo "Pulling model: $model"
if ollama pull "$model"; then
echo "✓ Successfully pulled: $model"
else
echo "Failed to pull: $model" >&2
fi
done
# Verify models are available
echo "Verifying models..."
ollama list
# Stop background server
echo "Stopping background server..."
kill $SERVER_PID 2>/dev/null || true
wait $SERVER_PID 2>/dev/null || true
# Start Ollama server in foreground
echo "Init complete. Starting Ollama server in foreground..."
exec ollama serve