Get list of users that belong to cPanel reseller
Ever needed to write a script that works with all cPanel accounts that are “owned” by a specific cPanel reseller account? Me too. But I wasn’t sure how to do it.
cPanel allows me to see this, but I wanted to automate some things. Such as a custom bash script that lets me run CXS (ConfigServer Exploit Scanner) via command line for all of a particular reseller’s cPanel accounts, and then provide a report to them of outdated software.
It is possible to get a simple listing of all cPanel user accounts owned by a cPanel reseller.
grep resellerUserName /etc/trueuserowners | cut -d : -f 1
This should output a simple text list of cPanel accounts belonging to the given reseller, which you could them iterate through to do whatever you need.
Here’s an example of how this might work:
#!/bin/bash users=`grep resellerUserName /etc/trueuserowners | cut -d : -f 1` for user in $users; do # do something here echo $user done
And if you wanted to accept input (so that your script can be re-used without editing), you can do it like this…
#!/bin/bash reseller=$1 users=`grep $reseller /etc/trueuserowners | cut -d : -f 1` for user in $users; do # do something here echo $user done
Now all you need to do is call your script like this:
sh getusersbyreseller.sh resellerUserName