Skip to main content

WHM hooks for WHM events

Comments

3 comments

  • cPanelMichael
    I put the hooks in debug mode and confirmed that no hook is called in any such events.

    Hello, You can add a hook after WHM API 1 functions using a command such as:
    /usr/local/cpanel/bin/manage_hooks add script /var/cpanel/myapp/myscript.pl --manual --category Whostmgr --event setsiteip --stage post
    Information on WHM API 1 functions such as "setsiteip" are available at: Guide to WHM API 1 - Software Development Kit - cPanel Documentation Thank you.
    0
  • Anoop P Alias
    I tested this and its not working . Moreover your documentation at Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation doesnt mention the usage as described above. The hooks does get added ; but its not executing for setsiteip or installssl events.
    0
  • cPanelMichael
    Hello, Upon further review, the ability to hook into any WHM API 1 function is not currently possible, as is the case for cPanel API functions. Per our documentation: The Standardized Hooks system uses the following categories for hookable events: Cpanel " The Cpanel category creates hookable events for cPanel API 1, cPanel API 2, or UAPI functions. PkgAcct " The PkgAcct category's events occur during backup creation. Passwd " The Passwd category's events occur when a WHM user changes a cPanel user's password. Stats " The Stats category's events occur during statistics processing. System " The System category's events occur during system updates or backups. Whostmgr " The Whostmgr category's events occur during WHM functions.
    We have an internal case open (HB-1394) to explore the possibility of such as feature, but the current available hooks for Web Host Manager functions are listed at: Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation Thus, you can see the step listed in my previous response will work for the listed functions. In this example, it touches a file after suspending an account:
    # cat /var/cpanel/myapp/myscript.pl #!/bin/bash touch /root/12345678 # /usr/local/cpanel/bin/manage_hooks add script /var/cpanel/myapp/myscript.pl --manual --category Whostmgr --event Accounts::suspendacct --stage post # ls /root/12345678 /bin/ls: cannot access /root/12345678: No such file or directory # /scripts/suspendacct cptest123 Changing Shell to /bin/false...Changing shell for cptest123. Shell changed. Done Locking Password...Locking password for user cptest123. passwd: Success Done 1Suspending mysql users Suspending websites... Suspending FTP accounts... Suspending outgoing email....Done cptest123's account has been suspended # ls /root/12345678 /root/12345678
    Feel free to open a feature request to add hook support for the specific actions you require via: Submit A Feature Request For instance, here's an example of a similar feature request we implemented: Rearrange an Account hook Thank you.
    0

Please sign in to leave a comment.