Better email log handling

This commit is contained in:
Bob Mottram 2018-05-23 18:14:34 +01:00
parent 8eb28483f0
commit 77993fb229
1 changed files with 21 additions and 11 deletions

View File

@ -1696,6 +1696,15 @@ function install_email {
function remove_ip_addresses_from_email_logs {
{ echo '#!/bin/bash';
echo '';
echo 'if grep -q "= /dev/null" /etc/php/7.0/fpm/php-fpm.conf; then';
echo ' if [ -f /var/log/exim4/mainlog ]; then';
echo ' rm /var/log/exim4/mainlog';
echo ' fi';
echo ' if [ -f /var/log/exim4/rejectlog ]; then';
echo ' rm /var/log/exim4/rejectlog';
echo ' fi';
echo 'else';
echo ' if [ -f /var/log/exim4/mainlog ]; then';
echo " if grep -q '\\[' /var/log/exim4/mainlog; then";
echo " tail -n 50 /var/log/exim4/mainlog | sed 's/\\[[^][]*\\]//g' > /tmp/.exim4_mainlog";
@ -1709,6 +1718,7 @@ function remove_ip_addresses_from_email_logs {
echo ' chown Debian-exim:adm /tmp/.exim4_rejectlog';
echo ' mv /tmp/.exim4_rejectlog /var/log/exim4/rejectlog';
echo ' fi';
echo ' fi';
echo 'fi'; } > /usr/bin/exim_log_tidy
chmod +x /usr/bin/exim_log_tidy
cron_add_mins 1 '/usr/bin/exim_log_tidy'