cPanel/WHM Hooks
While modifying cPanel and WHM source code is prohibited by our EULA, there are many hooks in cPanel and WHM to support custom configurations.
Hooks
Post Installer Hooks
These post installer hooks are not present by default and must be created and able to be executed. Code within these hooks should be written in Perl unless otherwise documented below.
- /scripts/postupcp - Runs after cPanel/WHM updates (/scripts/upcp)
- /scripts/postcourierinstall - Runs after Courier updates (/scripts/courierup)
- /scripts/postcourier-authlibup - Runs after courier-authlib package updates
- /scripts/postcourier-imapup - runs after courier-imap package updates
- /scripts/posteasyapache - Runs after Aapche is rebuilt (/scripts/easyapache)
- /scripts/postexim4install - Runs after Exim updates (/scripts/eximup)
- /scripts/postftpinstall - Runs after FTP server updates (/scripts/ftpup)
- /scripts/postmysqlinstall - Runs after MySQL updates (/scripts/mysqlup)
- /scripts/postwwwacct - Runs after account creation (/scripts/wwwacct)
- /scripts/postwwwacctuser - Runs after user creation
- /scripts/postsuspendacct <user> <reason> - Runs after an account is suspended (/scripts/suspendacct)
- /scripts/postunsuspendacct <user> - Runs after an account is unsuspended (/scripts/unsuspendacct)
- /scripts/post${pkg}install - Runs within /scripts/bandminup or /scripts/courierup, specify a package name to be run after.
- /scripts/postcpbackup - Runs after cpbackup (/scripts/cpbackup)
- /scripts/postbuildapache - Runs after apache rebuild (/scripts/easyapache)
- /scripts/postkillacct <user> <keepdns> - Runs after account termination (/scripts/killacct) HASH (make sure to parse as a hash because keepdns or user could change order)
- /scripts/legacypostkillacct <user> <keepdns> - Runs after account termination (/scripts/killacct)
/scripts/postwwwacct
This script will be run after an account is created. Within this script, data from /scripts/wwwacct can be accessed so that it can be passed to something such as a billing solution, custom application, or script.
The following data can be accessed:
- user (string)
-
User name of the account. Ex: user
- domain (string)
-
Domain name. Ex: domain.tld
- plan (string)
-
Package to use for account creation. Ex: reseller_gold
- quota (integer)
-
Disk space quota in MB. (0-999999, 0 is unlimited)
- pass (string)
-
Password to access cPanel. Ex: p@ss!w0rd$123
- useip (string)
-
Whether or not the domain has a dedicated IP address. (y = Yes, n = No)
- hascgi (string)
-
Whether or not the domain has cgi access. (y = Yes, n = No)
- installfp (string)
-
Whether or not the domain has FrontPage extensions installed. (y = Yes, n = No)
- hasshell (string)
-
Whether or not the domain has shell / ssh access. (y = Yes, n = No)
- contactemail (string)
-
Contact email address for the account. Ex: user@otherdomain.tld
- cpmod (string)
-
cPanel theme name. Ex: x3
- maxftp (string)
-
Maximum number of FTP accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxsql (string)
-
Maximum number of SQL databases the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxpop (string)
-
Maximum number of email accounts the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxlst (string)
-
Maximum number of mailing lists the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxsub (string)
-
Maximum number of subdomains the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxpark (string)
-
Maximum number of parked domains the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- maxaddon (string)
-
Maximum number of addon domains the user can create. (0-999999 | unlimited, null | 0 is unlimited)
- bwlimit (string)
-
Bandiwdth limit in MB. (0-999999, 0 is unlimited)
- useregns (boolean)
-
Use the registered nameservers for the domain instead of the ones configured on the server. (1 = Yes, 0 = No)
- owner (string)
-
Owner of the account.
(send arguments in a hash) --- This is the new and PREFERRED way as there will be a lot more data passed in the future and this is much better way to handle it.
Example:
'plan' => 'undefined',
'maxpark' => '0',
'hasshell' => 'y',
'maxlst' => 'n',
'maxpop' => 'n',
'maxaddon' => '0',
'cpmod' => 'x',
'pass' => 'fdfd',
'maxsub' => 'n',
'domain' => 'dummy.org',
'maxsql' => 'n',
'quota' => '0',
'installfp' => 'y',
'maxftp' => 'n',
'contactemail' => '',
'hascgi' => 'y',
'user' => 'dummyor',
'useip' => 'n',
'useregns' => '0',
'bwlimit' => '0',
'forcedns' => '0',
'owner' => 'root',
'featurelist' => 'default'
Accessing the data in PHP:
‹?php
$opts = array();
$argv0 = array_shift($argv);
while(count($argv)) {
$key = array_shift($argv);
$value = array_shift($argv);
$opts[$key] = $value;
}
?>
?›
Then you can access
$opts['user'], $opts['domain'], $opts['quota], etc
Accessing the data in Perl:
perl: my %OPTS = @ARGV;
access via $OPTS{'user'}, $OPTS{'domain'} etc
/scripts/legacypostwwwacct
(sends arguments as an array):
Example:
'dummy.org',
'dummyor',
'fdfd',
'0',
'x',
'n',
'y',
'y',
'n',
'n',
'n',
'n',
'n',
'0',
'y',
'root',
'undefined',
'0',
'0',
'default',
'',
'0',
'0'>
Accessing the data in PHP:
‹?php
access via $argv[1] (domain), $argv[2] (user) etc
?›
Accessing the data in Perl:
my @OPTS = @ARGV;
access via $OPTS[0] (domain) , $OPTS[1] (user)
Here is how its run from whm/wwwacct:
'/scripts/legacypostwwwacct', $OPTS{'domain'}, $OPTS{'user'}, $OPTS{'pass'},
$OPTS{'quota'}, $OPTS{'cpmod'}, $OPTS{'useip'}, $OPTS{'hascgi'}, $OPTS{'installfp'},
$OPTS{'maxftp'}, $OPTS{'maxsql'}, $OPTS{'maxpop'}, $OPTS{'maxlst'}, $OPTS{'maxsub'},
$OPTS{'bwlimit'}, $OPTS{'hasshell'}, $OPTS{'owner'}, $OPTS{'plan'}, $OPTS{'maxpark'},
$OPTS{'maxaddon'}, $OPTS{'featurelist'}, $OPTS{'contactemail'}, $OPTS{'forcedns'},
$OPTS{'useregns'}
/scripts/postwwwacctuser
This script runs after user creation if it is present and executable.
Here, you can access the new user's name:
- user (string)
-
User name of the account. Ex: user
Accessing the username in PHP:
Accessing the username in Perl:
cPanel Web Site Feedback Form