Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

Automating script installation

Discussion in 'cPanel Developers' started by kepler, Aug 20, 2017.

Tags:
  1. kepler

    kepler Registered

    Joined:
    Aug 20, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Porto
    cPanel Access Level:
    Root Administrator
    Good evening,

    I'm glad I joined the cPanel community :) So, here's my "little" problem:

    I own a VPS which has several parked domains in different dirs. One of these domains needs a script which installs automatically an application package when a new user is created in cPanel in his own space.

    So, the main script is installed in /usr/shared/app_name

    As far as I understood, I can make a postwwwacct script in cpanel /scripts dir which takes the arguments from cPanel when the account is created, and includes the install.php from the /usr/shared/app_name

    My problem is that the installation is only for one of the domains - not all... And the app_name symlinks the user dir (/home/username) to that user dir

    In the postwwwacct I think I can run the install - or not - if I detect the right domain.

    Is this the easy way of doing it?

    Also, I would like very much to know if - regarding the cPanel API - I can simply call it from any domain, and how to give an user the permissions to call a root dir, like /usr/shared/app_name for instance.

    Any sugestions - previous experiences - are welcomed :)

    Clear skies,

    Kepler
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can setup a post-stage hook that runs immediately after an account is created. You can read more about how hooks work at:

    Tutorial - Create a Standardized Hook - Software Development Kit - cPanel Documentation

    The particular event you would hook into is Accounts::Create:

    Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation

    Have you verified this works when you set it up manually? We typically recommend avoiding those types of symbolic links, and instead recommend creating individual directories for each account.

    Thank you.
     
  3. kepler

    kepler Registered

    Joined:
    Aug 20, 2017
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Porto
    cPanel Access Level:
    Root Administrator
    Good afternoon,

    I created allready a php which creates automatically an account in whm with a cpanel account. Now I'm trying to do the same, but regarding a particular app from Softaculous, without the user having to do it.

    I found this code:

    <?php

    @set_time_limit(100);

    $new = new Soft_Install();
    $new->login = 'https://user:root_password@domain.com:2083/frontend/paper_lantern/softaculous/index.live.php';
    $new->data['softdomain'] = 'domain.com'; // OPTIONAL - By Default the primary domain will be used
    $new->data['softdirectory'] = 'folder'; // OPTIONAL - By default it will be installed in the /public_html folder
    $new->data['admin_pass'] = 'qwerty'; //root password
    $new->data['admin_email'] = 'admin@domain.com';
    $res = $new->install(26); // Will install WordPress

    if($res == 'installed'){
    echo 'Installed';
    }else{
    echo $res; // A serialized array of error will be returned
    }

    But I have 3 questions:

    1) Does the script requires the include('/usr/local/cpanel/whostmgr/docroot/cgi/softaculous/sdk/installapi.php'); ?

    2) Will the app be installed automatically, or must the user/root login to cPanel?

    3) Is data['softdomain'] the 'username.domain.com', and the data['admin_pass'] the root password?

    Kind regards,

    Kepler
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page