About Eenos Hooks

Understand how Hooks works in the Eenos control panel. Create your own Hooks

Introduction

Getting started with hooks in Eenos

The  Eenos control panel supports hooks, which will help you to integrate any custom scripts or code blocks in the middle of Eenos operations. 

Eenos supports two types 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 hook 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.

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 supports any programming language or binary. The only requirement is that you need to provide execute permission for the hook scripts. We recommend using 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 hook script names are in a sorted order.  ( eg : 00-pre.py , 01-pre.py, 02-pre.py )