MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
I simply need to be able to run a command when a dns zone is deleted. Pretty basic. Any suggestions on how I can make this happen?
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
6,762
535
263
Houston
cPanel Access Level
DataCenter Provider

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
6,762
535
263
Houston
cPanel Access Level
DataCenter Provider
The full guide goes more in depth Guide to Standardized Hooks - Developer Documentation - cPanel Documentation

But ultimately you can write a standardized hook to run when a "hookable event" has occurred.

All hookable events are comprised of three main attributes:

  1. category — The event's logical grouping within cPanel & WHM.
  2. event — The event that cPanel & WHM performs.
  3. stage — The location of the trigger that runs the hook action code, relative to the event.
What command are you wanting to run when a DNS zone is removed?
 

MACscr

Well-Known Member
Sep 30, 2003
198
5
168
cPanel Access Level
Root Administrator
The full guide goes more in depth Guide to Standardized Hooks - Developer Documentation - cPanel Documentation

But ultimately you can write a standardized hook to run when a "hookable event" has occurred.

All hookable events are comprised of three main attributes:

  1. category — The event's logical grouping within cPanel & WHM.
  2. event — The event that cPanel & WHM performs.
  3. stage — The location of the trigger that runs the hook action code, relative to the event.
What command are you wanting to run when a DNS zone is removed?
I am just wanting to run a curl command when a zone is deleted so i can delete the zone on the slave. Zones are created/updated with AFXR, which obviously doesn't handle deletions. Maybe hooks isn't the right way to go? Whatever is the simplest to setup.
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,749
2,205
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @MACscr :)

1. The quickest way to see if an event is hookable is to enable the following setting for the Standardized Hooks - Debug Mode option under the Development tab in WHM >> Tweak Settings:

Debug mode is on. The system displays information about every stage for every hookable event, even if no hooks exist for that stage.

Once this is enabled, perform the action you want to hook into using either cPanel or Web Host Manager, and then monitor the /usr/local/cpanel/logs/error_log output to identify the hook action. The following tutorial includes some helpful information:


2. Hooks do not exist for all events, and DNS zone deletion is one example of an event without a corresponding hook. I recommend voting for and adding a comment to the following feature request if you'd like to see a hook for DNS zone management (add/edit/delete):


3. One alternative to explore is the use of a custom dnsadmin plugin. We document more information along with an example on the link below:


Let me know if this helps.

Thanks!