Available Hooks
All the action hooks are available in Eenos. Keep watching this page, more hooks will come in the future as we are getting the feature request for action hooks.
dns
The DNS Hook
This hook will help to automate additional tasks with your DNS server.
You can integrate your Third-party DNS cluster into Eenos with the help of this hook function.
Function name: DNS
Base Directory: /var/eenos/hooks/dns
Pre-Hooks Location
Please place all your DNS pre-hook scrips in /var/eenos/hooks/dns/pre/
Post Hooks Location
Please put your post dns hooks scripts in /var/eenos/hooks/dns/post/
All pre-hook and post-hook scripts need execute permission to perform the requested operations.
Supported Actions
The dns hooks will support CREATE, UPDATE, and DELETE actions. These actions will be executed based on the hook operation.
CREATE
This action will be given if a dns zone is created in the server.
UPDATE
This action will be given if a DNS zone file is updated in the server
DELETE
This action will be given if the dns zone is deleted from the server.
Hook Inputs
This hook will be provided with the following inputs:
- data: A base64 encoded JSON data of the related actions, This is compulsory.
- action: The action code CREATE, UPDATE or DELETE, This is a compulsory
- panel: The control panel that performs the hooks, wap. rapp or uapp, This is a compulsory
- domain: The domain name performing the hooks. It is optional
- user: The Eenos user name associated with. It is optional
data
The data will be given as a base64 encoded Json data string. This data contains all the details of the Zone data which you can find in /var/eenos/userdata/USER/dns/domain.name file
The DELETE Action will be provided with an empty json data sting as there is no need to provide dns record details during the delete action
Example Pre/Post Hooks Scripts in Python
You can use the following sample python script to create a DNS Cluster update post of pre-action hook scripts.
#!/usr/bin/python3
'''
License GPL V3
Feel free to customize
'''
import os,sys
import argparse
from datetime import datetime
from pprint import pprint
import base64
def options(default=False):
parser = argparse.ArgumentParser(description='Sync Domain to Dns cluster',usage='%(prog)s [options] ')
optional=parser._action_groups.pop()
main_cmd = parser.add_argument_group("Command(s)")
main_cmd.add_argument('data',metavar="data",type=str,help='base64 encoded json data')
main_cmd.add_argument('action',metavar="action",type=str,help='The action CREATE, UPDATE, DELETE')
main_cmd.add_argument('panel',metavar="panel",type=str,help='The Control panel wap,rapp,uapp')
main_cmd.add_argument('domain',metavar="domain",help='Domain name')
optional.add_argument('user',metavar="user",help='User name')
parser._action_groups.append(optional)
args=None
if default:
now = datetime.now()
print('Copyright(c) 2020-'+str(now.year)+', eenos.com')
parser.print_help()
sys.exit(1)
else:
try:
args = parser.parse_args()
return vars(args)
except:
sys.exit(0)
if __name__ == "__main__":
if not sys.argv[1:]:
options(default=True)
sys.exit(0)
else:
cmd=options()
# pprint(cmd)
if bool(cmd) and bool(cmd['data']):
try:
domain=cmd['domain'].split('=')[-1]
action=cmd['action'].split('=')[-1]
base64_string=cmd['data'].split('=')[-1]
base64_bytes = base64_string.encode("ascii")
data_string_bytes = base64.b64decode(base64_bytes)
# Decoded json string
json_data_string=data_string_bytes.decode("ascii")
# print(json_data_string)
if action == 'CREATE':
print("Creating Remote DNS Cluster Zone entry for domain : %s" %domain)
'''
Add your remote api code here for creating dns zone entry in dns cluster.
'''
if action == 'UPDATE':
print("updating Remote DNS Cluster Zone entry for domain : %s" %domain)
'''
Add your remote api code here for updating dns zone entry in dns cluster.
'''
if action == 'DELETE':
print("Deleting Remote DNS Cluster Zone entry for domain : %s" %domain)
'''
Add your remote api code here for updating dns zone entry in dns cluster.
'''
except Exception as e:
print(str(e))
pass
We recommend using secure scripts to perform the actions.
createacct
The account creation hooks
These hooks will be executed when a user account creation happens.
Function name: createacct
Base Directory: /var/eenos/hooks/createacct
Pre-Hooks Location
Please place all your create account pre-hook scrips in /var/eenos/hooks/createacct/pre/
Post Hooks Location
Please put your post create account hooks scripts in /var/eenos/hooks/createacct/post/
All pre-hook and post-hook scripts need execute permission to perform the requested operations.
Supported Actions
This hook will support CREATE action only.
Hook Inputs
This hook will be provided with the following inputs:
- data: A base64 encoded JSON data of the related actions, This is compulsory.
- action: The action code CREATE, This is compulsory
- panel: The control panel that performs the hooks, wap, This is compulsory
- domain: The domain name performing the hooks. It is optional
- user: The Eenos user name associated with. It is optional
data
The data will be a base64 encoded json string that contains the userdata file contents.
removeacct
The account termination hooks
These hooks will be executed when a user account is being terminated.
Function name: removeacct
Base Directory: /var/eenos/hooks/removeacct
Pre-Hooks Location
Please place all your pre-hook scrips in /var/eenos/hooks/removeacct/pre/
Post Hooks Location
Please put your post hooks scripts in /var/eenos/hooks/removeacct/post/
All pre-hook and post-hook scripts need execute permission to perform the requested operations.
Supported Actions
This hook will support DELETE action only.
Hook Inputs
This hook will be provided with the following inputs:
- data: A base64 encoded JSON data of the related actions, This is compulsory.
- action: The action code DELETE, This is compulsory
- panel: The control panel that performs the hooks, wap, This is compulsory
- domain: The domain name performing the hooks. It is optional
- user: The Eenos user name associated with. It is optional
data
The data will be a base64 encoded json string that contains the userdata file contents.
suspendacct
The account suspend hooks
These hooks will be executed when a user account is being suspended.
Function name: suspendacct
Base Directory : /var/eenos/hooks/suspendacct
Pre-Hooks Location
Please place all your pre-hook scrips in /var/eenos/hooks/suspendacct/pre/
Post Hooks Location
Please put your post hooks scripts in /var/eenos/hooks/suspendacct/post/
All pre-hook and post-hook scripts need execute permission to perform the requested operations.
Supported Actions
This hook will support UPDATE action only.
Hook Inputs
This hook will be provided with the following inputs:
- data: A base64 encoded JSON data of the related actions, This is compulsory.
- action: The action code UPDATE, This is compulsory
- panel: The control panel that performs the hooks, wap, This is compulsory
- domain: The domain name performing the hooks. It is optional
- user: The Eenos user name associated with. It is optional
data
The data will be a base64 encoded json string that contains the userdata file contents.
unsuspendacct
The account unsuspend hooks
These hooks will be executed when a user account is being unsuspended.
Function name: unsuspendacct
Base Directory: /var/eenos/hooks/unsuspendacct
Pre-Hooks Location
Please place all your pre-hook scrips in /var/eenos/hooks/unsuspendacct/pre/
Post Hooks Location
Please put your post hooks scripts in /var/eenos/hooks/unsuspendacct/post/
All pre-hook and post-hook scripts need execute permission to perform the requested operations.
Supported Actions
This hook will support UPDATE action only.
Hook Inputs
This hook will be provided with the following inputs:
- data: A base64 encoded JSON data of the related actions, This is compulsory.
- action: The action code UPDATE, This is compulsory
- panel: The control panel that performs the hooks, wap, This is compulsory
- domain: The domain name performing the hooks. It is optional
- user: The Eenos user name associated with. It is optional
data
The data will be a base64 encoded json string that contains the the userdata file contents.