#!/bin/sh
# Fix php module path
if [ -f /etc/apache2/conf.d/php-module.conf ]; then
    sed -i 's|modules/mod_php85.so|/usr/lib/apache2/mod_php.so|' \
        /etc/apache2/conf.d/php-module.conf
fi

# Fix /var/www/logs - remove symlink, create real dir for STIG compliance
rm -f /var/www/logs
mkdir -p /var/www/logs

# Redirect apache2 logs to /var/www/logs
sed -i 's|/var/log/apache2|/var/www/logs|g' \
    /etc/apache2/httpd.conf 2>/dev/null || true

# Add conf.d include to httpd.conf if not present
grep -q "conf.d" /etc/apache2/httpd.conf || \
    echo "IncludeOptional /etc/apache2/conf.d/*.conf" >> /etc/apache2/httpd.conf
