#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# precreate log files
if [[ ! -f /config/log/php/error.log ]]; then
    touch /config/log/php/error.log
fi

# create local php.ini if it doesn't exist, set local timezone
if [[ ! -f /config/php/php-local.ini ]]; then
    printf "; Edit this file to override php.ini directives\\n\\n" >/config/php/php-local.ini
    # set default timezone
    printf "date.timezone = %s\\n" "${TZ:-UTC}" >>/config/php/php-local.ini
fi

# create override for www.conf if it doesn't exist
if [[ ! -f /config/php/www2.conf ]]; then
    printf "; Edit this file to override www.conf and php-fpm.conf directives and restart the container\\n\\n; Pool name\\n[www]\\n\\n" >/config/php/www2.conf
fi
