The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WHM hooks for WHM events

Discussion in 'cPanel Developers' started by Anoop P Alias, May 7, 2016.

  1. Anoop P Alias

    Anoop P Alias Member

    Joined:
    Mar 31, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Kochi,Kerala,India
    cPanel Access Level:
    Root Administrator
    Hi,

    I am a plugin developer that is integrating the nginx server into the cPanel webstack.

    For the proper working of the plugin ;I will need hooks from the following WHM functions
    ##

    Home »IP Functions »Change a Site’s IP Address
    Home »Multi Account Functions »Change Multiple Sites’ IP Addresses
    Home »SSL/TLS »Manage SSL Hosts
    Home »SSL/TLS »Install an SSL Certificate on a Domain

    ##

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


    It would be great if cPanel take an effort and support these functions too in

    Guide to Standardized Hooks - Whostmgr Functions - Software Development Kit - cPanel Documentation
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,694
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You can add a hook after WHM API 1 functions using a command such as:

    Code:
    /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.
     
  3. Anoop P Alias

    Anoop P Alias Member

    Joined:
    Mar 31, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Kochi,Kerala,India
    cPanel Access Level:
    Root Administrator
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,694
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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:

    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:

    Code:
    # 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.
     
Loading...

Share This Page