On Mon, Apr 11, 2005 at 06:59:03PM +0100, Tim Meadowcroft wrote:
> On Friday 08 Apr 2005 15:14, John Peacock wrote:
> > > �- a single qpsmtpd setup, but use tcprules with tcpserver to set an
> > > environment variable which could point at a different config folder in
> > > Qpsmtpd::get_qmail_config()
> >
> > Interesting idea but I don't know how well that will work (since the
> > config code is mostly interested in "get the qmail config files and if
> > nothing there, use the local config files"). �You could also look at the
> > http_config plugin to see how you can leverage the config hook.
> 
> I think it would work OK if in that one routine, where it uses "/config/" I 
> could change that part of the path lookup based on an env var or similar...
> � my $cfgdir = ENV{QPSMTPD_CONFIG} || "config";
> and then I could easily override to point at "config.localnet/" and the like.

I've been using multiple configs for a while and really like it. I'm using 
it a couple of ways:

 - to run two instances of qpsmtpd (one small and aggressive, one large and
   conservative) off of the same code base. It's easier to upgrade since I 
   just roll out the update once (and in my case, via rpms).

 - for unit and round-trip system testing, where I have multiple test 
   directories each containing their own configs and test data, and do
   individual test runs using the same server
   
My original patch (0.28 vintage, I think) was:

--- orig/lib/Qpsmtpd.pm
+++ mod/lib/Qpsmtpd.pm
@@ -69,6 +69,7 @@
   my $configdir = ($ENV{QMAIL} || '/var/qmail') . '/control';
   my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
   $configdir = "$name/config" if (-e "$name/config/$config");
+  $configdir = "$ENV{QPCONFIG}" if ($ENV{QPCONFIG} && -e 
"$ENV{QPCONFIG}/$config");
 
   my $configfile = "$configdir/$config";
   if ($self->{_config_cache}->{$configfile}) {
@@ -134,6 +135,7 @@
       my $config_dir = ($ENV{QMAIL} || '/var/qmail') . '/control';
       my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
       $config_dir = "$name/config" if (-e "$name/config/$inc");
+      $config_dir = "$ENV{QPCONFIG}" if ($ENV{QPCONFIG} && -e 
"$ENV{QPCONFIG}/$inc");
       if (-d "$config_dir/$inc") {
         $self->log(LOGDEBUG, "Loading include dir: $config_dir/$inc");
         opendir(DIR, "$config_dir/$inc") || die "opendir($config_dir/$inc): 
$!";


Cheers,
Gavin

Reply via email to