[LON-CAPA-cvs] cvs: loncom / LondConnection.pm /configuration Configuration.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Fri, 15 Sep 2006 20:49:30 -0000
raeburn Fri Sep 15 16:49:30 2006 EDT
Modified files:
/loncom LondConnection.pm
/loncom/configuration Configuration.pm
/loncom/lonnet/perl lonnet.pm
Log:
Allow configuration files to be read in SLES10 when files are located in /etc/apache2. lonnet now reads in from loncapa.conf and loncapa_apache.conf using Configuration::read_conf().
Index: loncom/LondConnection.pm
diff -u loncom/LondConnection.pm:1.42 loncom/LondConnection.pm:1.43
--- loncom/LondConnection.pm:1.42 Fri Aug 25 17:20:11 2006
+++ loncom/LondConnection.pm Fri Sep 15 16:49:24 2006
@@ -1,7 +1,7 @@
# This module defines and implements a class that represents
# a connection to a lond daemon.
#
-# $Id: LondConnection.pm,v 1.42 2006/08/25 21:20:11 albertel Exp $
+# $Id: LondConnection.pm,v 1.43 2006/09/15 20:49:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1172,7 +1172,7 @@
#
-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
@@ -1180,25 +1180,33 @@
sub read_conf
{
my (@conf_files)=@_;
- my %perlvar;
- foreach my $filename (@conf_files,'loncapa_apache.conf')
- {
- if($DebugLevel > 3) {
- print STDERR ("Going to read $confdir.$filename\n");
- }
- open(CONFIG,'<'.$confdir.$filename) or
- die("Can't read $confdir$filename");
- while (my $configline=<CONFIG>)
- {
- if ($configline =~ /^[^\#]*PerlSetVar/)
- {
- my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
+ my (%perlvar,%configdirs);
+ foreach my $filename (@conf_files,'loncapa_apache.conf') {
+ 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");
+ }
+ if($DebugLevel > 3) {
+ print STDERR ("Going to read $configdir.$filename\n");
+ }
+ open(CONFIG,'<'.$configdir.$filename) or
+ die("Can't read $configdir$filename");
+ while (my $configline=<CONFIG>) {
+ if ($configline =~ /^[^\#]*PerlSetVar/) {
+ my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
chomp($varvalue);
$perlvar{$varname}=$varvalue;
- }
- }
+ }
+ }
close(CONFIG);
- }
+ }
if($DebugLevel > 3) {
print STDERR "Dumping perlvar:\n";
foreach my $var (keys %perlvar) {
Index: loncom/configuration/Configuration.pm
diff -u loncom/configuration/Configuration.pm:1.12 loncom/configuration/Configuration.pm:1.13
--- loncom/configuration/Configuration.pm:1.12 Thu Apr 1 10:26:04 2004
+++ loncom/configuration/Configuration.pm Fri Sep 15 16:49:27 2006
@@ -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=<CONFIG>) {
if ($configline =~ /^[^\#]*PerlSetVar/) {
my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.780 loncom/lonnet/perl/lonnet.pm:1.781
--- loncom/lonnet/perl/lonnet.pm:1.780 Fri Sep 15 03:55:05 2006
+++ loncom/lonnet/perl/lonnet.pm Fri Sep 15 16:49:29 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.780 2006/09/15 07:55:05 albertel Exp $
+# $Id: lonnet.pm,v 1.781 2006/09/15 20:49:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7117,29 +7117,8 @@
# ----------------------------------- Read loncapa.conf and loncapa_apache.conf
unless ($readit) {
{
- # FIXME: Use LONCAPA::Configuration::read_conf here and omit next block
- open(my $config,"</etc/httpd/conf/loncapa.conf");
-
- while (my $configline=<$config>) {
- if ($configline=~/\S/ && $configline =~ /^[^\#]*PerlSetVar/) {
- my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
- chomp($varvalue);
- $perlvar{$varname}=$varvalue;
- }
- }
- close($config);
-}
-{
- open(my $config,"</etc/httpd/conf/loncapa_apache.conf");
-
- while (my $configline=<$config>) {
- if ($configline =~ /^[^\#]*PerlSetVar/) {
- my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
- chomp($varvalue);
- $perlvar{$varname}=$varvalue;
- }
- }
- close($config);
+ my $configvars = LONCAPA::Configuration::read_conf('loncapa.conf');
+ %perlvar = (%perlvar,%{$configvars});
}
# ------------------------------------------------------------ Read domain file