- Added UseForwardedHeaders to properly handle X-Forwarded-For and X-Forwarded-Proto - Fixes anti-forgery token validation when behind nginx proxy - Resolves HTTP 500 errors on POST requests to login endpoint
83 lines
2.9 KiB
Bash
83 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Quick Fix for Unhealthy LittleShop Admin Container"
|
|
echo "=================================================="
|
|
echo ""
|
|
|
|
# Step 1: Stop and remove the problematic container
|
|
echo "1. Stopping current container..."
|
|
docker stop littleshop-admin 2>/dev/null
|
|
docker rm littleshop-admin 2>/dev/null
|
|
|
|
# Step 2: Fix permissions BEFORE starting
|
|
echo "2. Fixing file permissions..."
|
|
sudo mkdir -p /opt/littleshop/{data,logs,uploads}
|
|
sudo chown -R 1654:1654 /opt/littleshop/data/
|
|
sudo chown -R 1654:1654 /opt/littleshop/logs/
|
|
sudo chown -R 1654:1654 /opt/littleshop/uploads/
|
|
|
|
# Step 3: Check if database file exists and has content
|
|
echo "3. Checking database..."
|
|
if [ -f "/opt/littleshop/data/littleshop-production.db" ]; then
|
|
SIZE=$(stat -c%s "/opt/littleshop/data/littleshop-production.db")
|
|
echo " Database exists: $SIZE bytes"
|
|
if [ "$SIZE" -eq 0 ]; then
|
|
echo " ⚠ Database is empty, removing so it can be recreated..."
|
|
rm /opt/littleshop/data/littleshop-production.db
|
|
fi
|
|
else
|
|
echo " Database will be created on first run"
|
|
fi
|
|
|
|
# Step 4: Start container WITHOUT health check first to let it initialize
|
|
echo "4. Starting container (without health check for initialization)..."
|
|
docker run -d \
|
|
--name littleshop-admin \
|
|
--restart unless-stopped \
|
|
--network littleshop-network \
|
|
-p 5000:8080 \
|
|
-v /opt/littleshop/data:/app/data \
|
|
-v /opt/littleshop/logs:/app/logs \
|
|
-v /opt/littleshop/uploads:/app/wwwroot/uploads \
|
|
-e ASPNETCORE_ENVIRONMENT=Production \
|
|
-e ASPNETCORE_URLS="http://+:8080" \
|
|
-e ConnectionStrings__DefaultConnection="Data Source=/app/data/littleshop-production.db" \
|
|
-e SilverPay__BaseUrl="http://silverpay-api:8000" \
|
|
-e SilverPay__ApiKey="7703aa7a62fa4b40a87e9cfd867f5407147515c0986116ea54fc00c0a0bc30d8" \
|
|
-e SilverPay__WebhookSecret="Thefa1r1esd1d1twebhooks2024" \
|
|
-e JWT_SECRET_KEY="ThisIsAVeryLongSecretKeyForJWTTokenGeneration123456789!" \
|
|
littleshop:latest
|
|
|
|
echo "5. Waiting for initialization (15 seconds)..."
|
|
sleep 15
|
|
|
|
# Step 5: Check if it's running
|
|
echo "6. Checking status..."
|
|
docker ps | grep littleshop-admin
|
|
echo ""
|
|
|
|
# Step 6: Test the endpoints
|
|
echo "7. Testing endpoints..."
|
|
echo " Health endpoint:"
|
|
curl -s http://localhost:5000/health | head -c 100 && echo "..."
|
|
echo ""
|
|
echo " Login page:"
|
|
curl -s -o /dev/null -w " HTTP Status: %{http_code}\n" http://localhost:5000/Admin/Account/Login
|
|
echo ""
|
|
|
|
# Step 7: Show recent logs
|
|
echo "8. Recent logs:"
|
|
docker logs --tail 15 littleshop-admin 2>&1 | grep -v "Microsoft.EntityFrameworkCore"
|
|
echo ""
|
|
|
|
echo "=================================================="
|
|
echo "Status Check Complete!"
|
|
echo ""
|
|
echo "The container is now running WITHOUT health checks."
|
|
echo "If the login page works (HTTP 200 or 302), the issue was the health check timing."
|
|
echo ""
|
|
echo "To test login:"
|
|
echo " https://admin.thebankofdebbie.giize.com/Admin/Account/Login"
|
|
echo " Username: admin"
|
|
echo " Password: admin"
|
|
echo "==================================================" |