#!/bin/bash
echo "========================================"
echo "   Nexora Esports - Server Setup"
echo "========================================"
echo ""

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"

echo "[1/5] Creating virtual environment..."
python3 -m venv .venv
source .venv/bin/activate

echo "[2/5] Upgrading pip..."
pip install --upgrade pip --quiet

echo "[3/5] Installing packages..."
pip install -r requirements.txt --quiet

echo "[4/5] Setting permissions..."
chmod 755 static/uploads 2>/dev/null
chmod 640 nexora.db 2>/dev/null
touch nexora.db
chmod 660 nexora.db

echo "[5/5] Initializing database..."
python3 -c "from app import init_db; init_db(); print('Database ready')"

echo ""
echo "========================================"
echo "   Setup Complete!"
echo "   Website: https://azlantraders.store"
echo "   Admin:   https://azlantraders.store/admin"
echo "========================================"
