docker-mailserver/target/bin/report-pflogsumm-yesterday

28 lines
596 B
Plaintext
Raw Normal View History

#! /bin/bash
# shellcheck source=../bin-helper.sh
. /usr/local/bin/bin-helper.sh
set -o errexit
set -o pipefail
set -o nounset
2019-09-15 13:40:05 +00:00
HOSTNAME=${1}
RECIPIENT=${2}
SENDER=${3}
2019-09-15 13:40:05 +00:00
[[ -x /usr/sbin/pflogsumm ]] || errex "Critical: /usr/sbin/pflogsumm not found"
2019-09-15 13:40:05 +00:00
# shellcheck disable=SC2046
2019-09-15 13:40:05 +00:00
BODY=$(gzip -cdfq $(ls -tr /var/log/mail/mail.log*) | /usr/sbin/pflogsumm --problems_first -d yesterday)
sendmail -t <<EOF
From: ${SENDER}
To: ${RECIPIENT}
Subject: Postfix summary for ${HOSTNAME} sent $(date '+%Y-%m-%d_%H%M%S')
2019-09-15 13:40:05 +00:00
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
${BODY}
2019-09-15 13:40:05 +00:00
EOF