#!/bin/bash

# Define the directory path
DIRECTORY="/var/www/html/"


# Check if the directory exists
if [ -d "$DIRECTORY" ]; then
    echo "Updating permissions for $DIRECTORY..."
    
    # Set file permissions to 644
    find "$DIRECTORY" -type f -exec chmod 644 {} \;
    
    # Set directory permissions to 755
    find "$DIRECTORY" -type d -exec chmod 755 {} \;
    
    # Change ownership to www-data
    chown -R www-data:www-data "$DIRECTORY"

    echo "Permissions and ownership updated successfully."
else
    echo "Error: Directory $DIRECTORY does not exist."
fi
