#!/bin/bash
set -e

APP_PATH="/var/www/html/api"

echo "Setting permissions..."

chown -R www-data:www-data "$APP_PATH"

find "$APP_PATH" -type d -exec chmod 775 {} \;
find "$APP_PATH" -type f -exec chmod 664 {} \;

chmod -R 775 "$APP_PATH/application/cache" || true
chmod -R 775 "$APP_PATH/application/logs" || true

echo "Permissions updated successfully."