--- loncom/configuration/Configuration.pm 2004/04/01 15:26:04 1.12 +++ loncom/configuration/Configuration.pm 2006/09/15 20:49:27 1.13 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Configuration file reader # -# $Id: Configuration.pm,v 1.12 2004/04/01 15:26:04 albertel Exp $ +# $Id: Configuration.pm,v 1.13 2006/09/15 20:49:27 raeburn Exp $ # # # Copyright Michigan State University Board of Trustees @@ -34,21 +34,32 @@ package LONCAPA::Configuration; -$VERSION = sprintf("%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/); +$VERSION = sprintf("%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/); use strict; -my $confdir='/etc/httpd/conf/'; +my @confdirs=('/etc/httpd/conf/','/etc/apache2/'); # ------------------- Subroutine read_conf: read LON-CAPA server configuration. # This subroutine reads PerlSetVar values out of specified web server # configuration files. sub read_conf { my (@conf_files)=@_; - my %perlvar; + my (%perlvar,%configdirs); foreach my $filename (@conf_files,'loncapa_apache.conf') { - open(CONFIG,'<'.$confdir.$filename) or - die("Can't read $confdir$filename"); + my $configdir = ''; + $configdirs{$filename} = [@confdirs]; + while ($configdir eq '' && @{$configdirs{$filename}} > 0) { + my $testdir = shift(@{$configdirs{$filename}}); + if (-e $testdir.$filename) { + $configdir = $testdir; + } + } + if ($configdir eq '') { + die("Couldn't find a directory containing $filename"); + } + open(CONFIG,'<'.$configdir.$filename) or + die("Can't read $configdir$filename"); while (my $configline=) { if ($configline =~ /^[^\#]*PerlSetVar/) { my ($unused,$varname,$varvalue)=split(/\s+/,$configline);