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.

Hooks not executed

Discussion in 'cPanel Developers' started by mgastkemper, Apr 28, 2014.

  1. mgastkemper

    mgastkemper Member

    Joined:
    Oct 5, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Utrecht, Netherlands
    cPanel Access Level:
    Root Administrator
    I'm using hooks to install and configure my apps in cPanel account. It worked great, but the hooks aren't working on 11.42 build 12 anymore. I'm not sure from which version it's broken.

    /root/cpanel-deploy/mysqlAddDBHook contains some code to write credentials to a config file. For testing purposes I added the following:
    Code:
    #!/bin/bash
    echo "test"
    read input
    echo $input
    I add the hooks with this command:
    Code:
    manage_hooks add script /root/cpanel-deploy/mysqlAddDBHook --event=Api1::Mysql::adddb --stage=post --category=Cpanel --manual --escalateprivs
    I set the debughooks property to 2 and the following output appears in /usr/local/cpanel/logs/error_log:

    Code:
    [2014-04-28 17:37:43 +0200] info [cpmysql] Creating MySQL database f20_test24 for user f20
    [2014-04-28 17:37:43 +0200] info [cpanel] ---debug_hooks---
    [2014-04-28 17:37:43 +0200] info [cpanel]             msg: Beginning execution of script hook.
    [2014-04-28 17:37:43 +0200] info [cpanel]         context: Cpanel::Api1::Mysql::adddb
    [2014-04-28 17:37:43 +0200] info [cpanel]           stage: post
    [2014-04-28 17:37:43 +0200] info [cpanel]           point: main
    [2014-04-28 17:37:43 +0200] info [cpanel]              id: rLiWmcxBdMvkV11vEpLftFU8
    [2014-04-28 17:37:43 +0200] info [cpanel]            hook: /root/cpanel-deploy/mysqlAddDBHook
    [2014-04-28 17:37:43 +0200] info [cpanel]   escalateprivs: 1
    [2014-04-28 17:37:43 +0200] info [cpanel]          weight: 200
    [2014-04-28 17:37:43 +0200] info [cpanel]            data: {"user":"f20","output":[],"args":["test24"]}
    [2014-04-28 17:37:43 +0200] info [cpanel] ---debug_hooks---
    [2014-04-28 17:37:43 +0200] info [cpanel]             msg: Finished execution of script hook.
    [2014-04-28 17:37:43 +0200] info [cpanel]         context: Cpanel::Api1::Mysql::adddb
    [2014-04-28 17:37:43 +0200] info [cpanel]           stage: post
    [2014-04-28 17:37:43 +0200] info [cpanel]          result: 0
    [2014-04-28 17:37:43 +0200] info [cpanel]           point: main
    [2014-04-28 17:37:43 +0200] info [cpanel]              id: rLiWmcxBdMvkV11vEpLftFU8
    [2014-04-28 17:37:43 +0200] info [cpanel]            hook: /root/cpanel-deploy/mysqlAddDBHook
    [2014-04-28 17:37:43 +0200] info [cpanel]   escalateprivs: 1
    [2014-04-28 17:37:43 +0200] info [cpanel]          weight: 200
    [2014-04-28 17:37:43 +0200] info [cpanel]            data: {"user":"f20","output":[],"args":["test24"]}
    As you can see in error_log there's no output between Beginning and Finished. Even when I put some random characters in my script it won't show an error. Normally I get the something like this: "HOOK INFO: hook mysqlAddDBHook did not output any data"

    Does somebody have a solution for my problem?

    Kind regards Martijn
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. mgastkemper

    mgastkemper Member

    Joined:
    Oct 5, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Utrecht, Netherlands
    cPanel Access Level:
    Root Administrator
    I reported a bug with ID 4881345

    I discovered that this problem only occurs with cPanel hooks not with WHM hooks.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    648
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. mgastkemper

    mgastkemper Member

    Joined:
    Oct 5, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Utrecht, Netherlands
    cPanel Access Level:
    Root Administrator
    The problem was resolved by setting the right permissions. root and cpanel-deploy must have execute permissions for everybody. Escalate privileges doesn't matter.
    Setting these permissions on /root isn't correct so I have to move the scripts to a folders which is usable by all users.
     
Loading...

Share This Page