Files
hostpanel/build/init.sh
ilkeral 342f1314c7 yeni
2025-07-21 13:49:36 +03:00

57 lines
1.4 KiB
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
set -e
echo "=== Container başlatılıyor ==="
# Veritabanı dosyası yolu
DB_FILE="/app/db.sqlite3"
DB_DIR="/app"
echo "Mevcut durumu kontrol ediyorum..."
ls -la /app/ || true
# Veritabanı dosyası kontrolü ve oluşturma
if [ ! -f "$DB_FILE" ]; then
echo "SQLite veritabanı bulunamadı, oluşturuluyor..."
touch "$DB_FILE"
fi
# Tüm /app dizinini 1000:1000 kullanıcısına ata
echo "Dizin sahipliği ayarlanıyor..."
chown -R 1000:1000 /app
# Veritabanı dosyası için özel izinler
echo "Veritabanı izinleri ayarlanıyor..."
chmod 666 "$DB_FILE" # Daha geniş izin
chmod 777 "$DB_DIR" # Dizin için tam izin
# Gerekli dizinleri oluştur
mkdir -p /app/media /app/static /app/logs
mkdir -p /tmp/backups
chown -R 1000:1000 /app/media /app/static /app/logs /tmp/backups
chmod -R 777 /app/media /app/static /app/logs /tmp/backups
# /tmp dizinine de tam izin ver
chmod 777 /tmp
chown 1000:1000 /tmp
echo "Final izin kontrolü:"
ls -la /app/db.sqlite3 || true
ls -ld /app/ || true
echo "=== İzinler ayarlandı, appuser olarak geçiliyor ==="
# Django migrate çalıştır (root olarak)
echo "Django migrate çalıştırılıyor..."
cd /app
python manage.py migrate --noinput || echo "Migrate hatası, devam ediliyor..."
# Veritabanı izinlerini tekrar ayarla
chown 1000:1000 "$DB_FILE"
chmod 666 "$DB_FILE"
echo "=== Uygulama başlatılıyor ==="
# appuser olarak uygulamayı başlat
exec su-exec 1000:1000 "$@"