Automating script installation

kepler

Member
Aug 20, 2017
7
1
3
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,883
2,256
463
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

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
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.
 

kepler

Member
Aug 20, 2017
7
1
3
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:[email protected]: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'] = '[email protected]';
$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