cPanel/WHM Hooks
Warning: The information below is deprecated. Please see
our updated script hooks documentation.
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.
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 Apache 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/legacypostwwwacct — Older version of
/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> <killdns> - Runs after account termination (
/scripts/killacct). HASH: make sure to parse as a hash because killdns or user could change order.
- /scripts/legacypostkillacct <user> <killdns> — 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. Example:
user
- domain (string) — Domain name. Example:
domain.tld
- plan (string) — Package to use for account creation. Example:
reseller_gold
- quota (integer) — Disk space quota in MB.
- Possible values: 0-999999.
-
0 is unlimited.
- pass (string) — Password to access cPanel. Example:
p@ss!w0rd$123
- useip (string) — Whether or not the domain has a dedicated IP address.
- hascgi (string) — Whether or not the domain has cgi access.
- installfp (string) — Whether or not the domain has FrontPage extensions installed.
- hasshell (string) — Whether or not the domain has shell/SSH access.
- contactemail (string) — Contact email address for the account. Example:
user@otherdomain.tld
- cpmod (string) — cPanel theme name. Example:
x3
- maxftp (string) — Maximum number of FTP accounts the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxsql (string) — Maximum number of SQL databases the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxpop (string) — Maximum number of email accounts the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxlst (string) — Maximum number of mailing lists the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxsub (string) — Maximum number of subdomains the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxpark (string) — Maximum number of parked domains the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- maxaddon (string) — Maximum number of addon domains the user can create.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- bwlimit (string) — Bandiwdth limit in MB.
- Possible values: 0-999999,
unlimited, and null
-
0 is unlimited.
- useregns (boolean) — Whether to use the registered nameservers for the domain instead of the ones configured on the server.
- 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 a 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) — Username of the account. Example:
user
Accessing the Username with PHP
$user = $argv[1];
Accessing the Username with Perl
my $user = $ARGV[0];<a name="item_username"></a>
/scripts/postkillacct
This script runs after an account is terminated.
It is called with its parameters in a hash:
/scripts/postkillacct %OPTS
-
OPTS{'user'} — Username of the terminated account.
-
OPTS{'killdns'} — Whether the zone files were deleted during account termination. This is a boolean variable and will either be 1 (yes) or 0 (no).
/scripts/legacypostkillacct
This script runs after an account is terminated. This is an older version of
/scripts/postkillacct.
This script can access 2 parameters:
- user (string) — Username of the account. Example:
user
- killdns (boolean) — Whether the DNS zone files were deleted during account termination.