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.

Does this require using the whm API?

Discussion in 'General Discussion' started by meeven, Feb 4, 2008.

  1. meeven

    meeven Well-Known Member

    Joined:
    May 8, 2007
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    16
    I am getting someone to write a script that automatically installs a cms on a domain. That part is complete and the script is now being extended to install on a sub-domain (http://subdomain.example.com).

    I don't want to first manually create the subdomain (and thus its DNS zone file etc) and then run the script. Instead, I want the script to automatically handle the DNS zone file creation for the sub-domain, much like what cPanel does when you add a subdomain.

    Now, does this mean that the script will have to implement some kind of whm/cPanel API functions? If so, how/where can I access this API? I have a VPS, so I presume that I would have access to this kind of API?

    Thanks,
    Meeven
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I would recommend using a cPanel API as it will ensure things are set up properly and automatically (DNS etc.). There is an API1 function that is used to create subdomains. If you look at the code in the X3 theme for adding a subdomain (/usr/local/cpanel/base/frontend/x3/subdomain/index.html and doadddomain.html) you will get a good understanding of how this function works.

    You can call the API1 function from the XML API. Documentation on how to do that is available at:

    http://cpanel.net/plugins/devel

    Note, you would need the script to authenticate into the XML-API as a reseller that owns that account or as the root user (preferably via the hash/remote access key) for the script to have sufficient privileges to do this. There are details on how to do this in the XML-API documentation (it's not a chown/su type of thing).
     
  3. meeven

    meeven Well-Known Member

    Joined:
    May 8, 2007
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    16
    Thank you, cPanelDavidG for the detailed response. Very much appreciated.:)

    Just to confirm- the way the script will work is to create the sub-domain automatically, along with its DNS zone file. After development is done, the script will move the site to the main domain. At this point, it will automatically delete the DNS zone file.

    Sorry if this is a dumb question, but I suppose the API will allow both?
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Yes. The main thing to keep in mind is our design team built the X3 theme on top of API1 and API2. As a result, pretty much anything you can do in X3 is accessible via the API. In the meantime until comprehensive API documentation is published, I'd recommend looking at the code within the files that make up the X3 theme to learn about API1 and API2 functionality.
     
  5. meeven

    meeven Well-Known Member

    Joined:
    May 8, 2007
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    16
    Thank you.

    I got the following response from the developer
    I would appreciate it very much if you could help explain how do automatic subdomain creation in WHM as well. Or, have I missed your previous explanations about this?

    Thanks in advance.
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You would use the XML-API to call the API1/APi2 function that creates subdomains.
     
Loading...

Share This Page