How to Find out Reseller Name with Domains

January 20, 2012 / Domain and DNS

Reseller is a good way to earn unlimited benefits online and if you want to list all cPanel hosting accounts under a specific reseller, then you can use the below simple shell script.

Step 1: Create the file reseller.sh and add the following code.

vi /home/reseller.sh

#!/bin/bash
usage()
{
echo "Example : $0 domain.com or username"
exit 1
}

test $1 || usage
USERN=$(grep $1 "/etc/userdomains" | awk '{print $NF}' | awk 'NR==1')

if [[ -z $USERN ]]
then
echo -e "e[1;33m $1 is not a reseller e[0m"

exit 1
fi

OWNER=`cut -d: -f1 /var/cpanel/resellers | grep -o $USERN`
exitstatus=$?

if [ "$exitstatus" == 0 ] ; then
echo ""
echo -e "e[1;31m Below are the accounts associated with the reseller $name e[0m"
echo ""

output=$(for i in `grep $OWNER /var/cpanel/users/* -l` ; do grep USER= $i ; done | awk -F"=" '{ print $2 }')
echo -e "e[1;33m $output e[0m"
else
echo -e "e[1;35m $1 is not a Reseller e[0m"
exit

Step 2:

 chmod 755 /home/reseller.sh>/pre>

Step 3:

 cd /home/

Step 4:

root@server[#] ./reseller resellerusername

or

root@server[#] ./reseller resellerdomain.com

After executing the script you will get the below output as::

root@server[#] ./reseller yourdomainname.com

Below are the accounts associated with the reseller

Jason

Billy
Mike

or

root@server[#] ./reseller newtest
newtest is not a reseller.
Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *