File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.82: download - view: text, annotated - select for diffs
Fri Jul 29 16:44:36 2016 UTC (7 years, 9 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Add strict pragma
- Fix some typos

    1: <!-- updatequery.piml -->
    2: 
    3: <!-- $Id: updatequery.piml,v 1.82 2016/07/29 16:44:36 raeburn Exp $ -->
    4: 
    5: <!--
    6: 
    7: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: 
    9: LON-CAPA is free software; you can redistribute it and/or modify
   10: it under the terms of the GNU General Public License as published by
   11: the Free Software Foundation; either version 2 of the License, or
   12: (at your option) any later version.
   13: 
   14: LON-CAPA is distributed in the hope that it will be useful,
   15: but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: GNU General Public License for more details.
   18: 
   19: You should have received a copy of the GNU General Public License
   20: along with LON-CAPA; if not, write to the Free Software
   21: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: 
   23: /home/httpd/html/adm/gpl.txt
   24: 
   25: http://www.lon-capa.org/
   26: 
   27: -->
   28: 
   29: <piml>
   30: <targetroot>/</targetroot>
   31: <files>
   32: <file>
   33: <target dist='default'>/</target>
   34: <perlscript mode='fg'>
   35: $|=1;
   36:   use strict;
   37:   print(&lt;&lt;END);
   38: 
   39: 
   40: *********************************************
   41: *********************************************
   42: ****                                     ****
   43: **** LON-CAPA SYSTEM INFORMATION REQUEST ****
   44: ****                                     ****
   45: **** Please respond to the choices below ****
   46: ****                                     ****
   47: *********************************************
   48: *********************************************
   49: 
   50: END
   51: #sleep(3);
   52: </perlscript>
   53: </file>
   54: <file>
   55: <target dist='default'>loncom/hosts.tab</target>
   56: <perlscript mode='fg'>
   57: my $lonCluster;
   58: unless (-l "<TARGET />") {
   59:   print(&lt;&lt;END);
   60: 
   61: ===============================================================================
   62: Which cluster option would you like to have installed?
   63: IMPORTANT: to take advantage of the cluster options 1) and 3),
   64: you must contact lon-capa\@lon-capa.org.
   65: 
   66: 1) PRODUCTION - you want to eventually connect this machine to the
   67:                 LON-CAPA content sharing network. This setting is for
   68:                 schools, colleges, and universities, that currently
   69:                 are running - or in the future will run - courses
   70: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
   71:                  not be connected to other LON-CAPA machines for now
   72: 3) DEVELOPMENT - you want to do software (not content!) development with
   73:                  this workstation and eventually link it with the
   74:                  workstations of other LON-CAPA software developers.
   75: 4) RUNNING YOUR OWN CLUSTER - this machine is not in the standard LON-CAPA
   76:                  clusters and won't be in the future and you want the existing
   77:                  hosts.tab and domain.tab files to be left alone.
   78:                  (This choice is unlikely what you want to select.)
   79: END
   80: # Option number 26 will install rawhide_hosts.tab, but
   81: # the typical user does not want to be part of an intensive
   82: # machine test cluster.
   83: 
   84: # get input
   85: # if valid then process, otherwise loop
   86: my $flag=0;
   87: while (!$flag) {
   88:   print "ENTER 1, 2, 3, or 4:\n";
   89:   my $choice=&lt;&gt;;
   90:   chomp($choice);
   91:   if ($choice==1) {
   92:     $lonCluster='production'; $flag=1;
   93:   }
   94:   elsif ($choice==2) {
   95:     $lonCluster='standalone'; $flag=1;
   96:   }
   97:   elsif ($choice==3) {
   98:     $lonCluster='development'; $flag=1;
   99:   }
  100:   elsif ($choice==4) {
  101:     $lonCluster='existing'; $flag=1;
  102:     foreach my $file ('hosts.tab','dns_hosts.tab',
  103:                       'domain.tab','dns_domain.tab') {
  104:         if (-e '/home/httpd/lonTabs/'.$file) {
  105: 	    `cp /home/httpd/lonTabs/$file ../existing_$file`;
  106:         }
  107:         else {
  108: 	    print &lt;&lt;END;
  109: There is no existing /home/httpd/lonTabs/$file
  110: END
  111:             die('');
  112:         }
  113:     }
  114:   }
  115:   elsif ($choice==26) {
  116:     $lonCluster='rawhide'; $flag=1;
  117:   }
  118: }
  119: }
  120: </perlscript>
  121: </file>
  122: <file>
  123: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  124: <perlscript mode='fg'>
  125: $|=1;
  126: my $domainDescription;
  127: my $domainTabExtras;
  128: my $primaryLibServer;
  129: my $protocol;
  130: my $intdom;
  131: my @libservers = ();
  132: unless (-e "<TARGET />") {
  133:   print(&lt;&lt;END);
  134:            WELCOME TO LON-CAPA!
  135: 
  136: If you have questions, please visit http://install.lon-capa.org
  137: or contact helpdesk\@lon-capa.org.
  138: 
  139: ===============================================================================
  140: The following 7 values are needed to configure LON-CAPA:
  141: * Machine Role
  142: * LON-CAPA Domain Name
  143: * LON-CAPA Machine ID Name
  144: * Server Administration E-mail Address
  145: * LON-CAPA Domain's Primary Library Server Machine ID
  146: * Web Server Protocol
  147: * Internet Domain Name of Your Institution
  148: ===============================================================================
  149: 
  150: In addition, a Support E-mail Address can also be included. If
  151: an address is included then one of the options in the LON-CAPA 
  152: help menu will be a link to a form that a user will complete to
  153: request LON-CAPA help.  
  154: 
  155: END
  156: 
  157: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
  158: close(OUT);
  159: 
  160: # query for Machine Role
  161:   print(&lt;&lt;END);
  162: **** Machine Role ****
  163: Library server (recommended if first-time installation of LON-CAPA):
  164:    Servers that are repositories of authoritative educational resources.
  165:    These servers also provide the construction space by which instructors
  166:    assemble their classroom online material.
  167: Access server:
  168:    Servers that load-balance high-traffic delivery of educational resources
  169:    over the world-wide web.
  170: 1) Will this be a library server? (recommended if this is your first install)
  171: 2) Or, will this be an access server?
  172: END
  173: my $flag=0;
  174: my $r='';
  175: my $lonRole;
  176: while (!$flag) {
  177:   print "ENTER A CHOICE OF 1 or 2:\n";
  178:   my $choice=&lt;&gt;;
  179:   chomp($choice);
  180:   if ($choice==1) {
  181:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  182:     print(OUT 'lonRole'."\t".'library'."\n");
  183:     close(OUT);
  184:     $lonRole='library';
  185:     $r='l';
  186:     $flag=1;
  187:   }
  188:   elsif ($choice==2) {
  189:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  190:     print(OUT 'lonRole'."\t".'access'."\n");
  191:     close(OUT);
  192:     $lonRole='access';
  193:     $r='a';
  194:     $flag=2;
  195:   }
  196:   else {
  197: 
  198:   }
  199: }
  200: 
  201: # need to recommend a machine ID name (ipdomain.l.somenumber)
  202: my $hostname=`hostname -f`; chomp($hostname);
  203: my $ipdomain='';
  204: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
  205:   $ipdomain=$1;
  206: }
  207: 
  208:   print(&lt;&lt;END);
  209: 
  210: **** Domain ****
  211: [This does NOT need to correspond to internet address domains.
  212:  Please make this name short AND descriptive of your organization.
  213:  Domain names are close to impossible to change later!!!
  214:  Good examples might be "msu" or "bionet" or "vermontcc".
  215:  Bad examples are "physics" (too general)
  216:    or "michiganstateuniversity" (too long)
  217:    or "msuedu" (internet domain, just make it "msu")
  218:    or "msuphysics" (only if there is a good reason to limit to department
  219:                     - we don't know of one)
  220:    or "mydomain" (what is that?)
  221:  Avoid multiple domains at the same institution, even if it means that you 
  222:  have to actually work together with your colleagues. You can still run
  223:  multiple library servers within the same domain.
  224:  If this domain is eventually going to be part of the main production
  225:  cluster, you MUST contact the LON-CAPA group at MSU (loncapa\@loncapa.org)
  226:  to have a domain name assigned, and then use it exactly as given. This is
  227:  also true for test installs that might eventually turn into production setups.
  228:  Stop now if you didn't do so.]
  229: END
  230: 
  231: # get domain name
  232: # accept if valid, if not valid, tell user and repeat
  233: $flag=0;
  234: my $lonDefDomain;
  235: while (!$flag) {
  236: if ($ipdomain) {
  237: print(&lt;&lt;END);
  238: ENTER LONCAPA DOMAIN [$ipdomain]:
  239: END
  240: }
  241: else {
  242:   print(&lt;&lt;END);
  243: ENTER LONCAPA DOMAIN:
  244: END
  245: }
  246:   my $choice=&lt;&gt;;
  247:   chomp($choice);
  248:   my $bad_domain_flag=0;
  249:   my @bad_domain_names=('res','raw','userfiles','priv','adm','uploaded',
  250: 	'editupload');
  251:   foreach my $bad (@bad_domain_names) {
  252:     $bad_domain_flag=1 if $choice eq $bad;
  253:   }
  254:   if ($choice=~/capa/i) {
  255:      $bad_domain_flag=1;
  256:   }
  257:   if ($ipdomain and $choice=~/^\s*$/) {
  258:     $choice=$ipdomain;
  259:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  260:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  261:     close(OUT);
  262:     $lonDefDomain=$choice;
  263:     $flag=1;
  264:   } elsif (length($choice)>35) {
  265:     print "Name too long\n";
  266:   } elsif (length($choice)<2) {
  267:     print "Name too short\n";
  268:   } elsif ($bad_domain_flag) {
  269:     print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
  270:     print "Please try something different than '$choice'\n";
  271:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  272:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  273:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  274:     close(OUT);
  275:     $lonDefDomain=$choice;
  276:     $r='l';
  277:     $flag=1;
  278:   } else {
  279:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  280:   }
  281: }
  282: 
  283: 
  284: # get domain description
  285: # accept if valid, if not valid, tell user and repeat
  286: $flag=0;
  287: 
  288: while (!$flag) {
  289:   print(&lt;&lt;END);
  290: 
  291: **** Domain Description ****
  292: String describing the domain, to be shown to users.
  293: [Example, msu is Michigan State University]
  294: ENTER DOMAIN DESCRIPTION:
  295: END
  296: 
  297:   my $choice=&lt;&gt;;
  298:   chomp($choice);
  299:   if ($choice!~/:/) {
  300:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  301:     print(OUT 'domainDescription'."\t".$choice."\n");
  302:     close(OUT);
  303:     $domainDescription=$choice;
  304:     $flag=1;
  305:   }
  306:   else {
  307:     print "Invalid input (no ':' allowed).\n";
  308:   }
  309: }
  310: 
  311: my $lonHostID;
  312: if ($lonDefDomain) {
  313:   $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
  314:                                               # against the hosts.tab
  315: }
  316: 
  317:   print(&lt;&lt;END);
  318: 
  319: **** Machine ID Name ****
  320: [This does NOT need to correspond to internet address names;
  321:  this name MUST be unique to the whole LON-CAPA network;
  322:  we recommend that you use a name based off of your institution.
  323:  Good examples: "msul1" or "bioneta2".
  324:  Bad examples: "loncapabox" or "studentsinside".
  325:  Note that machine names are very hard to change later.]
  326: END
  327: # get machine name
  328: # accept if valid, if not valid, tell user and repeat
  329: $flag=0;
  330: while (!$flag) {
  331: if ($ipdomain) {
  332: print(&lt;&lt;END);
  333: ENTER LONCAPA MACHINE ID [$lonHostID]:
  334: END
  335: }
  336: else {
  337:   print(&lt;&lt;END);
  338: ENTER LONCAPA MACHINE ID:
  339: END
  340: }
  341:   my $choice=&lt;&gt;;
  342:   chomp($choice);
  343:   if ($choice=~/capa/i) {
  344:     print "Invalid input (names containing 'capa' are reserved).\n";
  345:   } elsif ($lonHostID and $choice=~/^\s*$/) {
  346:     $choice=$lonHostID;
  347:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  348:     print(OUT 'lonHostID'."\t".$choice."\n");
  349:     close(OUT);
  350:     $lonHostID=$choice;
  351:     $flag=1;
  352:   } elsif (length($choice)>45) {
  353:     print "Name too long\n";
  354:   } elsif (length($choice)<4) {
  355:     print "Name too short\n";
  356:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  357:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  358:     print(OUT 'lonHostID'."\t".$choice."\n");
  359:     close(OUT);
  360:     $lonHostID=$choice;
  361:     $flag=1;
  362:   } else {
  363:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  364:   }
  365: }
  366: 
  367: # get primary library server in domain
  368: if ($lonRole eq 'library') {
  369:     if (!grep/^\Q$lonHostID\E$/,@libservers) {
  370:         push(@libservers,$lonHostID);
  371:     } 
  372:     if (@libservers == 1) {
  373:         $primaryLibServer = $libservers[0];
  374:     }
  375: }
  376: 
  377: $flag=0;
  378: while (!$flag) {
  379:   print(&lt;&lt;END);
  380: **** Domain's Primary Library Server ID ****
  381: This should be the LON-CAPA machine ID of a library server in your 
  382: domain.  If you only have a single library server in your domain, then
  383: the Primary Library server ID will be the machine ID of that server. 
  384: This server will be where domain data which are not associated with any
  385: specific home library server will be stored (e.g., e-mail broadcast by
  386: administrators to users in the domain).
  387: END
  388:     if (defined($primaryLibServer)) {
  389:         print(&lt;&lt;END);
  390: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:
  391: END
  392:     } elsif (@libservers > 0) {
  393:         print(&lt;&lt;END);
  394: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]]
  395: END
  396:     } else {
  397:         print (&lt;&lt;END);
  398: No library servers could be identified for this domain.  If you have already installed LON-CAPA on a different server (designated as a library server) in this domain, please enter the LONCAPA MACHINE ID of that server.  If not, you will need to install a LON-CAPA library server.  Enter the MACHINE ID of the server you plan to designate as a library server.
  399: END
  400:     }
  401: 
  402:     my $choice=&lt;&gt;;
  403:     chomp($choice);
  404:     if ($primaryLibServer and $choice=~/^\s*$/) {
  405:         $choice=$primaryLibServer;
  406:         open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  407:         print(OUT 'primaryLibServer'."\t".$choice."\n");
  408:         close(OUT);
  409:         $flag=1;
  410:     } elsif (length($choice)>35) {
  411:         print "Name too long\n";
  412:     } elsif (length($choice)<4) {
  413:         print "Name too short\n";
  414:     } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  415:         open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  416:         print(OUT 'primaryLibServer'."\t".$choice."\n");
  417:         close(OUT);
  418:         $primaryLibServer=$choice;
  419:         $flag=1;
  420:     } else {
  421:         print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  422:     }
  423: }
  424: 
  425: 
  426: # get admin e-mail address
  427: # accept if valid, if not valid, tell user and repeat
  428: $flag=0;
  429: my $lonAdmEMail;
  430: while (!$flag) {
  431:   print(&lt;&lt;END);
  432: 
  433: **** Server Administrators E-mail ****
  434: E-mail address of the person who will manage this machine
  435: [should be in the form somebody\@somewhere]
  436: ENTER ADMIN E-MAIL ADDRESS:
  437: END
  438: 
  439:   my $choice=&lt;&gt;;
  440:   chomp($choice);
  441:   if ($choice=~/\@/) {
  442:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  443:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
  444:     close(OUT);
  445:     $lonAdmEMail=$choice;
  446:     $flag=1;
  447:   }
  448:   else {
  449:     print "Invalid input (this needs to look like an e-mail address!).\n";
  450:   }
  451: }
  452: 
  453: 
  454: # get support e-mail address
  455: # accept if valid, if not valid, tell user and repeat
  456: $flag=0;
  457: my $lonSupportEMail;
  458: while (!$flag) {
  459:   print(&lt;&lt;END);
  460: 
  461: **** Support E-mail ****
  462: E-mail address of the person who will receive 
  463: help requests from LON-CAPA users who access 
  464: the system via this server. If the address is left blank,
  465: then a help support form will not be displayed 
  466: as part of the help menu.
  467: [should be in the form somebody\@somewhere]
  468: ENTER SUPPORT E-MAIL ADDRESS:
  469: END
  470: 
  471:   my $choice=&lt;&gt;;
  472:   chomp($choice);
  473:   $choice =~ s/\s//g;
  474:   if ( ($choice=~/\@/) || $choice eq '') {
  475:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  476:     print(OUT 'lonSupportEMail'."\t".$choice."\n");
  477:     close(OUT);
  478:     $lonSupportEMail=$choice;
  479:     $flag=1;
  480:   }
  481:   else {
  482:     print "Invalid input (this either needs to be blank, or look like an e-mail address!).\n";
  483:   }
  484: }
  485: 
  486: # get protocol
  487: # accept if valid, if not valid, tell user and repeat
  488: $flag=0;
  489: while (!$flag) {
  490:   print(&lt;&lt;END);
  491: 
  492: ****  Web Server Protocol ****
  493: If you plan to run the Apache server with SSL enabled, 
  494: the protocol should be: https; otherwise it should be http.
  495: ENTER WEB SERVER PROTOCOL [http]:
  496: END
  497: 
  498:   my $choice=&lt;&gt;;
  499:   chomp($choice);
  500:   if ($choice =~ /^https?$/) {
  501:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  502:     print(OUT 'protocol'."\t".$choice."\n");
  503:     close(OUT);
  504:     $protocol=$choice;
  505:     $flag=1;
  506:   } elsif ($choice eq '') {
  507:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  508:     print(OUT 'protocol'."\t".'http'."\n");
  509:     close(OUT);
  510:     $protocol = 'http';
  511:     $flag = 1;
  512:   } else {
  513:     print "Invalid input (only http or https allowed).\n";
  514:   }
  515: }
  516: 
  517: # get internet domain
  518: # accept if valid, if not valid, tell user and repeat
  519: $flag=0;
  520: while (!$flag) {
  521:   print(&lt;&lt;END);
  522: 
  523: ****  Internet Domain Name of Your Institution ****
  524: 
  525: The internet domain name used for servers at your institution 
  526: should be provided.  This will be similar to: ustate.edu or
  527: topcollege.ac.uk or my.hostingcompany.com, i.e., the part of
  528: a server hostname which indicates to which organization the 
  529: server belongs.
  530: 
  531: ENTER INTERNET DOMAIN NAME:
  532: END
  533: 
  534:   my $choice=&lt;&gt;;
  535:   chomp($choice);
  536:   if ($choice =~/[^.]+\.[^.]+/) {
  537:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  538:     print(OUT 'internet domain'."\t".$choice."\n");
  539:     close(OUT);
  540:     $intdom=$choice;
  541:     $flag=1;
  542:   }
  543:   else {
  544:     print "Invalid input (must be at least two levels separated by .  - e.g., ustate.edu).\n";
  545:   }
  546: }
  547: 
  548: 
  549: # update loncapa.conf
  550: my $confdir = '/etc/httpd/conf/';
  551: if ('<DIST />' eq 'sles10' || '<DIST />' eq 'sles11' || '<DIST />' eq 'sles12' || '<DIST />' eq 'suse10.1' || '<DIST />' eq 'suse10.2' || '<DIST />' eq 'suse10.3' || '<DIST />' eq 'suse11.1' || '<DIST />' eq 'suse11.2' || '<DIST />' eq 'suse11.3' || '<DIST />' eq 'suse11.4' || '<DIST />' eq 'suse12.1' || '<DIST />' eq 'suse12.2' || '<DIST />' eq 'suse12.3' || '<DIST />' eq 'suse13.1' || '<DIST />' eq 'suse13.2' || '<DIST />' eq 'debian5' || '<DIST />' eq 'debian6' || '<DIST />' eq 'ubuntu6' || '<DIST />' eq 'ubuntu8' || '<DIST />' eq 'ubuntu10' || '<DIST />' eq 'ubuntu12' || '<DIST />' eq 'ubuntu14' || '<DIST />' eq 'ubuntu16') {
  552:      $confdir = '/etc/apache2/';
  553: }   
  554: my $filename='loncapa.conf';
  555: my %perlvar;
  556:     if (-e "$confdir$filename") {
  557: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
  558: 	while (my $configline=&lt;CONFIG&gt;) {
  559: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  560: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  561: 		chomp($varvalue);
  562: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
  563: 	    }
  564: 	}
  565: 	close(CONFIG);
  566:     }
  567:     $perlvar{'lonHostID'}=$lonHostID;
  568:     $perlvar{'lonDefDomain'}=$lonDefDomain;
  569:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
  570:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
  571:     $perlvar{'lonRole'}=$lonRole;
  572:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  573:        $perlvar{'lonLoadLim'}='2.00';
  574:     }
  575:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  576:        $perlvar{'lonUserLoadLim'}='0';
  577:     }
  578:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  579:        $perlvar{'lonExpire'}='86400';
  580:     }
  581:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  582:        my $lonReceipt='';
  583:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  584:        my @alnum=(0..9,"a".."z");
  585:        foreach my $i (1..20) {
  586: 	 $lonReceipt.=$alnum[int(rand(36))];
  587:        }
  588:        $perlvar{'lonReceipt'}=$lonReceipt;
  589:     }
  590:     open(OUT,"&gt;$confdir$filename") or
  591:       die("Cannot output to $confdir$filename\n");
  592:     foreach my $key (keys %perlvar) {
  593:       my $value=$perlvar{$key};
  594:       my $line = "PerlSetVar     $key      $value"; 
  595:       if ($value eq '') {
  596:           $line = '#'.$line;
  597:       }
  598:       print(OUT &lt;&lt;END);
  599: $line
  600: END
  601:     }
  602:     close(OUT);
  603: }
  604: </perlscript>
  605: </file>
  606: <file>
  607: <target dist='default'>/etc/httpd/conf/</target>
  608: <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 debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14 ubuntu16'>/etc/apache2/</target>
  609: <perlscript mode='fg'>
  610: sub securesetting {
  611:     my (%perlvar)=@_;
  612:     my $securestatus='unknown';
  613:     my $securenum='';
  614:     if      ( $perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
  615: 	$securestatus='no';                  $securenum='4';
  616:     } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
  617: 	$securestatus='lond';                $securenum='3';
  618:     } elsif (!$perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
  619: 	$securestatus='lonc';                $securenum='2';
  620:     } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
  621: 	$securestatus='yes (lond and lonc)'; $securenum='1';
  622:     }
  623:     return ($securestatus,$securenum);
  624: }
  625: # read values from loncapa.conf
  626: my $confdir = "<TARGET />";
  627: my $filename='loncapa.conf';
  628: my %perlvar;
  629: my ($securestatus,$securenum);
  630:     if (-e "$confdir$filename") {
  631: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
  632:           die("Can't read $confdir$filename");
  633: 	while (my $configline=&lt;CONFIG&gt;) {
  634: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  635: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  636: 		chomp($varvalue);
  637: 		$perlvar{$varname}=$varvalue;
  638: 	    }
  639: 	}
  640: 	close(CONFIG);
  641:     }
  642:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  643:        $perlvar{'lonLoadLim'}='2.00';
  644:     }
  645:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  646:        $perlvar{'lonUserLoadLim'}='0';
  647:     }
  648:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  649:        $perlvar{'lonExpire'}='86400';
  650:     }
  651:     unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
  652:        $perlvar{'londAllowInsecure'}='1';
  653:     }
  654:     unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
  655:        $perlvar{'loncAllowInsecure'}='1';
  656:     }
  657:     ($securestatus,$securenum)=&securesetting(%perlvar);
  658:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  659:        my $lonReceipt='';
  660:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  661:        my @alnum=(0..9,"a".."z");
  662:        foreach my $i (1..20) {
  663: 	 $lonReceipt.=$alnum[int(rand(36))];
  664:        }
  665:        $perlvar{'lonReceipt'}=$lonReceipt;
  666:     }
  667: my %perlvarstatic;
  668:     if (-e "${confdir}loncapa_apache.conf") {
  669: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
  670:           die("Can't read ${confdir}loncapa_apache.conf");
  671: 	while (my $configline=&lt;CONFIG&gt;) {
  672: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  673: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  674: 		chomp($varvalue);
  675: 		$perlvarstatic{$varname}=$varvalue;
  676: 	    }
  677: 	}
  678: 	close(CONFIG);
  679:     }
  680: 
  681:     my (@hosts_files, @domain_files);
  682:     if ( $lonCluster ne 'existing') {
  683: 	push(@domain_files,'../'.$lonCluster.'_domain.tab',
  684: 	     '../'.$lonCluster.'_dns_domain.tab');
  685: 	push(@hosts_files,'../'.$lonCluster.'_hosts.tab',
  686: 	     '../'.$lonCluster.'_dns_hosts.tab');
  687:     }
  688:     push(@domain_files,'/home/httpd/lonTabs/domain.tab',
  689:          '/home/httpd/lonTabs/dns_domain.tab');
  690:     push(@hosts_files,'/home/httpd/lonTabs/hosts.tab',
  691:          '/home/httpd/lonTabs/dns_hosts.tab');
  692: 
  693:     if (!$domainDescription) {
  694: 	foreach my $file (@domain_files) {
  695: 	    open(IN,'&lt;'.$file);
  696: 	    while(my $line = &lt;IN&gt;) {
  697: 		if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
  698: 		    (undef,$domainDescription,$domainTabExtras)=split(/:/,$line,3);
  699: 		    chomp($domainDescription);
  700: 		    chomp($domainTabExtras);
  701: 		    # the remaining field (primary lib server) is handled later
  702: 		    $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
  703: 		    last;
  704: 		}
  705: 	    }
  706: 	    close(IN);
  707: 	    last if ($domainDescription);
  708: 	}
  709:     }
  710: 
  711:     if (!$protocol) {
  712:         foreach my $file (@hosts_files) {
  713:             open(IN,'&lt;'.$file);
  714:             while(my $line = &lt;IN&gt;) {
  715:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:(https?)/) {
  716:                     $protocol = $1;
  717:                     chomp($protocol);
  718:                     last;
  719:                 }
  720:             }
  721:         }
  722:     }
  723: 
  724:     if (!$protocol) {
  725:         $protocol = 'http';
  726:     }
  727: 
  728:     if (!$intdom) {
  729:         foreach my $file (@hosts_files) {
  730:             open(IN,'&lt;'.$file);
  731:             while(my $line = &lt;IN&gt;) {
  732:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:https?\:([^:]+)/) {
  733:                     $intdom = $1;
  734:                     chomp($intdom);
  735:                     last;
  736:                 }
  737:             }
  738:         }
  739:     }
  740: 
  741:     while(!$primaryLibServer && (@hosts_files || @domain_files)) {
  742: 	my $file = shift(@domain_files);
  743:         open(IN,'&lt;'.$file);
  744:         while(my $line = &lt;IN&gt;) {
  745:             if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
  746: 		$primaryLibServer=(split(/:/,$line))[8];
  747:                 chomp($primaryLibServer);
  748:             }
  749:         }
  750:         close(IN);
  751: 	last if ($primaryLibServer);
  752: 	$file = shift(@hosts_files);
  753: 	open(IN,'&lt;'.$file);
  754: 	while(my $line = &lt;IN&gt;) {
  755: 	    if ($line =~ /^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
  756: 		push(@libservers,$1);
  757: 	    }
  758: 	}
  759: 	# make list unique
  760: 	@libservers = keys(%{{ map { $_ => 1 } (@libservers) }});
  761: 	close(IN);
  762: 	if (@libservers == 1) {
  763: 	    $primaryLibServer = $libservers[0];
  764: 	}
  765:     }
  766:    
  767: # implement editing logic below, interactively
  768: # update loncapa.conf until 14 is entered
  769: 
  770: my $flag=0;
  771: 
  772: while (!$flag) {
  773:   print(&lt;&lt;END);
  774: 
  775: ===============================================================================
  776: This is now the current configuration of your machine.
  777:  1) Domain Name: $perlvar{'lonDefDomain'}
  778:  2) Domain Description: $domainDescription
  779:  3) Machine Name: $perlvar{'lonHostID'}
  780:  4) ID of primary library server for domain: $primaryLibServer
  781:  5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  782:  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
  783:  7) Web Server Protocol (http or https): $protocol 
  784:  8) Internet Domain Name: $intdom 
  785:  9) Role: $perlvar{'lonRole'}
  786: 10) Cache Expiration Time: $perlvar{'lonExpire'}
  787: 11) Server Load: $perlvar{'lonLoadLim'}
  788: 12) User Load: $perlvar{'lonUserLoadLim'}
  789: 13) Allow only secure connections: $securestatus 
  790: 14) Everything is correct up above
  791: END
  792: 
  793: my @error;
  794: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
  795:    if (length($v)>35) { push(@error,"Name $v too long"); }		
  796:    if (length($v)<2) { push(@error,"Name $v too short"); }
  797:    if ($v=~/capa/i) {
  798: 	if ($v!~/^oucapa\d+$/ && 
  799: 	    ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
  800: 		 push(@error,"Name $v contains 'capa'");
  801: 	}
  802:    }
  803:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
  804: 	'editupload') {
  805:       push(@error,"\nName $v reserved.") if $v eq $bad;
  806:    }
  807:    if ($v=~/[^\w\-.]/) { push(@error,"Name $v contains special characters"); }
  808: }
  809: if ($domainDescription =~ /^\s*$/) {
  810:    push(@error,"Domain Description is blank.");
  811: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
  812:    push(@error,"Domain Description contains special characters.");
  813: } 
  814: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
  815:    unless ($v=~/^[\d+\.]+$/) { push(@error,"Number expected instead of $v"); }
  816: }
  817: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
  818:    push(@error,"Invalid Role");
  819: }
  820: 
  821: unless (($protocol eq 'http') || ($protocol eq 'https')) {
  822:    push(@error,"Invalid Protocol (must be http or https");
  823: }
  824: 
  825: if (!defined($intdom)) { 
  826:    push(@error,"No internet domain name designated. Enter something like ustate.edu"); 
  827: } elsif ($intdom !~ /[^.]+\.\w{2,6}$/) {
  828:    push(@error,"Invalid Internet domain name (must be at least two levels separated by .  - e.g., ustate.edu");
  829: }
  830: 
  831: if (!defined($primaryLibServer)) {
  832:    if (@libservers > 0) {
  833:        push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers)));
  834:    } else {
  835:        push(@error,"No library servers in this domain (including current server)");
  836:    }
  837: } else {
  838:    if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID:  $primaryLibServer too long"); }
  839:    if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID:  $primaryLibServer too short"); }
  840:    if ($primaryLibServer =~/capa/i) {
  841:         if ($primaryLibServer!~/^oucapa\d+$/ &&
  842:             ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
  843:                  push(@error,"Primary library server ID $primaryLibServer contains 'capa'")
  844:         }
  845:    }
  846:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
  847:         'editupload') {
  848:       push(@error,"Primary library server ID $primaryLibServer reserved.") if $primaryLibServer eq $bad;
  849:    }
  850:    if ($primaryLibServer=~/[^\w\-.]/) { push(@error,"Primary library server ID $primaryLibServer contains special characters"); }
  851: }
  852: 
  853: 
  854: if (@error) { print "\n*** ERRORS: \n\t".join("\n\t",@error)."\n"; }
  855:   print(&lt;&lt;END);
  856: ENTER A CHOICE OF 1-13 TO CHANGE, otherwise ENTER 14:
  857: END
  858: my $choice=&lt;&gt;;
  859: chomp($choice);
  860:   if ($choice==1) {
  861:   print(&lt;&lt;END);
  862: 1) Domain Name: $perlvar{'lonDefDomain'}
  863: ENTER NEW VALUE (this is an internal value used to identify a group of
  864:                  LON-CAPA machines, it must be alphanumerical, we suggest
  865:                  using a part of your actual DNS domain. For example, for
  866:                  the machine loncapa.msu.edu, we set the Domain to msu):
  867: END
  868:     my $choice2=&lt;&gt;;
  869:     chomp($choice2);
  870:     $perlvar{'lonDefDomain'}=$choice2;
  871:   }
  872:   elsif ($choice==2) {
  873:   print(&lt;&lt;END);
  874: 2) Domain Description: $domainDescription
  875: ENTER NEW VALUE (this should be a string that describes your domain, spaces
  876:                  and punctuation are fine except for ':'):
  877: END
  878:     my $choice2=&lt;&gt;;
  879:     chomp($choice2);
  880:     $domainDescription=$choice2;
  881:   }
  882:   elsif ($choice==3) {
  883:   print(&lt;&lt;END);
  884: 3) Machine Name: $perlvar{'lonHostID'}
  885: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
  886:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
  887:                  if you are in the domain 'example' and are the first library
  888:                  server you enter 'examplel1') :
  889: END
  890:     my $choice2=&lt;&gt;;
  891:     chomp($choice2);
  892:     $perlvar{'lonHostID'}=$choice2;
  893:   }
  894:   elsif ($choice==4) {
  895:   print(&lt;&lt;END);
  896: 4) ID of primary library server for domain: $primaryLibServer
  897: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
  898:                  your domain; it cannot contain any of '_' '-' '.' or ':'. 
  899:                  This server will be where domain data which are not 
  900:                  associated with any specific home library server
  901:                  will be stored (e.g., e-mail broadcast by Domain Coordinators
  902:                  to users in the domain).
  903: END
  904:     my $choice2=&lt;&gt;;
  905:     chomp($choice2);
  906:     $primaryLibServer=$choice2;
  907:   }
  908:   elsif ($choice==5) {
  909:   print(&lt;&lt;END);
  910: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  911: ENTER NEW VALUE:
  912: END
  913:     my $choice2=&lt;&gt;;
  914:     chomp($choice2);
  915:     $perlvar{'lonAdmEMail'}=$choice2;
  916:   }
  917:   elsif ($choice==6) {
  918:   print(&lt;&lt;END);
  919: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
  920: ENTER NEW VALUE:
  921: END
  922:     my $choice2=&lt;&gt;;
  923:     chomp($choice2);
  924:     $perlvar{'lonSupportEMail'}=$choice2;
  925:   }
  926:   elsif ($choice==7) {
  927:   print(&lt;&lt;END);
  928: 7) Server Protocol (http or https): 
  929: ENTER NEW VALUE: (this should be either 'http' or 'https'
  930:                  if in doubt set to 'http'):
  931: END
  932:     my $choice2=&lt;&gt;;
  933:     chomp($choice2);
  934:     $protocol=$choice2;
  935:   }
  936:   elsif ($choice==8) {
  937:   print(&lt;&lt;END);
  938: 8) Internet Domain Name of Institution
  939: ENTER NEW VALUE: 
  940: 
  941: END
  942:     my $choice2=&lt;&gt;;
  943:     chomp($choice2);
  944:     $intdom=$choice2;
  945:   }
  946:   elsif ($choice==9) {
  947:   print(&lt;&lt;END);
  948: 9) Role: $perlvar{'lonRole'}
  949: ENTER NEW VALUE (this should be either 'access' or 'library' 
  950:                  if in doubt select 'library'):
  951: END
  952:     my $choice2=&lt;&gt;;
  953:     chomp($choice2);
  954:     $perlvar{'lonRole'}=$choice2;
  955:   }
  956:   elsif ($choice==10) {
  957:   print(&lt;&lt;END);
  958: 10) Cache Expiration Time: $perlvar{'lonExpire'}
  959: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
  960: END
  961:     my $choice2=&lt;&gt;;
  962:     chomp($choice2);
  963:     $perlvar{'lonExpire'}=$choice2;
  964:   }
  965:   elsif ($choice==11) {
  966:   print(&lt;&lt;END);
  967: 11) Server Load: $perlvar{'lonLoadLim'}
  968: ENTER NEW VALUE:
  969: END
  970:     my $choice2=&lt;&gt;;
  971:     chomp($choice2);
  972:     $perlvar{'lonLoadLim'}=$choice2;
  973:   }
  974:   elsif ($choice==12) {
  975:   print(&lt;&lt;END);
  976: 12) User Load: $perlvar{'lonUserLoadLim'}
  977: Numer of users that can login before machine is 'overloaded'
  978: ENTER NEW VALUE (integer value, 0 means there is no limit):
  979: END
  980:     my $choice2=&lt;&gt;;
  981:     chomp($choice2);
  982:     $perlvar{'lonUserLoadLim'}=$choice2;
  983:   }
  984:   elsif ($choice==13) {
  985:   print(&lt;&lt;END);
  986: 13) Allow only secure connections: $securestatus 
  987: The Lon-CAPA communication daemons lonc and lond can be configured to
  988: allow only secure connections by default.
  989: 
  990: POSSIBLE CHOICES:
  991: 1) allow only secure connections and don't connect to machines that
  992:     can not be connected to securely
  993: 2) allow only secure connections but allow this machine to connect to 
  994:     machines that don't support secure connections
  995: 3) allow insecure connections to this machine but only allow connections
  996:     to machines that support secure connections
  997: 4) allow insecure connections
  998: ENTER NEW VALUE (currenly $securenum):
  999: END
 1000:     my $choice2=&lt;&gt;;
 1001:     chomp($choice2);
 1002:     if      ($choice2 eq '1') {
 1003: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
 1004:     } elsif ($choice2 eq '2') {
 1005: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
 1006:     } elsif ($choice2 eq '3') {
 1007: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
 1008:     } elsif ($choice2 eq '4') {
 1009: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
 1010:     }
 1011:     ($securestatus,$securenum)=&securesetting(%perlvar);
 1012:   }
 1013:   elsif (($choice==14) && (!@error)) {
 1014:     $flag=1;
 1015:   }
 1016:   else {
 1017:     print "Invalid input.\n";
 1018:   }
 1019: }
 1020:     open(OUT,"&gt;$confdir$filename") or
 1021:       die("Cannot output to $confdir$filename\n");
 1022:     foreach my $key (keys %perlvar) {
 1023:       my $value=$perlvar{$key};
 1024:       my $line = "PerlSetVar     $key      $value";
 1025:       if ($value eq '') {
 1026:           $line = '#'.$line;
 1027:       }
 1028:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
 1029: $line
 1030: END
 1031:     }
 1032:     close(OUT);
 1033: </perlscript>
 1034: </file>
 1035: <file>
 1036: <target dist='default'>loncom/hosts.tab</target>
 1037: <perlscript mode='fg'>
 1038: unless (-l "<TARGET />") {
 1039:   my $hostname=`hostname -f`;chomp($hostname);
 1040:   my $date=`date -I`; chomp($date);
 1041:   my $lonHostID=$perlvar{'lonHostID'};
 1042:   $lonHostID=~s/[^\w\-.]//g;
 1043:   my $lineexistflag=0;
 1044:   my $hostidexistflag=0;
 1045:   my $line2insert=&lt;&lt;END;
 1046: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$protocol:$intdom
 1047: END
 1048:   if (!$domainTabExtras) {
 1049: 	$domainTabExtras=':::::';
 1050:   }
 1051:   my $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
 1052:   if ($lonCluster eq 'standalone') {
 1053:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
 1054:       die('file generation error');
 1055:       print(OUT $line2insert);
 1056:       print OUT ("^$hostname:$protocol\n");
 1057:     close(OUT);
 1058:     open(OUT,'&gt;../'.$lonCluster.'_dns_hosts.tab') or
 1059:       die('file generation error');
 1060:       print(OUT $line2insert);
 1061:     close(OUT);
 1062:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
 1063:       die('file generation error');
 1064:       print(OUT $domaininsert);
 1065:     close(OUT);
 1066:     open(OUT,'&gt;../'.$lonCluster.'_dns_domain.tab') or
 1067:       die('file generation error');
 1068:       print(OUT $domaininsert);
 1069:     close(OUT);
 1070:   }
 1071:   if ($flag==1) {
 1072:     `rm -f ../hosts.tab`;
 1073:     `rm -f ../dns_hosts.tab`;
 1074:     `ln -s ${lonCluster}_dns_hosts.tab ../dns_hosts.tab`;
 1075:     open(IN,'&lt;../'.$lonCluster.'_dns_hosts.tab');
 1076:     while(my $line = &lt;IN&gt;) {
 1077:       if ($line =~ /^\Q$line2insert\E$/) {
 1078:         $lineexistflag=1;
 1079:       }
 1080:       if ($line =~ /^\Q$lonHostID\E\:/) {
 1081:         $hostidexistflag=1;
 1082:       }
 1083:     }
 1084:     close(IN);
 1085:     if ($hostidexistflag and !$lineexistflag) {
 1086:       print &lt;&lt;END;
 1087: WARNING: $lonHostID already exists inside
 1088: loncapa/loncom/${lonCluster}_dns_hosts.tab.  The entry inside
 1089: ${lonCluster}_dns_hosts.tab does not match your settings.
 1090: An entry inside ${lonCluster}_hosts.tab will be made
 1091: with your new values.
 1092: END
 1093:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
 1094:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
 1095:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
 1096:          print(OUT $line2insert);
 1097:        close(OUT);
 1098:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
 1099:       # email appropriate message
 1100:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1101:     }
 1102:     elsif ($hostidexistflag and $lineexistflag) {
 1103:       print &lt;&lt;END;
 1104: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
 1105: END
 1106:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
 1107:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
 1108:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
 1109:          print(OUT $line2insert);
 1110:        close(OUT);
 1111:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
 1112:       # email appropriate message
 1113:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1114:     }
 1115:     elsif (!$hostidexistflag and !$lineexistflag) {
 1116:       print &lt;&lt;END;
 1117: New entry for $lonCluster.
 1118: END
 1119:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
 1120:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
 1121:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
 1122:          print(OUT $line2insert);
 1123:        close(OUT);
 1124:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
 1125:       # email appropriate message
 1126:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1127:     }
 1128:   }
 1129:   $lineexistflag=0;
 1130:   my $domainexistflag=0;
 1131:   if ($flag==1) {
 1132:     `rm -f ../domain.tab`;
 1133:     `rm -f ../dns_domain.tab`;
 1134:     `ln -s ${lonCluster}_dns_domain.tab ../dns_domain.tab`;
 1135:     open(IN,'&lt;../'.$lonCluster.'_dns_domain.tab');
 1136:     while(my $line = &lt;IN&gt;) {
 1137:       if ($line =~/^\Q$domaininsert\E$/) {
 1138:         $lineexistflag=1;
 1139:       }
 1140:       if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
 1141:         $domainexistflag=1;
 1142:       }
 1143:     }
 1144:     close(IN);
 1145:     if ($domainexistflag and !$lineexistflag) {
 1146:       print &lt;&lt;END;
 1147: WARNING: $perlvar{'lonDefDomain'} already exists inside
 1148: loncapa/loncom/${lonCluster}_dns_domain.tab.  The entry inside
 1149: ${lonCluster}_dns_domain.tab does not match your settings.
 1150: An entry will be made in inside ${lonCluster}_domain.tab
 1151: with your new values.
 1152: END
 1153:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
 1154:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
 1155:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
 1156:          print(OUT $domaininsert);
 1157:        close(OUT);
 1158:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
 1159:       # email appropriate message
 1160:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
 1161:     }
 1162:     elsif ($domainexistflag and $lineexistflag) {
 1163:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
 1164:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
 1165:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
 1166:          print(OUT $domaininsert);
 1167:        close(OUT);
 1168:       print &lt;&lt;END;
 1169: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
 1170: END
 1171:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
 1172:       # email appropriate message
 1173:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
 1174:     }
 1175:     elsif (!$domainexistflag and !$lineexistflag) {
 1176:       print &lt;&lt;END;
 1177: New entry for $lonCluster.
 1178: END
 1179:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
 1180:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
 1181:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
 1182:          print(OUT $domaininsert);
 1183:        close(OUT);
 1184:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
 1185:       # email appropriate message
 1186:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
 1187:     }
 1188:   }
 1189: }
 1190: </perlscript>
 1191: </file>
 1192: </files>
 1193: </piml>

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