|
| 1 | +#!/bin/bash |
| 2 | +# KEA GUI Container Diagnostics Script |
| 3 | +# Run this to diagnose configuration issues |
| 4 | + |
| 5 | +CONTAINER_NAME="${1:-kea-gui}" |
| 6 | + |
| 7 | +echo "╔════════════════════════════════════════════════════════════════╗" |
| 8 | +echo "║ KEA GUI Container Diagnostics ║" |
| 9 | +echo "╚════════════════════════════════════════════════════════════════╝" |
| 10 | +echo "" |
| 11 | +echo "Container: $CONTAINER_NAME" |
| 12 | +echo "" |
| 13 | + |
| 14 | +# Check if container exists |
| 15 | +if ! docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then |
| 16 | + echo "❌ Container '$CONTAINER_NAME' not found!" |
| 17 | + echo "" |
| 18 | + echo "Available containers:" |
| 19 | + docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}' |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 24 | +echo "1. Container Status" |
| 25 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 26 | +docker ps -a --filter "name=^${CONTAINER_NAME}$" --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' |
| 27 | +echo "" |
| 28 | + |
| 29 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 30 | +echo "2. Config File on Host" |
| 31 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 32 | +if [ -f "config.yaml" ]; then |
| 33 | + echo "✅ config.yaml exists in current directory" |
| 34 | + ls -lh config.yaml |
| 35 | + echo "" |
| 36 | + echo "KEA URL configured:" |
| 37 | + grep "control_agent_url" config.yaml || echo "⚠️ control_agent_url not found" |
| 38 | +else |
| 39 | + echo "❌ config.yaml NOT FOUND in current directory!" |
| 40 | + echo " Create one or cd to the directory containing config.yaml" |
| 41 | +fi |
| 42 | +echo "" |
| 43 | + |
| 44 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 45 | +echo "3. Container Environment Variables" |
| 46 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 47 | +docker exec "$CONTAINER_NAME" env | grep -E "CONFIG|PYTHON" 2>&1 || echo "❌ Cannot access container environment" |
| 48 | +echo "" |
| 49 | + |
| 50 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 51 | +echo "4. Config Directory in Container" |
| 52 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 53 | +docker exec "$CONTAINER_NAME" ls -la /app/config/ 2>&1 || echo "❌ /app/config/ directory not found or not accessible" |
| 54 | +echo "" |
| 55 | + |
| 56 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 57 | +echo "5. Config File Content in Container" |
| 58 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 59 | +if docker exec "$CONTAINER_NAME" test -f /app/config/config.yaml 2>/dev/null; then |
| 60 | + echo "✅ Config file exists in container" |
| 61 | + echo "" |
| 62 | + docker exec "$CONTAINER_NAME" cat /app/config/config.yaml 2>&1 | head -20 |
| 63 | +else |
| 64 | + echo "❌ Config file NOT FOUND at /app/config/config.yaml" |
| 65 | + echo " This means the volume mount is missing or incorrect!" |
| 66 | + echo "" |
| 67 | + echo " Fix: Stop container and run with:" |
| 68 | + echo " docker run -d --name $CONTAINER_NAME -p 5000:5000 \\" |
| 69 | + echo " -v \$(pwd)/config.yaml:/app/config/config.yaml:ro \\" |
| 70 | + echo " awkto/kea-gui-reservations:latest" |
| 71 | +fi |
| 72 | +echo "" |
| 73 | + |
| 74 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 75 | +echo "6. API Config Endpoint Check" |
| 76 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 77 | +RESPONSE=$(curl -s http://localhost:5000/api/config 2>&1) |
| 78 | +if echo "$RESPONSE" | grep -q "control_agent_url"; then |
| 79 | + KEA_URL=$(echo "$RESPONSE" | grep -o '"control_agent_url":"[^"]*"' | cut -d'"' -f4) |
| 80 | + echo "✅ API is responding" |
| 81 | + echo " Configured KEA URL: $KEA_URL" |
| 82 | + |
| 83 | + if [[ "$KEA_URL" == *"localhost"* ]] || [[ "$KEA_URL" == *"127.0.0.1"* ]]; then |
| 84 | + echo " ⚠️ WARNING: Using localhost - config file may not be mounted!" |
| 85 | + fi |
| 86 | +else |
| 87 | + echo "❌ Cannot reach API or invalid response" |
| 88 | + echo "Response: $RESPONSE" |
| 89 | +fi |
| 90 | +echo "" |
| 91 | + |
| 92 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 93 | +echo "7. Health Check" |
| 94 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 95 | +curl -s http://localhost:5000/api/health 2>&1 | python3 -m json.tool 2>/dev/null || echo "❌ Health check failed or invalid JSON" |
| 96 | +echo "" |
| 97 | + |
| 98 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 99 | +echo "8. Recent Container Logs (last 30 lines)" |
| 100 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 101 | +docker logs --tail 30 "$CONTAINER_NAME" 2>&1 |
| 102 | +echo "" |
| 103 | + |
| 104 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 105 | +echo "9. Volume Mounts" |
| 106 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 107 | +docker inspect "$CONTAINER_NAME" --format='{{range .Mounts}}{{.Source}} -> {{.Destination}} ({{.Mode}}){{"\n"}}{{end}}' 2>&1 |
| 108 | +echo "" |
| 109 | + |
| 110 | +echo "╔════════════════════════════════════════════════════════════════╗" |
| 111 | +echo "║ Summary ║" |
| 112 | +echo "╚════════════════════════════════════════════════════════════════╝" |
| 113 | +echo "" |
| 114 | + |
| 115 | +# Determine issues |
| 116 | +HAS_ISSUES=false |
| 117 | + |
| 118 | +# Check if config file is mounted |
| 119 | +if ! docker exec "$CONTAINER_NAME" test -f /app/config/config.yaml 2>/dev/null; then |
| 120 | + echo "❌ ISSUE: Config file not mounted in container" |
| 121 | + HAS_ISSUES=true |
| 122 | +fi |
| 123 | + |
| 124 | +# Check if using localhost |
| 125 | +KEA_URL=$(curl -s http://localhost:5000/api/config 2>/dev/null | grep -o '"control_agent_url":"[^"]*"' | cut -d'"' -f4) |
| 126 | +if [[ "$KEA_URL" == *"localhost"* ]] || [[ "$KEA_URL" == *"127.0.0.1"* ]]; then |
| 127 | + echo "⚠️ WARNING: Application is configured to use localhost" |
| 128 | + echo " This usually means the config file is not properly mounted" |
| 129 | + HAS_ISSUES=true |
| 130 | +fi |
| 131 | + |
| 132 | +if [ "$HAS_ISSUES" = false ]; then |
| 133 | + echo "✅ No obvious issues detected!" |
| 134 | + echo "" |
| 135 | + echo "If you're still having problems, check:" |
| 136 | + echo " - KEA server is reachable from this container" |
| 137 | + echo " - KEA Control Agent is running on the configured port" |
| 138 | + echo " - Required hook libraries (lease_cmds, host_cmds) are loaded" |
| 139 | +else |
| 140 | + echo "" |
| 141 | + echo "📋 Recommended Actions:" |
| 142 | + echo "" |
| 143 | + echo "1. Stop the container:" |
| 144 | + echo " docker stop $CONTAINER_NAME && docker rm $CONTAINER_NAME" |
| 145 | + echo "" |
| 146 | + echo "2. Ensure config.yaml exists in current directory" |
| 147 | + echo "" |
| 148 | + echo "3. Run with proper volume mount:" |
| 149 | + echo " docker run -d --name $CONTAINER_NAME \\" |
| 150 | + echo " -p 5000:5000 \\" |
| 151 | + echo " -v \$(pwd)/config.yaml:/app/config/config.yaml:ro \\" |
| 152 | + echo " awkto/kea-gui-reservations:latest" |
| 153 | + echo "" |
| 154 | + echo " OR use docker-compose:" |
| 155 | + echo " docker-compose up -d" |
| 156 | +fi |
| 157 | + |
| 158 | +echo "" |
| 159 | +echo "For more help, see: DOCKER_CONFIG_TROUBLESHOOTING.md" |
0 commit comments