[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf lonhttpd /html/res/adm/pages menu.html /interface loncommon.pm /xml scripttag.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 24 Feb 2003 23:32:33 -0000
albertel Mon Feb 24 18:32:33 2003 EDT
Modified files:
/loncom lonhttpd loncapa_apache.conf
/loncom/xml scripttag.pm
/loncom/html/res/adm/pages menu.html
/loncom/interface loncommon.pm
Log:
- making it easy to moke the port lonhttpd is on, now a config option in loncapa_apache.conf, probably should be moved to loncapa.conf and added to the install questions
- added tag <LONCAPA_INTERNAL_LONHTTPD_PORT /> that gets replaced by a bit of javascript that sets the var lonhttpdport to the correct value
- lonhttpd reads the conf files on start up ad configures intself to the proper port, if the port is set to 80 it exits assuming that Apache is running there
- header image references reference the proper port
- finally making use of the fact that menu.html is parsed before sent out
- everything assumes a default value of 8080 if it can't find a set value
Index: loncom/lonhttpd
diff -u loncom/lonhttpd:1.5 loncom/lonhttpd:1.6
--- loncom/lonhttpd:1.5 Wed Nov 6 17:38:42 2002
+++ loncom/lonhttpd Mon Feb 24 18:32:32 2003
@@ -1,7 +1,7 @@
#!/usr/bin/perl
-# $Id: lonhttpd,v 1.5 2002/11/06 22:38:42 albertel Exp $
+# $Id: lonhttpd,v 1.6 2003/02/24 23:32:32 albertel Exp $
-$VERSION = "1.3.2 (Demonic/Linux/LON-CAPA Derivative)";
+$VERSION = "1.3.2 (Demonic/Linux/LON-CAPA Derivative $Revison$)";
# HTTPi Hypertext Tiny Truncated Process Implementation
# Copyright 1999-2001 Cameron Kaiser # All rights reserved
@@ -10,6 +10,17 @@
# LON-CAPA: find httpi license and readme at CVS loncom/license
#
+use lib '/home/httpd/lib/perl/';
+use LONCAPA::Configuration();
+%loncapavar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')};
+$port_to_use=$loncapavar{'lonhttpdPort'};
+if (!defined($port_to_use)) {
+ $port_to_use='8080';
+}
+
+# The main server is running on 80, so exit in this case
+if ($port_to_use eq '80') { die('Apache is already on Port 80'); }
+
%system_content_types =
("html" => "text/html",
"htm" => "text/html",
@@ -184,12 +195,13 @@
close(PIDSAVE);
$0 = "lonhttpd: (dhttpi) binding port ...";
-$bindthis = pack($sockaddr, 2, 8080, pack('l', chr(0).chr(0).chr(0).chr(0)));
+$bindthis = pack($sockaddr, 2, $port_to_use,
+ pack('l', chr(0).chr(0).chr(0).chr(0)));
socket(S, 2, 1, 6);
setsockopt(S, 1, 2, 1);
-bind(S, $bindthis) || die("$0: while binding port 8080:\n\"$!\"\n");
+bind(S, $bindthis) || die("$0: while binding port $port_to_use:\n\"$!\"\n");
listen(S, 128);
-$0 = "lonhttpd: (dhttpi) connected and waiting ANY:8080";
+$0 = "lonhttpd: (dhttpi) connected and waiting ANY:$port_to_use";
$statiosuptime = time();
@@ -431,7 +443,7 @@
</head>
<body bgcolor = "#ffffff" text = "#000000" vlink = "#0000ff" link = "#0000ff">
<h1>LonHTTPD (HTTPi) Server Status (<code>$VERSION</code>)</h1>
-<h3>lonhttpd on port 8080</h3>
+<h3>lonhttpd on port $port_to_use</h3>
<b>Started at:</b> $suptime<br>
<b>Uptime:</b> $d days, $h:$m:$s<br>
<b>Last request time:</b> $statiosltr<p>
@@ -478,8 +490,8 @@
$ENV{'SERVER_NAME'} = "localhost";
$ENV{'SERVER_PROTOCOL'} = "HTTP/$httpver";
$ENV{'SERVER_SOFTWARE'} = "HTTPi/$VERSION";
- $ENV{'SERVER_PORT'} = "8080";
- $ENV{'SERVER_URL'} = "http://localhost:8080/";
+ $ENV{'SERVER_PORT'} = "$port_to_use";
+ $ENV{'SERVER_URL'} = "http://localhost:$port_to_use/";
$ENV{'SCRIPT_FILENAME'} = $raddress;
$ENV{'SCRIPT_NAME'} = $address;
$ENV{'REMOTE_HOST'} = $hostname;
@@ -573,7 +585,7 @@
if ($pid = fork()) {
$0 = "lonhttpd: (dhttpi) waiting for child process";
waitpid($pid, 0);
- $0 = "lonhttpd: (dhttpi) on ANY:8080, last request " .
+ $0 = "lonhttpd: (dhttpi) on ANY:$port_to_use, last request " .
scalar localtime;
} else {
$0 = "lonhttpd: (dhttpi) child switching to socket";
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.35 loncom/loncapa_apache.conf:1.36
--- loncom/loncapa_apache.conf:1.35 Tue Feb 18 13:53:43 2003
+++ loncom/loncapa_apache.conf Mon Feb 24 18:32:32 2003
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.35 2003/02/18 18:53:43 www Exp $
+## $Id: loncapa_apache.conf,v 1.36 2003/02/24 23:32:32 albertel Exp $
##
#
@@ -720,6 +720,10 @@
PerlSetVar lonSqlAccess localhostkey
# -----------------------------------------------------------------------------
+# lonttpdPort is the port used by the lightweight graphics httpd server
+# not the main Apache server
+PerlSetVar lonhttpdPort 8080
+
# ====================================== Include machine-specific configuration
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.85 loncom/xml/scripttag.pm:1.86
--- loncom/xml/scripttag.pm:1.85 Fri Feb 7 17:03:21 2003
+++ loncom/xml/scripttag.pm Mon Feb 24 18:32:32 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# <script> definiton
#
-# $Id: scripttag.pm,v 1.85 2003/02/07 22:03:21 albertel Exp $
+# $Id: scripttag.pm,v 1.86 2003/02/24 23:32:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,7 +44,8 @@
('script','scriptlib','parserlib','import',
'window','display','storetc','physnet',
'standalone','comment',
- 'LONCAPA_INTERNAL_TURN_STYLE_ON'));
+ 'LONCAPA_INTERNAL_TURN_STYLE_ON',
+ 'LONCAPA_INTERNAL_LONHTTPD_PORT'));
}
sub start_LONCAPA_INTERNAL_TURN_STYLE_ON {
@@ -53,6 +54,21 @@
}
sub end_LONCAPA_INTERNAL_TURN_STYLE_ON {
+ return ('','no');
+}
+
+sub start_LONCAPA_INTERNAL_LONHTTPD_PORT {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ if ($target eq 'web') {
+ my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
+ if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
+ return '<script type="text/javascript">var lonhttpdport=\''.
+ $lonhttpdPort.'\';</script>';
+ }
+ return ('','no');
+}
+
+sub end_LONCAPA_INTERNAL_LONHTTPD_PORT {
return ('','no');
}
Index: loncom/html/res/adm/pages/menu.html
diff -u loncom/html/res/adm/pages/menu.html:1.87 loncom/html/res/adm/pages/menu.html:1.88
--- loncom/html/res/adm/pages/menu.html:1.87 Thu Feb 20 16:13:33 2003
+++ loncom/html/res/adm/pages/menu.html Mon Feb 24 18:32:32 2003
@@ -4,7 +4,7 @@
Remote Control
//
-// $Id: menu.html,v 1.87 2003/02/20 21:13:33 www Exp $
+// $Id: menu.html,v 1.88 2003/02/24 23:32:32 albertel Exp $
//
// Copyright Michigan State University Board of Trustees
//
@@ -40,6 +40,7 @@
onLoad="activate();"
>
<font size="1">
+<LONCAPA_INTERNAL_LONHTTPD_PORT />
<script type="text/javascript">
<!--
var statustop = '';
@@ -48,8 +49,8 @@
var dislocked = 1;
var statuslocked = 0;
-var imgpath=':8080/res/adm/pages/';
-var fontpath=':8080/adm/lonLCDfont/';
+var imgpath=':'+lonhttpdport+'/res/adm/pages/';
+var fontpath=':'+lonhttpdport+'/adm/lonLCDfont/';
var currentURL='';
var reloadURL='';
var currentSymb='';
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.82 loncom/interface/loncommon.pm:1.83
--- loncom/interface/loncommon.pm:1.82 Fri Feb 14 16:22:04 2003
+++ loncom/interface/loncommon.pm Mon Feb 24 18:32:32 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.82 2003/02/14 21:22:04 www Exp $
+# $Id: loncommon.pm,v 1.83 2003/02/24 23:32:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1482,8 +1482,10 @@
my $domain = &determinedomain(shift);
# See if there is a logo
if (-e '/home/httpd/html/adm/lonDomLogos/'.$domain.'.gif') {
- return '<img src="http://'.$ENV{'HTTP_HOST'}.':8080/adm/lonDomLogos/'.
- $domain.'.gif" />';
+ my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
+ if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
+ return '<img src="http://'.$ENV{'HTTP_HOST'}.':'.$lonhttpdPort.
+ '/adm/lonDomLogos/'.$domain.'.gif" />';
} elsif(exists($Apache::lonnet::domaindescription{$domain})) {
return $Apache::lonnet::domaindescription{$domain};
} else {
@@ -1576,6 +1578,8 @@
# Set messages
my $messages=&domainlogo($domain);
# Output
+ my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
+ if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
my $bodytag = <<END;
<body bgcolor="$pgbg" text="$font" alink="$alink" vlink="$vlink" link="$link"
$addentries>
@@ -1590,7 +1594,7 @@
$bodytag
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<tr><td bgcolor="$font">
-<img src="http://$ENV{'HTTP_HOST'}:8080/$img" /></td>
+<img src="http://$ENV{'HTTP_HOST'}:$lonhttpdPort$img" /></td>
<td bgcolor="$font"><font color='$sidebg'>$messages</font></td>
</tr>
<tr>