#!/bin/bash
set -e

echo "Setting up append mode deployment..."

# Ensure target directory exists
mkdir -p /var/www/

# Since CodeDeploy already copied files to /var/www/, 
# we just need to ensure proper permissions and handle any conflicts
echo "Files already copied by CodeDeploy to /var/www/"
echo "Checking for any file conflicts..."

# List what was deployed (with error handling)
if [ -d "/var/www/" ]; then
    echo "Deployed files in /var/www/:"
    ls -la /var/www/ | head -10 || echo "Could not list files in /var/www/"
else
    echo "Warning: /var/www/ directory does not exist"
fi

echo "Append mode deployment completed"
