#!/bin/bash
set -e

# Ensure uploads subdirectories exist and are writable
UPLOAD_ROOT="/var/www/html/uploads"
mkdir -p "$UPLOAD_ROOT/announcements" "$UPLOAD_ROOT/slides" "$UPLOAD_ROOT/datasources"

# Relax permissions so Apache (www-data) can write when using bind mounts
chown -R www-data:www-data "$UPLOAD_ROOT"
chmod -R 775 "$UPLOAD_ROOT"

exec apache2-foreground
