Created
November 20, 2015 00:08
-
-
Save rushipkar90/5cb4addf5da6795f6f45 to your computer and use it in GitHub Desktop.
testemailaccount.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
echo > mailaccounts.txt; | |
CP_ACCOUNTS=`ls -1A /var/cpanel/users/ | grep -v "root" | grep -v "system"` | |
for user in `echo -n $CP_ACCOUNTS` | |
do | |
domain=`grep -i ^dns /var/cpanel/users/$user |cut -d= -f2`; | |
maindomain=`cat /etc/trueuserdomains | grep "$user" | cut -d : -f1`; | |
homedir=`cat /var/cpanel/userdata/"$user"/"$maindomain" | grep homedir | cut -d / -f2`; | |
for dom in `echo -n "$domain"` | |
do | |
PASSWD_FILE="/$homedir/$user/etc/$dom/passwd"; | |
echo "$PASSWD_FILE" >> userhomedir.txt; | |
if [ -f $PASSWD_FILE ] && [ -s $PASSWD_FILE ] | |
then | |
for mail in `cat $PASSWD_FILE| cut -d":" -f1 | grep -w "test"` | |
do | |
echo "$mail@$dom" >> mailaccounts.txt | |
done | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment