Files
dj_beyhan/entrypoint.sh
Beyhan Oğur 3de0ca1fb5 first commit
2026-04-26 22:23:47 +03:00

32 lines
909 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Hata durumunda scripti durdur
set -e
# MySQL bağlantısını kontrol et (mevcut sunucu için)
echo "Checking MySQL connection..."
# Not: Mevcut MySQL sunucunuz zaten çalışıyor olmalı (10.80.80.70:3306)
# Veritabanı migrasyonlarını uygula
echo "Applying database migrations..."
python manage.py migrate --noinput
# Superuser oluştur (eğer yoksa)
echo "Creating superuser if it doesn't exist..."
python manage.py shell -c "
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(email='admin@example.com').exists():
User.objects.create_superuser('admin@example.com', 'admin')
print('Superuser created: admin@example.com / admin')
else:
print('Superuser already exists')
" || true
# Static dosyaları topla
echo "Collecting static files..."
python manage.py collectstatic --noinput --clear
echo "Starting server..."
exec "$@"