2019-01-04 11:24:22 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2018-03-31 19:35:32 +02:00
|
|
|
# Display PHP error's or not
|
|
|
|
|
if [[ "$ERRORS" != "1" ]] ; then
|
2021-07-04 13:30:09 +02:00
|
|
|
sed -i -e "s/error_reporting =.*/error_reporting = E_ALL/g" /etc/php8/php.ini
|
|
|
|
|
sed -i -e "s/display_errors =.*/display_errors = stdout/g" /etc/php8/php.ini
|
2018-03-31 19:35:32 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Disable opcache?
|
|
|
|
|
if [[ -v NO_OPCACHE ]]; then
|
2021-07-04 13:30:09 +02:00
|
|
|
sed -i -e "s/zend_extension=opcache.so/;zend_extension=opcache.so/g" /etc/php8/conf.d/00_opcache.ini
|
2018-03-31 19:35:32 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Tweak nginx to match the workers to cpu's
|
|
|
|
|
procs=$(cat /proc/cpuinfo | grep processor | wc -l)
|
|
|
|
|
sed -i -e "s/worker_processes 5/worker_processes $procs/" /etc/nginx/nginx.conf
|
|
|
|
|
|
2019-01-03 19:09:22 -08:00
|
|
|
# Copy important env vars for PHP-FPM to access
|
2021-07-04 13:30:09 +02:00
|
|
|
PHP_ENV_FILE="/etc/php8/php-fpm.d/${PHP_ENV_FILE:-env.conf}"
|
2019-01-03 19:09:22 -08:00
|
|
|
echo '[www]' > "$PHP_ENV_FILE"
|
2021-07-04 13:30:09 +02:00
|
|
|
echo 'user = nginx' >> "$PHP_ENV_FILE"
|
|
|
|
|
echo 'group = www-data' >> "$PHP_ENV_FILE"
|
|
|
|
|
env | grep -e 'REPORT_DB_HOST' -e 'REPORT_DB_PORT' -e 'REPORT_DB_NAME' -e 'REPORT_DB_USER' -e 'REPORT_DB_PASS' | sed "s/\(.*\)=\(.*\)/env[\1] = '\2'/" >> "$PHP_ENV_FILE"
|
|
|
|
|
|
|
|
|
|
# compat from older image where variable was not existing
|
|
|
|
|
grep -e ^REPORT_DB_PORT "$PHP_ENV_FILE" || echo env[REPORT_DB_PORT] = 3306 >> "$PHP_ENV_FILE"
|
2019-01-03 19:09:22 -08:00
|
|
|
|
2018-03-31 19:35:32 +02:00
|
|
|
# Start supervisord and services
|
|
|
|
|
/usr/bin/supervisord -n -c /etc/supervisord.conf
|
2022-08-09 20:48:04 +02:00
|
|
|
|
|
|
|
|
# Get and parse dmarc reports once at startup to avoid PHP errors with a new database
|
|
|
|
|
if /usr/bin/dmarcts-report-parser.pl -i -d -r > /var/log/nginx/dmarc-reports.log 2>&1; then
|
|
|
|
|
echo 'INFO: Dmarc reports parsed successfully'
|
|
|
|
|
else
|
|
|
|
|
echo 'CRIT: Dmarc reports could not be parsed. Check your IMAP and MYSQL Settings.'
|
|
|
|
|
echo -e "DEBUG: Parsing failed with the following output:\n"
|
|
|
|
|
cat /var/log/nginx/dmarc-reports.log
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|