#!/bin/bash # Fix LittleShop Admin HTTP 500 Error Script # Run this on the Hostinger server to diagnose and fix the issue echo "==========================================" echo "LittleShop Admin HTTP 500 Error Fix Script" echo "==========================================" echo "" # 1. Check container status echo "1. Checking container status..." docker ps -a | grep littleshop-admin echo "" # 2. Check container logs for errors echo "2. Checking recent container logs..." docker logs --tail 100 littleshop-admin 2>&1 | grep -E "ERROR|Exception|fail|500|Unable" echo "" # 3. Check full recent logs echo "3. Full recent logs (last 50 lines)..." docker logs --tail 50 littleshop-admin echo "" # 4. Check database file permissions echo "4. Checking database file permissions..." ls -la /opt/littleshop/data/ echo "" # 5. Check if database is accessible echo "5. Testing database connectivity..." docker exec littleshop-admin ls -la /app/data/ 2>/dev/null || echo "Could not access container filesystem" echo "" # 6. Check environment variables echo "6. Checking environment variables..." docker inspect littleshop-admin | grep -A 20 '"Env"' echo "" # 7. Try to fix common issues echo "7. Attempting common fixes..." echo "" # Fix database permissions (UID 1654 as per baseline) echo " - Fixing database permissions..." sudo chown -R 1654:1654 /opt/littleshop/data/ 2>/dev/null && echo " ✓ Database permissions fixed" || echo " ✗ Could not fix permissions" # Ensure database file exists if [ ! -f "/opt/littleshop/data/littleshop-production.db" ]; then echo " ✗ Database file missing! Creating new database..." # The container will create it on restart else echo " ✓ Database file exists" fi # Check if container is running if ! docker ps | grep -q littleshop-admin; then echo " ✗ Container not running. Starting container..." docker start littleshop-admin 2>/dev/null || docker restart littleshop-admin sleep 5 echo " Checking status after restart..." docker ps | grep littleshop-admin else echo " - Container is running. Restarting to apply fixes..." docker restart littleshop-admin sleep 5 fi echo "" echo "8. Final status check..." docker ps | grep littleshop-admin echo "" # Check if the site is responding now echo "9. Testing HTTP response..." curl -I http://localhost:5000 2>/dev/null | head -n 1 || echo "Local port 5000 not responding" curl -I http://localhost:8080 2>/dev/null | head -n 1 || echo "Local port 8080 not responding" echo "" echo "10. Checking latest logs after fixes..." docker logs --tail 20 littleshop-admin echo "" echo "==========================================" echo "Diagnostic complete!" echo "" echo "Common issues and solutions:" echo "1. Database permissions: Should be owned by UID 1654" echo "2. Database file: Must exist at /opt/littleshop/data/littleshop-production.db" echo "3. Environment vars: Check ASPNETCORE_ENVIRONMENT and ConnectionStrings" echo "4. Container must be on 'littleshop-network' for service connectivity" echo "" echo "If still having issues, check the full logs above for specific error messages." echo "=========================================="