Skip to main content

Hook to add addon domain.

Comments

5 comments

  • sparek-3
    I'm actually interested in this too. Haven't been able to get it to work, but I'm really new to scripting hooks, so I blew it off as not knowing enough. It doesn't appear that anything is passed to the script in $argv when the script is run. At least that's what I found. I added the code: [PHP]ob_start(); print_r($argv); $message = ob_get_contents(); ob_end_clean(); mail("email@address.com","Addon Hook", $message);[/PHP] at the top of the hook script, and I don't get the expected results.
    0
  • Augusto Will
    yeah, i put an file_put_contents('/hookcont.txt', $contents); in the script, no results. :) sparek-3, try this:
    function get_passed_data() { $raw_data; $stdin_fh = fopen('php://stdin', 'r'); if ( is_resource($stdin_fh) ) { stream_set_blocking($stdin_fh, 0); while ( ($line = fgets( $stdin_fh, 1024 )) !== false ) { $raw_data .= trim($line); } fclose($stdin_fh); } if ($raw_data) { $input_data = json_decode($raw_data, true); } else { $input_data = array('context'=>array(),'data'=>array(), 'hook'=>array()); } return $input_data; } $input = get_passed_data(); $contents = var_export($input, true); file_put_contents('/hookcont.txt', $contents); mail("email@address.com","Addon Hook", $contents);
    0
  • sparek-3
    Wow! Thanks! That was immensely helpful. Actually solved my problem. Never occurred to me that the script was being treated as a pipe. I guess that's in the documentation some where. Thanks for giving me the heads up on that. My use was for a pre hook instead of a post hook. I don't guess that really helps you though. Have you tried setting the debughooks variable in /var/cpanel/cpanel.config and tailing the /usr/local/cpanel/logs/error_log while creating an addon domain? There is information on this at:
    0
  • cPanelMichael
    ]I need some help with API2 here.... The API2 only execute the hook if the event is triggered by scripts using the API or even a user using cPanel trigger the API2 events in the same way? Thank you.

    Hello :) Yes, the hookable events should apply to actions performed in the cPanel/WHM UI as well as the command line. Feel free to open a support ticket if this is not functioning as expected so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome. Thank you.
    0

Please sign in to leave a comment.