Annotation of doc/loncapafiles/webserver.piml, revision 1.42
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.42 ! raeburn 5: <!-- $Id: webserver.piml,v 1.41 2015/01/03 03:00:18 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.41 raeburn 49: <target dist='sles10 sles11 sles12 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2'>/etc/apache2/default-server.conf</target>
1.39 raeburn 50: <target dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12'>/etc/apache2/sites-available/loncapa</target>
1.42 ! raeburn 51: <target dist='ubuntu14 ubuntu16'>/etc/apache2/conf-available/loncapa</target>
1.32 raeburn 52: <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 53: <dependencies dist='default'>
54: /etc/httpd/conf/httpd.conf
55: </dependencies>
1.20 raeburn 56: <dependencies dist='suse9.2 suse9.3 sles9'>
57: /etc/httpd/httpd.conf
58: </dependencies>
1.39 raeburn 59: <dependencies dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12'>
1.25 raeburn 60: /etc/apache2/sites-available/loncapa
61: </dependencies>
1.42 ! raeburn 62: <dependencies dist='ubuntu14 ubuntu16'>
1.39 raeburn 63: /etc/apache2/conf-available/loncapa
64: </dependencies>
1.41 raeburn 65: <dependencies dist='sles10 sles11 sles12 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2'>
1.20 raeburn 66: /etc/apache2/default-server.conf
67: </dependencies>
1.19 raeburn 68: <perlscript mode='fg' dist="default">
1.11 harris41 69: # Generated from doc/loncapafiles/webserver.piml
1.1 harris41 70: unless (-e "<TARGET />") {
1.20 raeburn 71: print '**** ERROR! <TARGET /> should exist! Are you missing the Apache '.
1.13 harris41 72: 'software package?';
1.11 harris41 73: exit(1);
1.1 harris41 74: }
75: else {
1.32 raeburn 76: # Append loncapa_apache.conf inclusion to httpd.conf
1.39 raeburn 77: # (or sites-available/loncapa or conf-available/loncapa) if not present.
1.9 harris41 78: $flag=0;
1.11 harris41 79: open(IN,'<<TARGET />');
1.9 harris41 80: while (<IN>) {
81: if (/^\s*Include\s+conf\/loncapa_apache.conf/) {
82: $flag=1;
83: }
84: }
1.11 harris41 85: close(IN);
1.9 harris41 86: unless ($flag==1) {
1.11 harris41 87: open(OUT,'>><TARGET />');
88: print(OUT 'Include conf/loncapa_apache.conf'."\n");
89: close(OUT);
1.9 harris41 90: }
1.39 raeburn 91: # Remove loncapa.conf inclusion from httpd.conf
92: # (or sites-available/loncapa or conf-available/loncapa) if present.
1.11 harris41 93: $flag=0;
94: open(IN,'<<TARGET />');
95: while (<IN>) {
96: if (/^\s*Include\s+conf\/loncapa.conf/) {
97: $flag=1;
98: }
99: }
100: close(IN);
101: $in='';
102: if ($flag==1) {
103: open(IN,'<<TARGET />');
104: while(<IN>) {
105: $in.=$_ unless /^\s*Include\s+conf\/loncapa.conf/;
106: }
107: close(IN);
108: open(OUT,'><TARGET />');
109: print(OUT $in."\n");
110: close(OUT);
1.13 harris41 111: }
1.18 raeburn 112:
113: # Checking for overlapping ScriptAlias and DocumentRoot definitions.
114: $scriptalias_flag=0;
115: $documentroot_flag=0;
116: my $scriptalias;
117: my $documentroot;
118: open(IN,'<<TARGET />');
119: while (<IN>) {
120: if (m!^\s*ScriptAlias\s+/cgi-bin/\s+(.*)$!) {
121: $scriptalias = $1;
122: if ($scriptalias !~ m!home/httpd/cgi-bin!) {
123: $scriptalias_flag = 1;
124: }
125: }
126: if (m!^\s*DocumentRoot\s+(.*)$!) {
127: $documentroot = $1;
128: if ($documentroot !~ m!home/httpd/html!) {
129: $documentroot_flag = 1;
130: }
131: }
132: }
133: close(IN);
134: if ($scriptalias_flag==1) {
1.32 raeburn 135: my $conffile = '/etc/httpd/conf/httpd.conf';
136: if ('<DIST />' eq 'suse9.2' || '<DIST />' eq 'suse9.3'
137: || '<DIST />' eq 'sles9') {
138: $conffile = '/etc/httpd/httpd.conf';
139: } elsif ('<DIST />' =~ /^(suse|sles)/) {
140: $conffile = '/etc/apache2/default-server.conf';
141: } elsif ('<DIST />' =~ /^(debian|ubuntu)/) {
142: $conffile = '/etc/apache2/sites-available/loncapa';
143: }
144: print('**** ERROR **** '.$conffile.' has an overlapping definition of '.
145: 'ScriptAlias (it is incorrectly set to '.$scriptalias.').'."\n".
146: 'This conflicts with loncapa_apache.conf.'."\n");
1.18 raeburn 147: }
148: if ($documentroot_flag==1) {
1.32 raeburn 149: print('**** ERROR **** '.$conffile.' has an overlapping definition of '.
150: 'DocumentRoot (it is incorrectly set to '.$documentroot.').'."\n".
151: 'This conflicts with loncapa_apache.conf.'."\n");
1.18 raeburn 152: }
1.32 raeburn 153:
154: # Checking for rewrites of http:// to https://
155: my $rewrite_dir = '/etc/httpd/conf/rewrites';
156: my $curr_rewrite = '/etc/httpd/conf/loncapa_rewrite.conf';
157: if ('<DIST />' eq 'suse9.2' || '<DIST />' eq 'suse9.3'
158: || '<DIST />' eq 'sles9') {
159: $rewrite_dir = '/etc/httpd/rewrites/';
160: $curr_rewrite = '/etc/httpd/loncapa_rewrite.conf';
161: } elsif ('<DIST />' =~ /^(suse|sles|debian|ubuntu)/) {
162: $rewrite_dir = '/etc/apache2/rewrites';
163: $curr_rewrite = '/etc/apache2/loncapa_rewrite.conf';
164: }
165: my $rewrite_off = $rewrite_dir.'/loncapa_rewrite_off.conf';
166: my $rewrite_on = $rewrite_dir.'/loncapa_rewrite_on.conf';
167: if (!-e $curr_rewrite) {
168: system("cp $rewrite_off $curr_rewrite");
169: chmod(0644, $curr_rewrite);
170: } else {
171: my ($not_rewrite_on,$not_rewrite_off);
172: if (open(PIPE, "diff --brief $rewrite_off $curr_rewrite |")) {
173: my $diffres = <PIPE> ;
174: close(PIPE);
175: chomp($diffres);
176: if ($diffres) {
177: $not_rewrite_off = 1;
178: }
179: }
180: if (open(PIPE, "diff --brief $rewrite_on $curr_rewrite |")) {
181: my $diffres = <PIPE> ;
182: close(PIPE);
183: chomp($diffres);
184: if ($diffres) {
185: $not_rewrite_on = 1;
186: }
187: }
188: unless ($not_rewrite_off || $not_rewrite_on) {
189: print('**** WARNING **** '.$curr_rewrite.' does not match '.
190: 'either: '.$rewrite_on.' - the file used to enable rewriting '.
191: 'of requests for http:// to https:// or: '.$rewrite_off.
192: ' - the file used to disable such rewriting'."\n\n".
193: 'This may be because '. $curr_rewrite.' has been '.
194: 'previously customized, or it may be because of a change '.
195: 'to the files in '.$rewrite_dir."\n");
196: }
197: }
1.13 harris41 198: }
199: </perlscript>
1.1 harris41 200: </file>
201: </files>
202: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>