# Complete Explorer Restoration - Commands to Run

**Run these commands INSIDE the container (you're already there as root@blockscout-1)**

## Quick Complete Restoration

Copy and paste this entire block:

```bash
#!/bin/bash
echo "=== Starting Blockscout ==="

# Check what's available
echo "1. Checking installation..."
systemctl list-unit-files | grep blockscout || echo "No systemd service"
test -f /opt/blockscout/docker-compose.yml && echo "docker-compose.yml exists" || echo "docker-compose.yml NOT found"
docker ps -a | head -5

# Start Blockscout
echo ""
echo "2. Starting Blockscout..."
systemctl start blockscout 2>&1 || true
sleep 5

# If systemd didn't work, try docker-compose
if ! systemctl is-active --quiet blockscout 2>/dev/null; then
    if [ -f /opt/blockscout/docker-compose.yml ]; then
        echo "Starting via docker-compose..."
        cd /opt/blockscout
        docker-compose up -d 2>&1 || docker compose up -d 2>&1
        sleep 15
    fi
fi

# Start any stopped containers
echo "Starting stopped containers..."
docker ps -a --filter "status=exited" -q | xargs -r docker start 2>&1 || true
sleep 10

# Wait for startup
echo ""
echo "3. Waiting for Blockscout to start (30 seconds)..."
sleep 30

# Test
echo ""
echo "4. Testing..."
echo "Port 4000:"
ss -tlnp | grep :4000 || echo "NOT listening"
echo ""
echo "API Test:"
curl -s http://127.0.0.1:4000/api/v2/status | head -10 || echo "NOT responding"
echo ""
echo "Docker containers:"
docker ps | grep -E "blockscout|postgres" || echo "None running"

echo ""
echo "=== Complete ==="
```

## Step-by-Step (if you prefer)

```bash
# Step 1: Check what's installed
systemctl list-unit-files | grep blockscout
ls -la /opt/blockscout/ 2>/dev/null | head -5
docker ps -a

# Step 2: Start via systemd
systemctl start blockscout
sleep 5
systemctl status blockscout --no-pager -l | head -15

# Step 3: If systemd doesn't work, try docker-compose
if ! systemctl is-active --quiet blockscout; then
    cd /opt/blockscout
    docker-compose up -d
    sleep 20
fi

# Step 4: Start any stopped containers
docker ps -a --filter "status=exited" -q | xargs docker start
sleep 10

# Step 5: Wait and test
sleep 30
curl -s http://127.0.0.1:4000/api/v2/status
ss -tlnp | grep :4000
docker ps
```

## After Starting - Verify from pve2

Once you exit the container, test from pve2:

```bash
# Exit container first
exit

# Then on pve2, test:
curl http://192.168.11.140:4000/api/v2/status
curl http://192.168.11.140/api/v2/stats
```

## Expected Results

**Success:**
- Port 4000 is listening
- API returns JSON with `chain_id: 138`
- Nginx proxy works (not 502 Bad Gateway)

**If still not working:**
- Check logs: `journalctl -u blockscout -n 50`
- Check Docker: `docker-compose -f /opt/blockscout/docker-compose.yml logs`
- Verify PostgreSQL is running: `docker ps | grep postgres`

