cPanel event not triggering the execution of my script. Am I doing it wrong?

stards

Member
Jan 11, 2014
8
1
53
cPanel Access Level
Root Administrator
Hi,

I'm using the manage_hooks script to hook into some MySQL related events like Mysql::create_user and Mysql::delete_user among others. Here's the one-liner I'm running:


Code:
/usr/local/cpanel/bin/manage_hooks add script /home/scripts/syncup.sh --category Cpanel --event 'Mysql::create_user' --stage post --manual 1
The run confirms the hook has been registered:

Code:
Added hook for Cpanel::Mysql::create_user to hooks registry
Unfortunately these events are not triggering my script (script syncup.sh is executable with the executable bit set for the directories as well). Is this the right way to hook into these events and trigger a script run?

Thank you
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
97
49
93
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Hi @stards ,

For Cpanel events, you have to specify the API system in addition to the module/function, API::Module::function. For your case, this would be UAPI::Mysql::create_user.

Additionally, you can turn on Standardized Hooks - Debug Mode in WHM >> Tweak Settings, then call the API using the CLI commands. As part of the return, if a hook is registered to the API event, it will list pre- and post- conditions with any hooks registered for it.
 
  • Like
Reactions: stards

stards

Member
Jan 11, 2014
8
1
53
cPanel Access Level
Root Administrator
Hi @stards ,

For Cpanel events, you have to specify the API system in addition to the module/function, API::Module::function. For your case, this would be UAPI::Mysql::create_user.

Additionally, you can turn on Standardized Hooks - Debug Mode in WHM >> Tweak Settings, then call the API using the CLI commands. As part of the return, if a hook is registered to the API event, it will list pre- and post- conditions with any hooks registered for it.
Very helpful! Thanks TJ.
 
  • Like
Reactions: cPanelTJ