[Postfix, Web] Feature: Show last SMTP login

This commit is contained in:
andryyy
2020-09-15 11:02:53 +02:00
parent 28041b1d97
commit 1f36ae28d4
7 changed files with 49 additions and 7 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# Do not attempt to write to slave
if [[ ! -z ${REDIS_SLAVEOF_IP} ]]; then
REDIS_CMDLINE="redis-cli -h ${REDIS_SLAVEOF_IP} -p ${REDIS_SLAVEOF_PORT}"
else
REDIS_CMDLINE="redis-cli -h redis -p 6379"
fi
while read QUERY; do
QUERY=($QUERY)
# If nothing matched, end here - Postfix last line will be empty
if [[ -z "$(echo ${QUERY[0]} | tr -d '\040\011\012\015')" ]]; then
echo -ne "action=dunno\n\n"
# We found a username, log and return
elif [[ "${QUERY[0]}" =~ sasl_username ]]; then
${REDIS_CMDLINE} SET "last-login/smtp/$(echo ${QUERY[0]#sasl_username=})" "$(date +%s)"
echo -ne "action=dunno\n\n"
fi
done