Introduction
Getting started with hooks in Eenos
The Eenos control panel support hooks, which will help you to integrate any custom scripts or code block in the middle of Eenos operations.
Eenos support two type of hooks Pre Hooks and Post Hooks.
Pre Hooks
The pre hooks will be executed before the operation of a specific function. You should place the hook script in the following folder.
Location : /var/eenos/hooks/FUNCTION_NAME/pre/ , where FUNCTION_NAME is the action function
Example :
Example for a dns creation pre hook : /var/eenos/hooks/dns/pre/01-dns_sync.py
Post Hooks
The post hooks will be executed after the operation of a specific function . You should place the hook script in the following folder.
Location : /var/eenos/hooks/FUNCTION_NAME/post/ , where FUNCTION_NAME is the action function
Example :
Example for a dns creation post hook : /var/eenos/hooks/dns/post/01-dns_sync.py
All hooks scripts must need execute permission to run the program .
Hook Inputs
The Eenos system calls will send the following command line inputs to the hook scripts.
- data : A base64 encoded JSON data of the related actions , This is compulsory.
- action : The action code CREATE , UPDATE or DELETE , This is compulsory
- panel : The control panel that perform the hooks , wap. rapp or uapp , This is compulsory
- domain : The domain name performing the hooks. It is optional
- user : The Eenos user name associated with . It is optional
An example hook action will be look like as follows :
/var/eenos/hooks/dns/pre/01-test.py \
data=eyJ0ZXN0IjoidGVzdCIsImhpIjoiaGVsbG8ifQ== \
action=CREATE \
panel=wap \
domain=fun.com \
user=foo
You may decode the data and process it.
Hook Programming Languages
The Eenos hook support any programming language or binary. The only requirement is that your need to provide execute permission for the hook scripts. We recommend to use Python scripts for creating hooks.
Hooks Script Ordering
The Eenos will sort the hook scripts based on the name . So if you like to execute multiple hooks , please make sure the the hook scripts name in a sorted order. ( eg : 00-pre.py , 01-pre.py, 02-pre.py )