Skip to content

Instantly share code, notes, and snippets.

@dhaupin
Created April 28, 2017 15:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dhaupin/20161fc0002f2f9d37706db9dd179051 to your computer and use it in GitHub Desktop.
Save dhaupin/20161fc0002f2f9d37706db9dd179051 to your computer and use it in GitHub Desktop.
Example - WHM/cPanel Update Hooks
# https://documentation.cpanel.net/display/SDK/Guide+to+Standardized+Hooks+-+The+manage_hooks+Utility
# To add a script to upcp schema (as a hook)
/usr/local/cpanel/bin/manage_hooks add script /root/src/cpanel-hooks/postupcp.sh --manual --category System --event upcp --stage post
# To remove a script as hook from upcp schema
/usr/local/cpanel/bin/manage_hooks delete script /root/src/cpanel-hooks/postupcp.sh --manual --category System --event upcp --stage post
# To list current hooks (
/usr/local/cpanel/bin/manage_hooks list
# Perl modules can be used too
/var/cpanel/perl/scripts/someApp/someScript.pm
# Can be used in manage_hooks binary as method syntax
/usr/local/cpanel/bin/manage_hooks <action> module someApp::someScript <flags>
# Or php scripts
/var/cpanel/someApp/someScript.php
# Can be used in manage_hooks binary as script syntax
/usr/local/cpanel/bin/manage_hooks <action> script /var/cpanel/someApp/someScript.php <flags>
# https://documentation.cpanel.net/display/SDK/Guide+to+Standardized+Hooks+-+The+describe%28%29+Method
# <flags> can be included in the script or module using the describe() method
function describe() {
$init_add = $init_remove = array(
'category' => 'System',
'event' => 'upcp',
'stage' => 'post',
'hook' => '/var/cpanel/someApp/someScript.php',
'exectype' => 'script',
);
return array($init_add, $init_remove);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment