#!/bin/bash set -e echo "Iniciando Preinscripción..." # Esperar a que PostgreSQL esté disponible (sin nc) echo "Esperando a que PostgreSQL esté disponible..." until (echo > /dev/tcp/${DB_HOST:-postgres}/${DB_PORT:-5432}) >/dev/null 2>&1; do sleep 1 done echo "PostgreSQL está disponible" # Permisos chown -R www-data:www-data /var/www/html chmod -R 755 /var/www/html mkdir -p /var/www/html/instalacion/{temp,log,cache} chown -R www-data:www-data /var/www/html/instalacion/{temp,log,cache} chmod -R 777 /var/www/html/instalacion/{temp,log,cache} # Compilar recursos si aplica if [ "$ENVIRONMENT" = "production" ]; then echo "Compilando recursos para producción..." cd /var/www/html if [ -f "bin/preinscripcion" ]; then ./bin/preinscripcion compilar_recursos || true fi fi echo "Iniciando Apache..." exec apache2-foreground