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