|With the addition of the custom package items, you can now use these items to control other areas of your system. For this example, we'll have these items control the content of a User httpd.conf file.|
1)The first step is to add a custom package item. See this guide on how to do that. For this example, use a checkbox. Give the variable a name called myval
2)Next, we need to have this option do something. By default, the item is only stored in the user.conf file.. it won't do anything.
To have it do something, create the script /usr/local/directadmin/scripts/custom/user_create_post.sh. Inside that file, add this code:
Which will insert the "CustomApache code" into the |CUSTOM| token in the virtual_host2*.conf template files.
The templates offer even more degrees of flexibility with the use of if-then-else statements and variables. For example, if you edit the global templates to have some code.... but you only want the code available for some Users or domains, you can if-then-else along with variables. For this example, if the variable MYVAL=yes is set, then we'll insert code into the httpd.conf, eg, in the virtual_host2*.conf files, after the |CUSTOM| token :
echo "CustomApache code" >> /usr/local/directadmin/data/users/$username/domains/$domain.cust_httpd
echo "|?MYVAL=yes|" >> /usr/local/directadmin/data/users/$username/domains/$domain.cust_httpdwhich get's inserted into the |CUSTOM| token, thus setting the variable.. so that once your if-then-else statement happens, the value=yes, and you're good to go.
You can then turn domain on or off from:
Admin Level -> Custom httpd config -> domain
by adding or removing the |MYVAL=yes| code from the text area.
This can also still be managed via the packages, but you'd also need to create user_modify_post.sh, to add or remove the domain.com.cust_httpd file, based on what value is set.
|Using the custom package item feature to alter user httpd.conf files|
© 2003 JBMC Software, Suite 173 3-11 Bellerose Drive, St Albert, AB T8N 1P7 Canada. Mon-Fri 9AM-5PM MST