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