Customised virtual_*.conf templates

FruitNZ

Verified User
Joined
Jul 3, 2008
Messages
5
Hi,

I am trying to customise the virtual_*.conf templates, more specifically the OPEN_BASE_DIR path.

We have a reseller that have developed their own PHP library/CMS system, and are using it for all their users. Currently they have to upload the whole library to the users home directory before they can use the site, which creates problems down the line with updates and support.

Is their a Token for the CREATOR/RESELLER that could be used in these templates? I see that there is one in the "Custom HTTPD Configuration" section, but that's only available to the Admin level, not Reseller.

I've tried:

|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/usr/local/lib/php/:/home/`CREATOR`/phplib/|

at the top of the file, but it resolves `CREATOR` as blank.

I've tried |CREATOR| further down like:

php_admin_value open_basedir |OPEN_BASEDIR_PATH|:/home/|CREATOR|/phplib/

but with the same result.

I've checked : http://help.directadmin.com/item.php?id=2 and yes, CREATOR is not in the Token list, but it is listed as a valid Token in "Custom HTTPD Configuration" (Available Tokens: |DOMAIN|, |IP|, |HOME|, |ADMIN|, |DOCROOT|, |USER|, |GROUP|, |CERT|, |KEY|, |HOSTNAME|, |SAFE_MODE|, |OPEN_BASEDIR|, |CREATOR|, |BANDWIDTH|, |QUOTA|)

Now I know that with the if-then-else and the scripting capabilities now available this can be done the long way, but I was hoping that someone might have a quicker and easier method :)

I'd appreciate any hints or advice that people might have to offer. I'll keep plugging away at this anyway :)


Cheers.

Regards,
Morgan
Hosting Direct Ltd
 
Well, I don't have the time to check it right now, but I think if you create a custom package item, its value should be populated into the custom template.
If it does, just make sure to make it a drop down with 2 possible values: "empty" and "/home/RESELLER/somelib" and that should be it.

Otherwise, you can use Ability to add scripting to the virtual_host.conf files and use it to extract the creator value from /usr/local/directadmin/data/users/|USER|/user.conf file.
It's still scripting, but much more manageable than creating custom domain_create_post.sh script.
 
Thank you so much for pointing out the Custom Package Item feature!

This has made it a piece of pie to implement. Just need to add some sanity checks on paths but so far everything works!

For anyone else who wants an example of this:

custom_packages_items.conf:

custobd=type=text&string=Shared PHP Lib Path&desc=Path to Resellers Custom PHP Lib&default=

virtual_host*.conf (replacing the old !*if OPEN_BASEDIR ... !*end block):

|$/usr/local/bin/php
<?
$ini_array = parse_ini_file("/usr/local/directadmin/data/users/|USER|/user.conf");
if ($ini_array[custobd])
{
echo "|*if OPEN_BASEDIR="ON"|\n";
echo "php_admin_value open_basedir |OPEN_BASEDIR_PATH|:/home/$ini_array[creator]/$ini_array[custobd]\n";
echo "|*endif|\n";
} else {
echo "|*if OPEN_BASEDIR="ON"|\n";
echo "php_admin_value open_basedir |OPEN_BASEDIR_PATH|\n";
echo "|*endif|\n";
}
?>
DONE|


I had to do it this way as the templates didn't seem to allow nested !*if blocks.

Need to go away and clean this up a bit more.

Thanks again!
 
Thank you muchly! This has been a tremendous help (both the linking to the features, and the example).

Thanks again,
Jarrod.
 
Back
Top