Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 126486 - webapp-config subdomain handling
Summary: webapp-config subdomain handling
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Web Application Packages Maintainers
URL: http://forums.gentoo.org/viewtopic-t-...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-16 20:33 UTC by Peter Fern
Modified: 2006-12-05 07:32 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ugly hack to get a subdomain into the config, not proposed as formal patch (webapp-config-subdomain.patch,2.49 KB, patch)
2006-03-19 17:21 UTC, Peter Fern
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Fern 2006-03-16 20:33:00 UTC
webapp-config has no provision for common virtual hosting directory stucture /rootdir/domain.tld/subdomain/htdocs
Comment 1 Peter Fern 2006-03-16 20:39:39 UTC
Commonly virtual hosting setups use the directory structure /basedir/domain.tld/subdomain/ but webapp-config does not provide a method for installing to a structure of this form.  An easy solution would be to split the input from the '-h' switch and provide two new variables, eg ${vhost_domain} and ${vhost_subdomain}, whilst retaining ${vhost_hostname} for compatibility.  I don't write python, but I'll have a look at creating a small patch to this effect.  Previously it was possible to fairly simply extract this data on the fly by manipulating variables in using BASH methods as in the URL specified, but without delving into the config parser I can't easily see a method to allow this in the new python build...
Comment 2 Michael Eichenberger 2006-03-19 04:30:57 UTC
With the bash version we could do the following:
if [ "${G_HOSTNAME}" != "localhost" ];
then
    for i in 1 2 3; do
        domain[$i]=`echo ${G_HOSTNAME} | cut -d "." -f $i`
    done

    VHOST_ROOT="/var/www/${domain[3]}/${domain[2]}/${domain[1]}"
else
    VHOST_ROOT="/var/www/${G_HOSTNAME}"
fi

In the end we got the following structure (for www.domain.tld):
/var/www/tld/domain/www/public_html/...

At the moment, we can't really use the current webapp-config version, which really is shame, because it has huge advantaged for us as a web hosting company!

Kind regards, Michael
Comment 3 Peter Fern 2006-03-19 17:21:05 UTC
Or indeed, just using bash syntax like so (simple to adapt for your need of tld separation as well):

VHOST_ROOT="/home/www/${G_HOSTNAME#*.}/${G_HOSTNAME%%.*}"

I'm using the attached patch currently, it's not pretty but it works until there is a formal solution, or I learn some python.  Michael, it should be fairly easy for you to add another field to take the TLD, obviously this is a big and totally ugly way of getting what you need, but I had to get it working quickly as some packages seem to be depending on the current webapp-config.
Comment 4 Peter Fern 2006-03-19 17:21:54 UTC
Created attachment 82634 [details, diff]
Ugly hack to get a subdomain into the config, not proposed as formal patch
Comment 5 Gunnar Wrobel (RETIRED) gentoo-dev 2006-04-20 16:15:15 UTC
The webapps-team just released webapp-config-1.50.14 and we hope that this version fixes the problem.

There is one thing we cannot do: Bring back full bash parsing capabilities for the configuration file. Since we moved to python for speed reasons that was one thing we had to drop.

There was a (albeit undocumented, fixed in 1.50.14) workaround for that:

You can use the -D and -E switches in order to inject custom variables into the webapp-config parameters.

So you can set the vhost_root variable in the config file to
vhost_root=/srv/${my_fancy_var_1}/${my_fancy_var_2}/htdocs

and then call webapp-config with

webapp-config -D my_fancy_var_1=test -D my_fancy_var_2=test ...

As some users noted this gets kind of clumsy if you just want to split the domain into sub domain names. 

So we added the following variables now:

vhost_subdomain_1, vhost_subdomain_2, vhost_subdomain_3, ...

webapp-config will generate these automatically from the hostname and provide them internally. So you can use them in the configuration file like this:

vhost_root="/var/www/${vhost_subdomain_1}/${vhost_subdomain_2}/${vhost_subdomain_3}"

If you need a setup that is more complex than that you will have to employ the -D/-E switches and maybe wrap the webapp-config call into your own bash script.

Hope that satisfies all parties :)
Comment 6 Gunnar Wrobel (RETIRED) gentoo-dev 2006-05-04 07:47:47 UTC
Looks like my last fix did not work.

webapp-config -I -h www.gunnarwrobel.de -d /test squirrelmail 1.4.5-r1
* Fatal error: 
* Fatal error: There is a problem with your configuration file.
* Fatal error: webapp-config tried to read the variable "vhost_config_dir"
* Fatal error: and received the following error:
* Fatal error: 
* Fatal error: Bad value substitution:
* Fatal error: 	section: [USER]
* Fatal error: 	option : vhost_config_dir
* Fatal error: 	key    : vhost_subdomain_2
* Fatal error: 	rawval : 
* Fatal error: 
* Fatal error: Please note that webapp-config is not written in bash anymore
* Fatal error: and that you cannot use the bash scripting features.
* Fatal error(s) - aborting
Comment 7 Gunnar Wrobel (RETIRED) gentoo-dev 2006-05-05 15:54:04 UTC
yoann, I am somehow unable to reproduce the problem today. I did set vhost_root="/var/www/${vhost_subdomain_1}.${vhost_subdomain_2}/${vhost_subdomain_3}" and variations thereof but these settings work as expected. I did not store our IRC conversation. Could you be so kind and post your problematic setting again?
Comment 8 Thomas Beutin 2006-06-01 02:58:08 UTC
Just a question: is it possible to define a default value for some vars in the config file and overwrite them in the command line on demand?
Comment 9 Gunnar Wrobel (RETIRED) gentoo-dev 2006-12-05 07:32:52 UTC
@thomas: yes, that is possible. The configuration variables from the environment get imported after the config file has been read and overwrite these values.

Closing this bug since I got no response and the problem does not seem to persist.