diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index c44162137..b97eb3947 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -236,10 +236,30 @@ sub open { ### config variables $session{config}{webguiRoot} = $_[0]; $session{config}{configFile} = $_[1] || "WebGUI.conf"; - $config = new Data::Config $session{config}{webguiRoot}.'/etc/'.$session{config}{configFile}; - foreach ($config->param) { - $session{config}{$_} = $config->param($_); - } + + # Below is a patch which allow you to configure WebGUI with + # environmentvariables in stead of using WebGUI.conf. To enable this + # set a env var called wgConfigureByEnvironment to 'YES'. The var + # names are those of WebGUI.conf prepended with 'wg'. + # + # NOTE: This is an undocumented an experimental feature. It seems to + # work with apache/linux on multiple virtual hosts. For things like + # runHourly.pm you STILL need WebGUI.conf! + + if ($ENV{wgConfigureByEnvironment} eq 'YES') { + foreach (keys(%ENV)) { + if ($_ =~ /^wg(.+)$/) { + $session{config}{$1} = $ENV{'wg'.$1}; + } + } + } else { + $config = new Data::Config + $session{config}{webguiRoot}.'/etc/'.$session{config}{configFile}; + foreach ($config->param) { + $session{config}{$_} = $config->param($_); + } + } + if( defined( $session{config}{scripturl} ) ) { # get rid of leading "/" if present. $session{config}{scripturl} =~ s/^\///;