#!/bin/sh # Wait for volume mount to settle (Easypanel may mount after container starts) sleep 3 # Check if data.db exists in storage folder and has content DB_PATH="/app/storage/data.db" UPLOADS_PATH="/app/storage/uploads" # Ensure storage directories exist mkdir -p "$UPLOADS_PATH" # Check if data.db exists and has content if [ -f "$DB_PATH" ]; then DB_SIZE=$(stat -c%s "$DB_PATH" 2>/dev/null || stat -f%z "$DB_PATH" 2>/dev/null || echo "0") if [ "$DB_SIZE" -gt 1000 ]; then if sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM content" 2>/dev/null | grep -q "^[1-9]"; then echo "Database exists with content, starting normally..." exec node ./dist/server/entry.mjs fi fi fi echo "Database missing, empty, or corrupted. Running emdash init & seed..." cd /app pnpm exec emdash init pnpm exec emdash seed exec node ./dist/server/entry.mjs