Skip to main content

Run Script on Subdomain Creation via cPanel

Comments

5 comments

  • cPanelMichael
    I'd like to hook into the subdomain creation process (when done via cPanel) to run a bash (or perl) script. I successfully added one by creating a WHM module for account creation, but it seems like cPanel hooks don't work the same way.

    Hello :) Please let us know if this thread is helpful: Hook to add addon domain. It's for addon domain names, but you could apply it to subdomains as well. Thank you.
    0
  • Joe P
    That definitely sent me down the right path and got it registered. It runs, but using the exact script here (Guide to Standardized Hooks - Hook Action Code - Software Development Kit - cPanel Documentation) along with some printing in do_something to figure out how data is being passed, but I'm getting nothing for $json:
    my $json = JSON::Syck::Dump($input); my $filename = '/home/test.txt'; open(my $fh, '>', $filename); print $fh "My json: $json"; close $fh;
    $input is supposed to have the data from get_passed_data() which is supposed to return JSON...but I get nothing. (Note - the file IS being created and its contents are: My json: null
    0
  • cPanelMichael
    Have you enabled debug mode? It's documented at: Guide to Standardized Hooks - Debug Mode - Software Development Kit - cPanel Documentation It will print debug data into the /usr/local/cpanel/logs/error_log file. Thank you.
    0
  • Joe P
    Debug saved me. Thanks! I got it all working after much trial, error, and printing to the log.
    0
  • cPanelMichael
    I am happy to see you were able to address the issue. Thank you for updating us with the outcome.
    0

Please sign in to leave a comment.