What file contains a list of usernames and the main account domain?
So another thread led me to /etc/domainusers, which is *almost* exactly what I need, except that it contains all the domains in use for each user.
What I need is something I can grep from bash that will return a username *once* with its corresponding main domain.
Or is there a way to query cPanel's setup somehow to return this from bash?
Basically, if you have the username as $user and do
, you get something like
- which is perfect, except you get multiple domains if they have addon domains. I need something that will allow me to only get the primary domain associated with an account. Any ideas? :)
grep ': $user' /etc/userdomains
, you get something like
example.com: username
- which is perfect, except you get multiple domains if they have addon domains. I need something that will allow me to only get the primary domain associated with an account. Any ideas? :)
-
cat /var/cpanel/users/%user% | grep ^DNS= | sed s/^DNS=//g 0 -
You are magic. Thank you so so very much. :) 0 -
Any ideas?
There is much simpler way than using a complex sed and grep combination when there is already a file that has the data that you are looking for. /etc/userdomains contains list of all Addon and Subdomain. If you want just get a list of main account and its user, use trueuserdomains. # cat /etc/trueuserdomains This is the file that contains a list of the main domain and their respective usernames..0 -
Just to follow up with a few examples: # whmapi1 listaccts search='^cptest$' searchtype=user|grep -oP '(?<=domain: ).+' cptest.tld # grep -oP "[^:]+(?=: cptest$)" /etc/trueuserdomains cptest.tld
0
Please sign in to leave a comment.
Comments
4 comments