File:
[LON-CAPA] /
doc /
loncapafiles /
webserver.piml
Revision
1.32:
download - view:
text,
annotated -
select for diffs
Thu May 26 01:05:41 2011 UTC (13 years, 3 months ago) by
raeburn
Branches:
MAIN
CVS tags:
version_2_10_0,
HEAD
- Bug 5925.
- Support for rewriting of http:// to https:// for external web requests
if mod_ssl and mod_rewrite enabled. Default is: Rewrite off.
- webserver.piml
- Update description to accommodate additional distros.
- Error message generated if Apache config file is missing tailored to
distro.
- Compare LON-CAPA config file to rewrite: http:// -> https:// with
default files (rewrite Off and rewrite On); report if neither matches.
- loncapafiles.lpml
- Only need /etc/httpd/conf directory for CentOS/Red Hat/SL/Fedora
- Default files for rewrites Off and rewrites On in loncom/rewrites
- loncapa_apache.conf
- Include conf/loncapa_rewrite.conf to support rewrite.
1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
2: "http://lpml.sourceforge.net/DTD/piml.dtd">
3: <!-- webserver.piml -->
4:
5: <!-- $Id: webserver.piml,v 1.32 2011/05/26 01:05:41 raeburn Exp $ -->
6:
7: <!--
8:
9: Copyright Michigan State University Board of Trustees
10:
11: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
12:
13: LON-CAPA is free software; you can redistribute it and/or modify
14: it under the terms of the GNU General Public License as published by
15: the Free Software Foundation; either version 2 of the License, or
16: (at your option) any later version.
17:
18: LON-CAPA is distributed in the hope that it will be useful,
19: but WITHOUT ANY WARRANTY; without even the implied warranty of
20: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21: GNU General Public License for more details.
22:
23: You should have received a copy of the GNU General Public License
24: along with LON-CAPA; if not, write to the Free Software
25: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26:
27: /home/httpd/html/adm/gpl.txt
28:
29: http://www.lon-capa.org/
30:
31: -->
32:
33: <!-- Default values must be defined before specific values. -->
34: <!-- If no 'dist' attribute is specified, then it is always installed. -->
35: <!-- If 'dist' attribute is set to 'default', then the specification. -->
36: <!-- is accepted if an alternative distribution is not requested or not -->
37: <!-- defined. -->
38:
39: <piml>
40: <targetroot>/</targetroot>
41: <specialnotices>
42: <specialnotice>
43: </specialnotice>
44: </specialnotices>
45: <files>
46: <file>
47: <target dist='default'>/etc/httpd/conf/httpd.conf</target>
48: <target dist='suse9.2 suse9.3 sles9'>/etc/httpd/httpd.conf</target>
49: <target dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4'>/etc/apache2/default-server.conf</target>
50: <target dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10'>/etc/apache2/sites-available/loncapa</target>
51: <note>This is for Apache 1.X for Red Hat 4ES, Fedora 2, 3 and 4, SusSE 9.2 and 9.3, and SLES 9 distributions. This is for Apache 2.X for Fedora 5, Red Hat 5, CentOS 5, Scientific Linux 5, SuSE 10.1, SLES 10, Debian 5, Ubuntu LTS 8 and later distributions</note>
52: <dependencies dist='default'>
53: /etc/httpd/conf/httpd.conf
54: </dependencies>
55: <dependencies dist='suse9.2 suse9.3 sles9'>
56: /etc/httpd/httpd.conf
57: </dependencies>
58: <dependencies dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10'>
59: /etc/apache2/sites-available/loncapa
60: </dependencies>
61: <dependencies dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4'>
62: /etc/apache2/default-server.conf
63: </dependencies>
64: <perlscript mode='fg' dist="default">
65: # Generated from doc/loncapafiles/webserver.piml
66: unless (-e "<TARGET />") {
67: print '**** ERROR! <TARGET /> should exist! Are you missing the Apache '.
68: 'software package?';
69: exit(1);
70: }
71: else {
72: # Append loncapa_apache.conf inclusion to httpd.conf
73: # (or sites-available/loncapa) if not present.
74: $flag=0;
75: open(IN,'<<TARGET />');
76: while (<IN>) {
77: if (/^\s*Include\s+conf\/loncapa_apache.conf/) {
78: $flag=1;
79: }
80: }
81: close(IN);
82: unless ($flag==1) {
83: open(OUT,'>><TARGET />');
84: print(OUT 'Include conf/loncapa_apache.conf'."\n");
85: close(OUT);
86: }
87: # Remove loncapa.conf inclusion from httpd.conf if present.
88: $flag=0;
89: open(IN,'<<TARGET />');
90: while (<IN>) {
91: if (/^\s*Include\s+conf\/loncapa.conf/) {
92: $flag=1;
93: }
94: }
95: close(IN);
96: $in='';
97: if ($flag==1) {
98: open(IN,'<<TARGET />');
99: while(<IN>) {
100: $in.=$_ unless /^\s*Include\s+conf\/loncapa.conf/;
101: }
102: close(IN);
103: open(OUT,'><TARGET />');
104: print(OUT $in."\n");
105: close(OUT);
106: }
107:
108: # Checking for overlapping ScriptAlias and DocumentRoot definitions.
109: $scriptalias_flag=0;
110: $documentroot_flag=0;
111: my $scriptalias;
112: my $documentroot;
113: open(IN,'<<TARGET />');
114: while (<IN>) {
115: if (m!^\s*ScriptAlias\s+/cgi-bin/\s+(.*)$!) {
116: $scriptalias = $1;
117: if ($scriptalias !~ m!home/httpd/cgi-bin!) {
118: $scriptalias_flag = 1;
119: }
120: }
121: if (m!^\s*DocumentRoot\s+(.*)$!) {
122: $documentroot = $1;
123: if ($documentroot !~ m!home/httpd/html!) {
124: $documentroot_flag = 1;
125: }
126: }
127: }
128: close(IN);
129: if ($scriptalias_flag==1) {
130: my $conffile = '/etc/httpd/conf/httpd.conf';
131: if ('<DIST />' eq 'suse9.2' || '<DIST />' eq 'suse9.3'
132: || '<DIST />' eq 'sles9') {
133: $conffile = '/etc/httpd/httpd.conf';
134: } elsif ('<DIST />' =~ /^(suse|sles)/) {
135: $conffile = '/etc/apache2/default-server.conf';
136: } elsif ('<DIST />' =~ /^(debian|ubuntu)/) {
137: $conffile = '/etc/apache2/sites-available/loncapa';
138: }
139: print('**** ERROR **** '.$conffile.' has an overlapping definition of '.
140: 'ScriptAlias (it is incorrectly set to '.$scriptalias.').'."\n".
141: 'This conflicts with loncapa_apache.conf.'."\n");
142: }
143: if ($documentroot_flag==1) {
144: print('**** ERROR **** '.$conffile.' has an overlapping definition of '.
145: 'DocumentRoot (it is incorrectly set to '.$documentroot.').'."\n".
146: 'This conflicts with loncapa_apache.conf.'."\n");
147: }
148:
149: # Checking for rewrites of http:// to https://
150: my $rewrite_dir = '/etc/httpd/conf/rewrites';
151: my $curr_rewrite = '/etc/httpd/conf/loncapa_rewrite.conf';
152: if ('<DIST />' eq 'suse9.2' || '<DIST />' eq 'suse9.3'
153: || '<DIST />' eq 'sles9') {
154: $rewrite_dir = '/etc/httpd/rewrites/';
155: $curr_rewrite = '/etc/httpd/loncapa_rewrite.conf';
156: } elsif ('<DIST />' =~ /^(suse|sles|debian|ubuntu)/) {
157: $rewrite_dir = '/etc/apache2/rewrites';
158: $curr_rewrite = '/etc/apache2/loncapa_rewrite.conf';
159: }
160: my $rewrite_off = $rewrite_dir.'/loncapa_rewrite_off.conf';
161: my $rewrite_on = $rewrite_dir.'/loncapa_rewrite_on.conf';
162: if (!-e $curr_rewrite) {
163: system("cp $rewrite_off $curr_rewrite");
164: chmod(0644, $curr_rewrite);
165: } else {
166: my ($not_rewrite_on,$not_rewrite_off);
167: if (open(PIPE, "diff --brief $rewrite_off $curr_rewrite |")) {
168: my $diffres = <PIPE> ;
169: close(PIPE);
170: chomp($diffres);
171: if ($diffres) {
172: $not_rewrite_off = 1;
173: }
174: }
175: if (open(PIPE, "diff --brief $rewrite_on $curr_rewrite |")) {
176: my $diffres = <PIPE> ;
177: close(PIPE);
178: chomp($diffres);
179: if ($diffres) {
180: $not_rewrite_on = 1;
181: }
182: }
183: unless ($not_rewrite_off || $not_rewrite_on) {
184: print('**** WARNING **** '.$curr_rewrite.' does not match '.
185: 'either: '.$rewrite_on.' - the file used to enable rewriting '.
186: 'of requests for http:// to https:// or: '.$rewrite_off.
187: ' - the file used to disable such rewriting'."\n\n".
188: 'This may be because '. $curr_rewrite.' has been '.
189: 'previously customized, or it may be because of a change '.
190: 'to the files in '.$rewrite_dir."\n");
191: }
192: }
193: }
194: </perlscript>
195: </file>
196: </files>
197: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>