Compare commits
4 Commits
63db4c1317
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2aa6dfaad6 | |||
| 3cb450ada8 | |||
| a26b854cca | |||
| 3377e36a2e |
+12
-11
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
script_dir="$(dirname $(realpath $0))"
|
script_dir="$(dirname "$(realpath "$0")")"
|
||||||
conf_dir="${script_dir}/conf"
|
conf_dir="${script_dir}/conf"
|
||||||
conf_file="${conf_dir}/get_mail_domains.conf"
|
conf_file="${conf_dir}/get_mail_domains.conf"
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ DEFAULT_db_name="postfix"
|
|||||||
clean_up() {
|
clean_up() {
|
||||||
|
|
||||||
# Perform program exit housekeeping
|
# Perform program exit housekeeping
|
||||||
rm -rf $tmp_dir
|
rm -rf "$tmp_dir"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
echononl(){
|
echononl(){
|
||||||
echo X\\c > /tmp/shprompt$$
|
echo X\\c > /tmp/shprompt$$
|
||||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
if [ "$(wc -c /tmp/shprompt$$ | awk '{print $1}')" -eq 1 ]; then
|
||||||
echo "$*\\c" 1>&2
|
echo "$*\\c" 1>&2
|
||||||
else
|
else
|
||||||
echo -e -n "$*" 1>&2
|
echo -e -n "$*" 1>&2
|
||||||
@@ -77,14 +77,15 @@ trap clean_up SIGHUP SIGINT SIGTERM
|
|||||||
|
|
||||||
clear
|
clear
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32mRunning script \033[1m"$(basename $0)"\033[m .."
|
echo -e "\033[32mRunning script \033[1m$(basename "$0")\033[m .."
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echononl " Loading default Configuration values from $(basename ${conf_file}).."
|
echononl " Loading default Configuration values from $(basename "${conf_file}").."
|
||||||
if [[ ! -f "$conf_file" ]]; then
|
if [[ ! -f "$conf_file" ]]; then
|
||||||
echo_skipped
|
echo_skipped
|
||||||
else
|
else
|
||||||
|
# shellcheck source=/dev/null
|
||||||
source "${conf_file}" > /dev/null 2>&1
|
source "${conf_file}" > /dev/null 2>&1
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo_ok
|
echo_ok
|
||||||
@@ -131,7 +132,7 @@ fi
|
|||||||
echo ""
|
echo ""
|
||||||
echononl " Collect supported domains at this server.."
|
echononl " Collect supported domains at this server.."
|
||||||
if [[ "$db_type" = "mysql" ]] ; then
|
if [[ "$db_type" = "mysql" ]] ; then
|
||||||
domains=$(mysql $mysql_credential_args "$db_name" -N -s -e \
|
domains=$(mysql "$mysql_credential_args" "$db_name" -N -s -e \
|
||||||
"SELECT domain FROM domain ORDER by domain" 2> "$log_messages")
|
"SELECT domain FROM domain ORDER by domain" 2> "$log_messages")
|
||||||
else
|
else
|
||||||
domains=$(su - postgres -c"psql \"$db_name\" -t -q -c\"SELECT domain FROM domain ORDER by domain\"")
|
domains=$(su - postgres -c"psql \"$db_name\" -t -q -c\"SELECT domain FROM domain ORDER by domain\"")
|
||||||
@@ -144,16 +145,16 @@ else
|
|||||||
clean_up 1
|
clean_up 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n\n \033[37m\033[1mMail Domains supported by this server ("$(hostname -f)"):\033[m\n"
|
echo -e "\n\n \033[37m\033[1mMail Domains supported by this server ($(hostname -f)):\033[m\n"
|
||||||
echo "Mail Domains supported by this server ("$(hostname -f)"):" > $out_file
|
echo "Mail Domains supported by this server ($(hostname -f)):" > "$out_file"
|
||||||
echo "" >> $out_file
|
echo "" >> "$out_file"
|
||||||
|
|
||||||
for domain in $domains ; do
|
for domain in $domains ; do
|
||||||
[[ "$domain" = "ALL" ]] && continue
|
[[ "$domain" = "ALL" ]] && continue
|
||||||
echo -e " \033[32m$domain\033[m"
|
echo -e " \033[32m$domain\033[m"
|
||||||
echo " $domain" >> $out_file
|
echo " $domain" >> "$out_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "" >> $out_file
|
echo "" >> "$out_file"
|
||||||
echo ""
|
echo ""
|
||||||
clean_up 0
|
clean_up 0
|
||||||
|
|||||||
+22
-9
@@ -57,8 +57,10 @@ set -euo pipefail
|
|||||||
# - Das sind Regeln “für die Praxis”, keine 100% perfekte Klassifikation.
|
# - Das sind Regeln “für die Praxis”, keine 100% perfekte Klassifikation.
|
||||||
#
|
#
|
||||||
# 6) Erfolg/Fehlschlag:
|
# 6) Erfolg/Fehlschlag:
|
||||||
# - --success zeigt nur erfolgreiche LMTP Outcomes
|
# - --success zeigt nur Outcomes mit status=success
|
||||||
# - --fail zeigt nur nicht-erfolgreiche Outcomes
|
# - --fail zeigt nur Outcomes mit status=failed
|
||||||
|
# - Handoff-Einträge (Übergabe an Amavis) werden von beiden Filtern
|
||||||
|
# ausgeblendet, da sie keine endgültige Zustellung darstellen.
|
||||||
# - Erfolgreich definieren wir hier pragmatisch als status in:
|
# - Erfolgreich definieren wir hier pragmatisch als status in:
|
||||||
# sent | delivered | deliverable
|
# sent | delivered | deliverable
|
||||||
#
|
#
|
||||||
@@ -71,6 +73,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
FOLLOW=0
|
FOLLOW=0
|
||||||
ALL_LOGS=0
|
ALL_LOGS=0
|
||||||
|
LOG_FILE=""
|
||||||
|
|
||||||
FAIL_ONLY=0
|
FAIL_ONLY=0
|
||||||
SUCCESS_ONLY=0
|
SUCCESS_ONLY=0
|
||||||
@@ -116,7 +119,7 @@ Filter:
|
|||||||
|
|
||||||
Status-Filter:
|
Status-Filter:
|
||||||
--success nur erfolgreiche Endzustellungen (status=success)
|
--success nur erfolgreiche Endzustellungen (status=success)
|
||||||
--fail nur fehlgeschlagene Endzustellungen (status=failed oder handoff)
|
--fail nur fehlgeschlagene Endzustellungen (status=failed, kein handoff)
|
||||||
|
|
||||||
AUTH / Richtung:
|
AUTH / Richtung:
|
||||||
--sasl-only nur Einlieferungen mit SMTP AUTH (sasl_username vorhanden)
|
--sasl-only nur Einlieferungen mit SMTP AUTH (sasl_username vorhanden)
|
||||||
@@ -138,6 +141,7 @@ Debug:
|
|||||||
Input / Zeitraum:
|
Input / Zeitraum:
|
||||||
--follow tail -F /var/log/mail.log (live)
|
--follow tail -F /var/log/mail.log (live)
|
||||||
--all-logs /var/log/mail.log* inkl. .gz (historisch)
|
--all-logs /var/log/mail.log* inkl. .gz (historisch)
|
||||||
|
--log-file <pfad> einzelne Logdatei (auch .gz); nicht kombinierbar mit --follow/--all-logs
|
||||||
--since <prefix> Timestamp prefix-match (z.B. 2026-01-13T14:47)
|
--since <prefix> Timestamp prefix-match (z.B. 2026-01-13T14:47)
|
||||||
--until <prefix> stoppe sobald ts >= prefix (ISO8601 string compare)
|
--until <prefix> stoppe sobald ts >= prefix (ISO8601 string compare)
|
||||||
USAGE
|
USAGE
|
||||||
@@ -148,6 +152,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
--follow) FOLLOW=1 ;;
|
--follow) FOLLOW=1 ;;
|
||||||
--all-logs) ALL_LOGS=1 ;;
|
--all-logs) ALL_LOGS=1 ;;
|
||||||
|
--log-file) LOG_FILE="${2:-}"; shift ;;
|
||||||
--success) SUCCESS_ONLY=1 ;;
|
--success) SUCCESS_ONLY=1 ;;
|
||||||
--fail) FAIL_ONLY=1 ;;
|
--fail) FAIL_ONLY=1 ;;
|
||||||
--addr) ADDR_FILTER="${2:-}"; shift ;;
|
--addr) ADDR_FILTER="${2:-}"; shift ;;
|
||||||
@@ -183,6 +188,14 @@ if [[ "$DEDUP_PREFER" != "final" && "$DEDUP_PREFER" != "amavis" && "$DEDUP_PREFE
|
|||||||
echo "Ungültiges --dedup-prefer: $DEDUP_PREFER (final|amavis|first|last)" >&2
|
echo "Ungültiges --dedup-prefer: $DEDUP_PREFER (final|amavis|first|last)" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
if [[ -n "$LOG_FILE" && ($FOLLOW -eq 1 || $ALL_LOGS -eq 1) ]]; then
|
||||||
|
echo "--log-file kann nicht zusammen mit --follow oder --all-logs verwendet werden." >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [[ -n "$LOG_FILE" && ! -r "$LOG_FILE" ]]; then
|
||||||
|
echo "Datei nicht lesbar: $LOG_FILE" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
if [[ $SUCCESS_ONLY -eq 1 && $FAIL_ONLY -eq 1 ]]; then
|
if [[ $SUCCESS_ONLY -eq 1 && $FAIL_ONLY -eq 1 ]]; then
|
||||||
echo "Bitte nur eines von --success oder --fail verwenden." >&2
|
echo "Bitte nur eines von --success oder --fail verwenden." >&2
|
||||||
exit 2
|
exit 2
|
||||||
@@ -199,12 +212,12 @@ fi
|
|||||||
# --- Input selection ---------------------------------------------------------
|
# --- Input selection ---------------------------------------------------------
|
||||||
if [[ $FOLLOW -eq 1 ]]; then
|
if [[ $FOLLOW -eq 1 ]]; then
|
||||||
INPUT_CMD=(sudo tail -F /var/log/mail.log)
|
INPUT_CMD=(sudo tail -F /var/log/mail.log)
|
||||||
else
|
elif [[ -n "$LOG_FILE" ]]; then
|
||||||
if [[ $ALL_LOGS -eq 1 ]]; then
|
INPUT_CMD=(sudo zcat -f "$LOG_FILE")
|
||||||
|
elif [[ $ALL_LOGS -eq 1 ]]; then
|
||||||
INPUT_CMD=(sudo zcat -f /var/log/mail.log*)
|
INPUT_CMD=(sudo zcat -f /var/log/mail.log*)
|
||||||
else
|
else
|
||||||
INPUT_CMD=(sudo cat /var/log/mail.log)
|
INPUT_CMD=(sudo cat /var/log/mail.log)
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -600,8 +613,8 @@ END {
|
|||||||
if (status == "failed" && msg != "") LAST_FAILURE[qid] = msg
|
if (status == "failed" && msg != "") LAST_FAILURE[qid] = msg
|
||||||
|
|
||||||
# Statusfilter
|
# Statusfilter
|
||||||
if (success_only == 1 && !is_success(status)) next
|
if (success_only == 1 && status != "success") next
|
||||||
if (fail_only == 1 && is_success(status)) next
|
if (fail_only == 1 && status != "failed") next
|
||||||
|
|
||||||
client = (CLIENT[qid] ? CLIENT[qid] : "-")
|
client = (CLIENT[qid] ? CLIENT[qid] : "-")
|
||||||
clientip = (CLIENTIP[qid] ? CLIENTIP[qid] : "-")
|
clientip = (CLIENTIP[qid] ? CLIENTIP[qid] : "-")
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user