ralphlw

Member
Jan 2, 2008
5
0
51
It isn't hard to do the only problem is getting a supported post hook to have new accounts have their own .conf file in the nginx configuration directory and just include every file in there.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
It isn't hard to do the only problem is getting a supported post hook to have new accounts have their own .conf file in the nginx configuration directory and just include every file in there.
What cPanel/WHM function(s) do you need to hook? There is a possibility we may already offer the ability to do post hooks on the functionality you need to hook.
 

nvez

Active Member
PartnerNOC
Jul 17, 2006
40
0
156
add new account, domain parking, domain addon, domain forwarding :)

we need the hook to reload the script to generate new vhost.conf for nginx :)
Let me introduce you to ..

/scripts/postwwwacct

That's for after creating a new account.

For the others, I'm sure cPanel has something in place or you can dig for that yourself.

If they don't offer it, you could easily have a cronjob that runs every 5 minutes for the others.
 

nsetiono

Active Member
Mar 29, 2007
36
0
156
Let me introduce you to ..

/scripts/postwwwacct

That's for after creating a new account.

For the others, I'm sure cPanel has something in place or you can dig for that yourself.

If they don't offer it, you could easily have a cronjob that runs every 5 minutes for the others.
what i'm affraid is if there is a trouble if restarting nginx every 5 minutes :)
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
add new account, domain parking, domain addon, domain forwarding :)

we need the hook to reload the script to generate new vhost.conf for nginx :)
You can find some more information on /scripts/postwwwacct at:

ScriptHooks < DevHooks < TWiki

Domain parking, addon domains and domain forwarding are handled by cPanel API functions. Part of this API architecture is the ability to create function hooks to execute your own shell script after these functions are executed. You can read more about this at:

Hooking into cPanel Functionality

We have some documentation on the Addon Domains API functions at: AddonDomainRef < DeveloperResources/ApiRef < TWiki

We have documentation on Park Domains API functions at:

ParkRef < DeveloperResources/ApiRef < TWiki

The API 1 function call for adding a redirect (as used by the cPanel interface) is:

<cpanel Mime="add_redirect(path, type, url, domain, wildcard, rdwww)">

Mime is the module name
add_redirect is the function name

path is the path within the URL to redirect (if any)

type is either temp or permanent

url is the URL to redirect to

domain is .* if ** All Public Domains ** is selected, otherwise it is the domain/addon domain/etc to redirect.

wildcard is: 1 if this is a wildcard redirect

rdwww is: 2 if "Only redirect with www. " is selected, 0 if "Redirect with or without www." is selected, or 1 if "Do Not Redirect www." is selected.
 

nsetiono

Active Member
Mar 29, 2007
36
0
156
You can find some more information on /scripts/postwwwacct at:

ScriptHooks < DevHooks < TWiki

Domain parking, addon domains and domain forwarding are handled by cPanel API functions. Part of this API architecture is the ability to create function hooks to execute your own shell script after these functions are executed. You can read more about this at:

Hooking into cPanel Functionality

We have some documentation on the Addon Domains API functions at: AddonDomainRef < DeveloperResources/ApiRef < TWiki

We have documentation on Park Domains API functions at:

ParkRef < DeveloperResources/ApiRef < TWiki

The API 1 function call for adding a redirect (as used by the cPanel interface) is:

<cpanel Mime="add_redirect(path, type, url, domain, wildcard, rdwww)">

Mime is the module name
add_redirect is the function name

path is the path within the URL to redirect (if any)

type is either temp or permanent

url is the URL to redirect to

domain is .* if ** All Public Domains ** is selected, otherwise it is the domain/addon domain/etc to redirect.

wildcard is: 1 if this is a wildcard redirect

rdwww is: 2 if "Only redirect with www. " is selected, 0 if "Redirect with or without www." is selected, or 1 if "Do Not Redirect www." is selected.
how to adding it so if anyone adding a domain name it will run nginx.sh to regenerate the file vhost.conf
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
Friendly Moderator Note

I have moved our discussion about APIs and Hooks to a new thread in the cPanel/WHM Developer Discussions forum, where you are likely to receive more relevant feedback.
 

nsetiono

Active Member
Mar 29, 2007
36
0
156
currently i know the file responsible for domain addon add and domain addon deleting which is doadddomain.html and dodeldomain.html.

how i can put a code on it so it will run /scripts/nginx.sh after a domain successful added or deleted ?

for doadddomain.html, i know it's should be put after the code below

Code:
<cpanelif !$CPERROR{'addondomain'}>
   <cpanel print="$FORM{'domain'}"> &nbsp;<cpanel langprint="AODCreateYes">!<br />
  <!--  <cpanel Ftp="addftp($FORM{'user'},$FORM{'pass'},$FORM{'dir'},,,$FORM{'dir'})"> -->
<!--    If you would like to create an ftp account to upload files to this new domain, you can do so here: <a href="../ftp/addftp.html?domain$
<br/>   <cpanel langprint="AODGoFileMgr">: <a target="_blank" href="../files/index.html?dir=<cpanel print="$homedir">/<cpanel print="$FORM{'d$

</cpanelif>
and for dodeldomain.html it's should be put after the code below

Code:
<cpanelif !$CPERROR{'addondomain'}>
   <cpanel langprint="AODAddedPre">&nbsp; <cpanel print="$FORM{'domain'}"> &nbsp;<cpanel langprint="RDRedRemText">!
    <br /><cpanel Ftp="delftp($FORM{'domain'})">
</cpanelif>
the problem is i don't know what is the syntax to run /scripts/nginx.sh (my nginx generation is nginx.sh)
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,608
77
308
cPanel Access Level
Root Administrator
currently i know the file responsible for domain addon add and domain addon deleting which is doadddomain.html and dodeldomain.html.
Modifying the theme files will not accomplish what you want. DavidG earlier linked to our integration documentation. Please read the documents pertaining to 'hook' abilities.
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,545
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
is there any sample how to use the hook ?
i really newbie here about cpanel hook and really don't know what i must do and how to use the hook :(
Please carefully review the documentation; this will be the best resource to help learn. If you have specific questions about something feel free to ask; however, if you need assistance creating something I would consider locating and hiring someone to develop the solution for you.

The following advertising forums might help with locating a company to help:
Server Management and Server Repair - cPanel Forums

For details and examples, please thoroughly review the following documentation; the following link that cPanelDavidG provided should help:
Hooking into cPanel Functionality

Additional, more specific documentation pages linked from the above:
WritingFunctionHooks < DevHooks < TWiki
ScriptHooks < DevHooks < TWiki
CustomEventHandler < DevHooks < TWiki