#!/bin/sh
set -e

cd /var/www/html

# Permissões Laravel (storage, cache)
for dir in storage bootstrap/cache; do
    if [ -d "$dir" ]; then
        chown -R www-data:www-data "$dir" 2>/dev/null || true
        chmod -R ug+rwx "$dir" 2>/dev/null || true
    fi
done

exec "$@"
