From 66c98735185c71f6f4754c82bf1aeb5b0545a74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=93=99=F0=9D=93=BE=F0=9D=93=B5=F0=9D=93=B2?= =?UTF-8?q?=F0=9D=93=B8?= Date: Fri, 1 Nov 2024 15:35:52 +0000 Subject: [PATCH] Add bash/dovecot/validate.cpanel.MD --- bash/dovecot/validate.cpanel.MD | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bash/dovecot/validate.cpanel.MD diff --git a/bash/dovecot/validate.cpanel.MD b/bash/dovecot/validate.cpanel.MD new file mode 100644 index 0000000..8deaeb1 --- /dev/null +++ b/bash/dovecot/validate.cpanel.MD @@ -0,0 +1,26 @@ +```bash +#!/bin/bash + +# Ensure we're using Bash +if [ -z "$BASH_VERSION" ]; then + echo "This script must be run with Bash." + exit 1 +fi + + +tail -F /var/log/dovecot.log | while read -r line; do + if echo "$line" | grep -q "Login: user=<[^@]\+@[^>]\+>"; then + domain=$(echo "$line" | sed -n 's/.*Login: user=<[^@]\+@\([^>]\+\)>.*/\1/p') + + if [ -n "$domain" ]; then + owner=$( /scripts/whoowns "$domain" ) + + if [ -z "$owner" ]; then + echo "Domain $domain does not exist." + else + echo "Domain $domain exists and is owned by $owner." + fi + fi + fi +done +``` \ No newline at end of file