Skip to main content

Bash script example hook

Comments

5 comments

  • Anoop P Alias
    the hook give you a json ds in stdin .Bash wont be a good choice to parse json. You can use python ,which is similar to bash or go with php/perl . Basically any high level language with support for stuff like json,yaml etc be good enough .
    0
  • rahnev
    Can you give me a working example with perl for example for catching all input data and parse it?
    0
  • cPanelMichael
    Hello, You can find the corresponding API function for a hook by enabling "Debug mode is on. The system s information about every stage for every hookable event, even if no hooks exist for that stage." under the "Development" tab in "WHM >> Tweak Settings". Then, perform the specific action you want to hook into via cPanel or WHM, and watch the output in /usr/local/cpanel/logs/error_log. For example, the following cPanel API 1 function is utilized when adding an Alias in cPanel: Cpanel::Api1::Park::park You can find documentation on hooks with cPanel functions at: Guide to Standardized Hooks - Cpanel Functions - Software Development Kit - cPanel Documentation As far as checking for conditions before a hook is ran, an example is documented at: Guide to Standardized Hooks - Checks - Software Development Kit - cPanel Documentation Thank you.
    0
  • rahnev
    @cPanelMichael, Thanks for the info but I am searching for an example hook, written in bash script. I want to know how can I catch the input and I will find a way to parse it for my needs.
    0
  • Anoop P Alias
    Hi please find an example of a hook i wrote in python raw.githubusercontent.com/AnoopAlias/XtendWeb/ndeploy4/scripts/cpanel_functions_hook_post.py As mentioned before ..doing the same would be a bit tough in bash since bash does not support json. You may get some luck with text processing tools like sed or awk, but thats just a workaround and the easier way to do this would be using a high level language that support json. Perl,php,python,ruby etc would be easier here .
    0

Please sign in to leave a comment.