19 mar 2021

Hook Action Code

Wilmer Barrios | viernes, marzo 19, 2021 |
Creating Hook Action Code

You can create hook action code in a custom Perl module or as an executable script. Using hook action code can customize cPanel & WHM functions to change the end-user experience. For example, you can create a hook action Perl module to install WordPress each time a user creates an account.

Hook action code must read the entire input stream until end of line (EOL) and it must treat it as a JSON-encoded data structure. After the system decodes the JSON string, the native data structure is a hash.
Scripts may use any language that the Linux shell can execute.

Hook action code files and subroutine names are arbitrary. So yes, you could include the word "bathtub" in your filename and "oranges" in a subroutine name. However, keep in mind, the system references these names later when you register your code. It is more suggested to name your files and subroutines in relation to what your code is doing.

Make certain that you save hook action code in the correct location on the cPanel & WHM server:

Install hook action code modules to your Perl environment's correct directory.
Save hook action scripts in the /usr/local/cpanel/3rdparty/bin directory. Scripts must have root:root ownership and 755 permissions.

Hook scripts execute as a separate process. Hook modules run as part of the cPanel Server daemon (cpsrvd).

Hook action code in a custom Perl module can access cPanel environment variables. For steps to create a hook action code Perl module, read our Create a Standardized Hook tutorial.
Hook action code as a script cannot access cPanel environment variables.
For more information about cPanel environment variables, read our Guide to cPanel Variables documentation.

Important:
Scripts must include argument evaluation in the hook action code in order to use the describe() method. When you register hooks with script hook action code, the /usr/local/cpanel/bin/manage_hooks utility calls the script with the --describe argument. 

Share this article
 
Copyright © 2021 MyBiosWeb
Distributed By My Themes | Template Design By BioHosting