mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-10 01:15:00 +02:00
Complete Refactor for target/bin
(#1654)
* documentation and script updates trying to fix #1647 * preparations for refactoring target/bin/ * complete refactor for target/bin/ * changing script output slightly * outsourcing functions in `bin-helper.sh` * re-wrote linting to allow for proper shellcheck -x execution * show explanation for shellcheck ignore * adding some more information
This commit is contained in:
parent
0ada57d87c
commit
da8171388f
37 changed files with 579 additions and 504 deletions
|
@ -1,17 +1,19 @@
|
|||
#!/bin/bash
|
||||
#! /bin/bash
|
||||
|
||||
HOSTNAME=$1
|
||||
RECIPIENT=$2
|
||||
SENDER=$3
|
||||
errex() {
|
||||
echo -e "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
# shellcheck source=../bin-helper.sh
|
||||
. /usr/local/bin/bin-helper.sh
|
||||
|
||||
test -x /usr/sbin/pflogsumm || errex "Critical: /usr/sbin/pflogsumm not found"
|
||||
HOSTNAME=${1}
|
||||
RECIPIENT=${2}
|
||||
SENDER=${3}
|
||||
|
||||
# The case that the mail.log.1 file isn't readable shouldn't actually be possible with logrotate not rotating empty files.. But you never know!
|
||||
if [ -r "/var/log/mail/mail.log.1" ]; then
|
||||
[[ -x /usr/sbin/pflogsumm ]] || errex "Critical: /usr/sbin/pflogsumm not found"
|
||||
|
||||
# The case that the mail.log.1 file isn't readable shouldn't
|
||||
# actually be possible with logrotate not rotating empty files..
|
||||
# But you never know!
|
||||
if [[ -r "/var/log/mail/mail.log.1" ]]
|
||||
then
|
||||
BODY=$(/usr/sbin/pflogsumm /var/log/mail/mail.log.1 --problems-first)
|
||||
else
|
||||
BODY="Error: Mail log not readable or not found: /var/log/mail/mail.log.1
|
||||
|
@ -19,15 +21,15 @@ else
|
|||
In case of mail inactivity since the last report, this might be considered a nuisance warning.
|
||||
|
||||
Yours faithfully,
|
||||
The $HOSTNAME Mailserver"
|
||||
The ${HOSTNAME} Mailserver"
|
||||
fi
|
||||
|
||||
sendmail -t <<EOF
|
||||
From: $SENDER
|
||||
To: $RECIPIENT
|
||||
Subject: Postfix Summary for $HOSTNAME
|
||||
From: ${SENDER}
|
||||
To: ${RECIPIENT}
|
||||
Subject: Postfix Summary for ${HOSTNAME}
|
||||
Content-Transfer-Encoding: 8bit
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
$BODY
|
||||
${BODY}
|
||||
EOF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue