File:  [LON-CAPA] / doc / loncapafiles / webserver.piml
Revision 1.42: download - view: text, annotated - select for diffs
Sun Apr 10 17:13:00 2016 UTC (8 years ago) by raeburn
Branches: MAIN
CVS tags: version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, HEAD
- Support Ubuntu 16 LTS.

    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.42 2016/04/10 17:13:00 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 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>
   50: <target dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12'>/etc/apache2/sites-available/loncapa</target>
   51: <target dist='ubuntu14 ubuntu16'>/etc/apache2/conf-available/loncapa</target>
   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>
   53: <dependencies dist='default'>
   54: /etc/httpd/conf/httpd.conf
   55: </dependencies>
   56: <dependencies dist='suse9.2 suse9.3 sles9'>
   57: /etc/httpd/httpd.conf
   58: </dependencies>
   59: <dependencies dist='debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12'>
   60: /etc/apache2/sites-available/loncapa
   61: </dependencies>
   62: <dependencies dist='ubuntu14 ubuntu16'>
   63: /etc/apache2/conf-available/loncapa
   64: </dependencies>
   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'>
   66: /etc/apache2/default-server.conf
   67: </dependencies>
   68: <perlscript mode='fg' dist="default">
   69: # Generated from doc/loncapafiles/webserver.piml
   70: unless (-e "<TARGET />") {
   71:   print '**** ERROR! <TARGET /> should exist! Are you missing the Apache '.
   72:     'software package?';
   73:   exit(1);
   74: }
   75: else {
   76:   # Append loncapa_apache.conf inclusion to httpd.conf 
   77:   # (or sites-available/loncapa or conf-available/loncapa) if not present.
   78:   $flag=0;
   79:   open(IN,'&lt;<TARGET />');
   80:   while (&lt;IN&gt;) { 
   81:     if (/^\s*Include\s+conf\/loncapa_apache.conf/) {
   82:       $flag=1; 
   83:     }
   84:   }
   85:   close(IN);
   86:   unless ($flag==1) {
   87:     open(OUT,'&gt;&gt;<TARGET />');
   88:     print(OUT 'Include conf/loncapa_apache.conf'."\n");
   89:     close(OUT);
   90:   }
   91:   # Remove loncapa.conf inclusion from httpd.conf 
   92:   # (or sites-available/loncapa or conf-available/loncapa) if present.
   93:   $flag=0;
   94:   open(IN,'&lt;<TARGET />');
   95:   while (&lt;IN&gt;) {
   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,'&lt;<TARGET />');
  104:     while(&lt;IN&gt;) {
  105:       $in.=$_ unless /^\s*Include\s+conf\/loncapa.conf/;
  106:     }
  107:     close(IN);
  108:     open(OUT,'&gt;<TARGET />');
  109:     print(OUT $in."\n");
  110:     close(OUT);
  111:   }
  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,'&lt;<TARGET />');
  119:   while (&lt;IN&gt;) {
  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) {
  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");
  147:   }
  148:   if ($documentroot_flag==1) {
  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");
  152:   }
  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 = &lt;PIPE&gt; ;
  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 = &lt;PIPE&gt; ;
  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:     }
  198: }
  199: </perlscript>
  200: </file>
  201: </files>
  202: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>