-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify_setup.sh
More file actions
executable file
·135 lines (120 loc) · 4.17 KB
/
verify_setup.sh
File metadata and controls
executable file
·135 lines (120 loc) · 4.17 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# LibreTranslate Setup Verification Script
# This script verifies that LibreTranslate is properly installed and running
set -e
echo "=========================================="
echo "LibreTranslate Setup Verification"
echo "=========================================="
echo ""
# Check if Docker is installed
echo "1. Checking Docker installation..."
if ! command -v docker &> /dev/null; then
echo " ❌ Docker is not installed"
echo " Please install Docker: https://docs.docker.com/get-docker/"
exit 1
fi
echo " ✅ Docker is installed: $(docker --version)"
# Check if Docker Compose is installed
echo ""
echo "2. Checking Docker Compose installation..."
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo " ❌ Docker Compose is not installed"
echo " Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
echo " ✅ Docker Compose is installed"
# Check if docker-compose.yml exists
echo ""
echo "3. Checking docker-compose.yml..."
if [ ! -f "docker-compose.yml" ]; then
echo " ❌ docker-compose.yml not found"
exit 1
fi
echo " ✅ docker-compose.yml found"
# Check if LibreTranslate container is running
echo ""
echo "4. Checking LibreTranslate container status..."
if docker ps --format '{{.Names}}' | grep -q "videotranslator-libretranslate"; then
echo " ✅ LibreTranslate container is running"
else
echo " ⚠️ LibreTranslate container is not running"
echo " Starting LibreTranslate..."
docker-compose up -d
echo " Waiting for LibreTranslate to start (30 seconds)..."
sleep 30
fi
# Check LibreTranslate health endpoint
echo ""
echo "5. Checking LibreTranslate health..."
MAX_RETRIES=5
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
if curl -s http://localhost:5000/health > /dev/null 2>&1; then
echo " ✅ LibreTranslate is healthy and responding"
break
else
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo " ❌ LibreTranslate is not responding"
echo " Check logs with: docker-compose logs libretranslate"
exit 1
fi
echo " ⏳ Waiting for LibreTranslate to be ready (attempt $RETRY_COUNT/$MAX_RETRIES)..."
sleep 10
fi
done
# Test languages endpoint
echo ""
echo "6. Testing languages endpoint..."
LANG_COUNT=$(curl -s http://localhost:5000/languages | grep -o '"code"' | wc -l)
if [ "$LANG_COUNT" -gt 0 ]; then
echo " ✅ Languages endpoint working ($LANG_COUNT languages available)"
else
echo " ❌ Languages endpoint failed"
exit 1
fi
# Test translation
echo ""
echo "7. Testing translation (English to Spanish)..."
TRANSLATION=$(curl -s -X POST http://localhost:5000/translate \
-H "Content-Type: application/json" \
-d '{"q":"Hello, world!","source":"en","target":"es","format":"text"}' \
| grep -o '"translatedText":"[^"]*"' | cut -d'"' -f4)
if [ -n "$TRANSLATION" ]; then
echo " ✅ Translation successful: '$TRANSLATION'"
else
echo " ❌ Translation failed"
exit 1
fi
# Check Python dependencies
echo ""
echo "8. Checking Python dependencies..."
if command -v python3 &> /dev/null; then
echo " ✅ Python 3 is installed: $(python3 --version)"
# Check if httpx is installed
if python3 -c "import httpx" 2>/dev/null; then
echo " ✅ httpx library is installed"
else
echo " ⚠️ httpx library not found"
echo " Install with: uv pip install httpx"
fi
else
echo " ⚠️ Python 3 is not installed"
fi
echo ""
echo "=========================================="
echo "✅ All checks passed!"
echo "=========================================="
echo ""
echo "LibreTranslate is ready to use at: http://localhost:5000"
echo ""
echo "Next steps:"
echo " 1. Run example script: python examples/translate_example.py"
echo " 2. Open web UI: http://localhost:5000"
echo " 3. Check documentation: TRANSLATION_GUIDE.md"
echo ""
echo "Useful commands:"
echo " - View logs: docker-compose logs -f libretranslate"
echo " - Stop service: docker-compose stop"
echo " - Restart: docker-compose restart libretranslate"
echo ""