Files

82 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# One-time host setup for OpenClaw with Ollama
# Run this BEFORE deploying the container.
set -e
echo "=== OpenClaw + Ollama Setup ==="
echo ""
# Ensure config dirs exist
mkdir -p /srv/openclaw/config
mkdir -p /srv/openclaw/workspace
# Remove old misconfigured files from previous attempts
rm -f /srv/openclaw/config/config.json
rm -f /srv/openclaw/config/auth-profiles.json
rm -f /srv/openclaw/config/agents/main/agent/auth-profiles.json 2>/dev/null || true
# Write openclaw.json - the correct config file for provider setup
cat > /srv/openclaw/config/openclaw.json << 'EOF'
{
"models": {
"providers": {
"ollama": {
"baseUrl": "http://ollama:11434/v1",
"apiKey": "ollama-local",
"api": "openai-completions",
"models": [
{
"id": "qwen2.5:7b",
"name": "Qwen 2.5 7B",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 32768,
"maxTokens": 32768
},
{
"id": "qwen2.5-coder:7b",
"name": "Qwen 2.5 Coder 7B",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 32768,
"maxTokens": 32768
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "ollama/qwen2.5:7b"
}
}
}
}
EOF
# Fix ownership so the node user (uid 1000) inside the container can read/write
chown -R 1000:1000 /srv/openclaw
echo "✓ Created /srv/openclaw/config/openclaw.json"
echo "✓ Removed old conflicting config files"
echo "✓ Fixed permissions (uid 1000)"
echo ""
echo "=== Next Steps ==="
echo ""
echo "1. Build the image:"
echo " docker compose -f openclaw/docker-compose.yml build"
echo ""
echo "2. Start the container:"
echo " docker compose -f openclaw/docker-compose.yml up -d"
echo ""
echo "3. Check logs:"
echo " docker logs openclaw -f"
echo ""
echo "4. Verify Ollama connectivity:"
echo " docker exec openclaw curl -s http://ollama:11434/v1/models | head -c 200"
echo ""
echo "5. Redeploy Portainer stack after pushing to git."