Skip to main content

Add note/description for hook

Comments

3 comments

  • cPanelMichael
    Hello, I don't see a way to add notes/descriptions using the manage_hooks utility from the command line, however you can manually add notes to the /var/cpanel/hooks.yaml file. Here's an example of how the entry you provided would look if you were to manually add a "notes" entry to this YAML file:
    System: Backup: - check: /root/myscript escalateprivs: 1 exectype: script hook: /root/myscript id: sH22fqxJUJT1hjSwJP3VxwtF notes: 12345 stage: post weight: 100
    Thank you.
    0
  • Havri
    Hello Michael, I thought of editing /var/cpanel/hooks.yaml, but I saw what the documentation said: "Do not edit this file by hand. Instead, manage Standardized Hooks with the /usr/local/cpanel/bin/manage_hooks utility." I've found another way by using the WHM List Hooks API, then access it using the jq command and then editing the hook with the WHM Edit Hook API. It's clean and it works. It looks something like this:
    whmapi1 list_hooks --output=jsonpretty | jq -r '.data.categories[].events[].stages[].actions[]|select(.hook | contains ("/root/myscript -arg1")).id' | xargs -I{} whmapi1 edit_hook id={} enabled=1 notes="The comment that I want to add"
    What needs to be changed in the above command: 1. The script location ( the part with /root/myscript -arg1 should be changed to match the path to your hooked script - like /root/foo/bar/or/whatever.sh) 2. The actual added note (the part with The comment that I want to add should be changed to whatever note you want to be added) All the documentation can be found in the following links: Hope this helps someone. Regards.
    0
  • cPanelMichael
    Hello, Awesome work! Thank you for taking the time to share the solution.
    0

Please sign in to leave a comment.