The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

List ALL domains - an easy way ?

Discussion in 'General Discussion' started by 4u123, Jan 24, 2008.

  1. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    For the purpose of writing a script to do some maintenance stuff, I needed an accurate list of all domains currently being hosted on a particular server. By that I mean primary, parked and addon domains.

    In WHM you can generate a CSV file which lists all the primary hosted domains - but it seems the only way of getting the rest of them is to click "list parked domains" and "list sub domains" and copy paste each one of them out individually - which is very time consuming.

    I've looked at the "localdomains" file. This doesnt appear accurate. Neither do "userdomains" or "trueuserdomains". Porbably because these files contian sub-domains which I'm not interested in.

    Isnt there an easy way to get an accurate list of what domains are on the server ?
     
    #1 4u123, Jan 24, 2008
    Last edited: Jan 24, 2008
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    The complete list can be compiled from the various 'databases' cPanel maintains. For example, each file in /var/cpanel/users contains each domain owned by an account. The format is DNS#=example.com with the caveat that the primary domain for the account is formated as DNS=example.com

    If you need to make a distinction among the various kinds of domains (sub, addon, parked, etc), then /var/cpanel/userdata/user/main contains that. This file is in YAML format. If your scripting language has a YAML interface, it would be relatively trivial to handle those files.
     
  3. 4u123

    4u123 Well-Known Member
    PartnerNOC

    Joined:
    Jan 2, 2006
    Messages:
    765
    Likes Received:
    1
    Trophy Points:
    18
    Thanks Ken,

    I was hoping we wouldnt need to write a seperate script just to obtain a list of domains from the server. Would it be just as accurate to use "localdomains" and remove the sub-domain entries?

    There are many reasons why you might want to get a full list of all the domains running from a server and I think you guys should look into adding some reporting options to WHM.
     
  4. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Possibly a combination of localdomains and remotedomains. These two files are used by Exim to determine whether the mail is hosted locally or not.

    The reason I suggested /var/cpanel/userdata is because you mentioned you were writing a script. The YAML format in the /var/cpanel/userdata/user/main file is excellent for use in a script. Of course, it depends upon your scripting language. For sh, it probably offers little benefit.
     
  5. dwinans

    dwinans Member
    PartnerNOC

    Joined:
    Jan 23, 2009
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    I've found the easiest way to get a listing of all domains under an account is by grep'ing the username out of /etc/userdomains

    I'm surprised that cpanel doesn't have this function built in.
     
Loading...

Share This Page