66 lines
1.7 KiB
Bash
Executable File
66 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# GNX Mail Setup Script
|
|
echo "Setting up GNX Mail..."
|
|
|
|
# Check if Python 3.11+ is installed
|
|
python_version=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
|
|
required_version="3.11"
|
|
|
|
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
|
|
echo "Error: Python 3.11 or higher is required. Current version: $python_version"
|
|
exit 1
|
|
fi
|
|
|
|
# Create virtual environment
|
|
echo "Creating virtual environment..."
|
|
python3 -m venv venv
|
|
source venv/bin/activate
|
|
|
|
# Install Python dependencies
|
|
echo "Installing Python dependencies..."
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
# Install Node.js dependencies for frontend
|
|
echo "Installing frontend dependencies..."
|
|
cd frontend
|
|
npm install
|
|
cd ..
|
|
|
|
# Create .env file if it doesn't exist
|
|
if [ ! -f .env ]; then
|
|
echo "Creating .env file..."
|
|
cp env.example .env
|
|
echo "Please edit .env file with your configuration before running the application."
|
|
fi
|
|
|
|
# Create necessary directories
|
|
echo "Creating directories..."
|
|
mkdir -p logs
|
|
mkdir -p media
|
|
mkdir -p staticfiles
|
|
|
|
# Run database migrations
|
|
echo "Running database migrations..."
|
|
python manage.py makemigrations
|
|
python manage.py migrate
|
|
|
|
# Create superuser
|
|
echo "Creating superuser..."
|
|
python manage.py createsuperuser
|
|
|
|
# Collect static files
|
|
echo "Collecting static files..."
|
|
python manage.py collectstatic --noinput
|
|
|
|
echo "Setup complete!"
|
|
echo ""
|
|
echo "To start the application:"
|
|
echo "1. Activate virtual environment: source venv/bin/activate"
|
|
echo "2. Start Django server: python manage.py runserver"
|
|
echo "3. Start Celery worker: celery -A gnxmail worker -l info"
|
|
echo "4. Start frontend: cd frontend && npm start"
|
|
echo ""
|
|
echo "Or use Docker: docker-compose up --build"
|