Annotation of doc/loncapafiles/webserver.piml, revision 1.38
1.8 harris41 1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
2: "http://lpml.sourceforge.net/DTD/piml.dtd">
1.1 harris41 3: <!-- webserver.piml -->
4:
1.38 ! raeburn 5: <!-- $Id: webserver.piml,v 1.37 2013/12/01 22:29:39 raeburn Exp $ -->
1.1 harris41 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>
1.6 harris41 40: <targetroot>/</targetroot>
1.2 harris41 41: <specialnotices>
42: <specialnotice>
43: </specialnotice>
44: </specialnotices>
1.1 harris41 45: <files>
46: <file>
47: <target dist='default'>/etc/httpd/conf/httpd.conf</target>
1.20 raeburn 48: <target dist='suse9.2 suse9.3 sles9'>/etc/httpd/httpd.conf</target>
1.37 raeburn 49: <target dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1'>/etc/apache2/default-server.conf</target>
1.38 ! raeburn 50: <target dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14'>/etc/apache2/sites-available/loncapa</target>
1.32 raeburn 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>
1.1 harris41 52: <dependencies dist='default'>
53: /etc/httpd/conf/httpd.conf
54: </dependencies>
1.20 raeburn 55: <dependencies dist='suse9.2 suse9.3 sles9'>
56: /etc/httpd/httpd.conf
57: </dependencies>
1.38 ! raeburn 58: <dependencies dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14'>
1.25 raeburn 59: /etc/apache2/sites-available/loncapa
60: </dependencies>
1.37 raeburn 61: <dependencies dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1'>
1.20 raeburn 62: /etc/apache2/default-server.conf
63: </dependencies>
1.19 raeburn 64: <perlscript mode='fg' dist="default">
1.11 harris41 65: # Generated from doc/loncapafiles/webserver.piml
1.1 harris41 66: unless (-e "<TARGET />") {
1.20 raeburn 67: print '**** ERROR! <TARGET /> should exist! Are you missing the Apache '.
1.13 harris41 68: 'software package?';
1.11 harris41 69: exit(1);
1.1 harris41 70: }
71: else {
1.32 raeburn 72: # Append loncapa_apache.conf inclusion to httpd.conf
73: # (or sites-available/loncapa) if not present.
1.9 harris41 74: $flag=0;
1.11 harris41 75: open(IN,'<<TARGET />');
1.9 harris41 76: while (<IN>) {
77: if (/^\s*Include\s+conf\/loncapa_apache.conf/) {
78: $flag=1;
79: }
80: }
1.11 harris41 81: close(IN);
1.9 harris41 82: unless ($flag==1) {
1.11 harris41 83: open(OUT,'>><TARGET />');
84: print(OUT 'Include conf/loncapa_apache.conf'."\n");
85: close(OUT);
1.9 harris41 86: }
1.12 harris41 87: # Remove loncapa.conf inclusion from httpd.conf if present.
1.11 harris41 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);
1.13 harris41 106: }
1.18 raeburn 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) {
1.32 raeburn 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");
1.18 raeburn 142: }
143: if ($documentroot_flag==1) {
1.32 raeburn 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");
1.18 raeburn 147: }
1.32 raeburn 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: }
1.13 harris41 193: }
194: </perlscript>
1.1 harris41 195: </file>
196: </files>
197: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>