#!/bin/sh set -e # Ensure data directory exists mkdir -p /app/data # If bun is available, run setup (for dev images) if command -v bun >/dev/null 2>&1; then echo "Running bun setup (if needed)..." bun run setup || true fi # Initialize the database if it doesn't exist if [ ! -f "/app/data/gitea-mirror.db" ]; then echo "Initializing database..." if [ -f "dist/scripts/init-db.js" ]; then bun dist/scripts/init-db.js elif [ -f "dist/scripts/manage-db.js" ]; then bun dist/scripts/manage-db.js init else echo "Warning: Could not find database initialization scripts in dist/scripts." echo "Creating and initializing database manually..." # Create the database file touch /app/data/gitea-mirror.db # Initialize the database with required tables sqlite3 /app/data/gitea-mirror.db <