File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.30: download - view: text, annotated - select for diffs
Fri May 21 20:40:53 2004 UTC (19 years, 11 months ago) by www
Branches: MAIN
CVS tags: HEAD
Bug #3028: hopefully clearer explanation of the cluster options

    1: <!-- updatequery.piml -->
    2: 
    3: <!-- $Id: updatequery.piml,v 1.30 2004/05/21 20:40:53 www 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:   print(&lt;&lt;END);
   37: 
   38: 
   39: *********************************************
   40: *********************************************
   41: ****                                     ****
   42: **** LON-CAPA SYSTEM INFORMATION REQUEST ****
   43: ****                                     ****
   44: **** Please respond to the choices below ****
   45: ****                                     ****
   46: *********************************************
   47: *********************************************
   48: 
   49: END
   50: sleep(3);
   51: </perlscript>
   52: </file>
   53: <file>
   54: <target dist='default'>loncom/hosts.tab</target>
   55: <perlscript mode='fg'>
   56: unless (-l "<TARGET />") {
   57:   print(&lt;&lt;END);
   58: 
   59: ===============================================================================
   60: Which cluster option would you like to have installed?
   61: IMPORTANT: to take advantage of the cluster options 1) and 3),
   62: you must contact lon-capa\@lon-capa.org.
   63: 
   64: 1) PRODUCTION - you want to eventually connect this machine to the
   65:                 LON-CAPA content sharing network. This setting is for
   66:                 schools, colleges, and universities, that currently
   67:                 are running - or in the future will run - courses
   68: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
   69:                  not be connected to other LON-CAPA machines for now
   70: 3) DEVELOPMENT - you want to do software (not content!) development with
   71:                  this workstation and eventually link it with the
   72:                  workstations of other LON-CAPA software developers.
   73: 4) PRESERVE the existing hosts.tab and domain.tab
   74:                 (/home/httpd/lonTabs/hosts.tab and
   75:                  /home/httpd/lonTabs/domain.tab)
   76: 
   77: END
   78: # Option number 26 will install rawhide_hosts.tab, but
   79: # the typical user does not want to be part of an intensive
   80: # machine test cluster.
   81: 
   82: # get input
   83: # if valid then process, otherwise loop
   84: $flag=0;
   85: while (!$flag) {
   86:   print "ENTER 1, 2, 3, or 4:\n";
   87:   my $choice=&lt;&gt;;
   88:   chomp($choice);
   89:   if ($choice==1) {
   90:     $lonCluster='production'; $flag=1;
   91:   }
   92:   elsif ($choice==2) {
   93:     $lonCluster='standalone'; $flag=1;
   94:   }
   95:   elsif ($choice==3) {
   96:     $lonCluster='development'; $flag=1;
   97:   }
   98:   elsif ($choice==4) {
   99:     $lonCluster='existing'; $flag=1;
  100:     if (-e '/home/httpd/lonTabs/hosts.tab') {
  101:       `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
  102:     }
  103:     else {
  104:       print &lt;&lt;END;
  105: There is no existing /home/httpd/lonTabs/hosts.tab
  106: END
  107:       die('');
  108:     }
  109:     if (-e '/home/httpd/lonTabs/domain.tab') {
  110:       `cp /home/httpd/lonTabs/domain.tab ../existing_domain.tab`;
  111:     }
  112:     else {
  113:       print &lt;&lt;END;
  114: There is no existing /home/httpd/lonTabs/domain.tab
  115: END
  116:       die('');
  117:     }
  118:   }
  119:   elsif ($choice==26) {
  120:     $lonCluster='rawhide'; $flag=1;
  121:   }
  122: }
  123: }
  124: </perlscript>
  125: </file>
  126: <file>
  127: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  128: <perlscript mode='fg'>
  129: $|=1;
  130: my $domainDescription;
  131: my $domainTabExtras;
  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 sharrison\@mail.lon-capa.org.
  138: 
  139: ===============================================================================
  140: The following 4 values are needed to configure LON-CAPA:
  141: * Machine Role
  142: * LON-CAPA Domain Name
  143: * LON-CAPA Machine ID Name, and
  144: * System Administration E-mail Address.
  145: END
  146: 
  147: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
  148: close(OUT);
  149: 
  150: # query for Machine Role
  151:   print(&lt;&lt;END);
  152: **** Machine Role ****
  153: Library server (recommended if first-time installation of LON-CAPA):
  154:    Servers that are repositories of authoritative educational resources.
  155:    These servers also provide the construction space by which instructors
  156:    assemble their classroom online material.
  157: Access server:
  158:    Servers that load-balance high-traffic delivery of educational resources
  159:    over the world-wide web.
  160: 1) Will this be a library server? (recommended if this is your first install)
  161: 2) Or, will this be an access server?
  162: END
  163: my $flag=0;
  164: my $r='';
  165: my $lonRole;
  166: while (!$flag) {
  167:   print "ENTER A CHOICE OF 1 or 2:\n";
  168:   my $choice=&lt;&gt;;
  169:   chomp($choice);
  170:   if ($choice==1) {
  171:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  172:     print(OUT 'lonRole'."\t".'library'."\n");
  173:     close(OUT);
  174:     $lonRole='library';
  175:     $r='l';
  176:     $flag=1;
  177:   }
  178:   elsif ($choice==2) {
  179:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  180:     print(OUT 'lonRole'."\t".'access'."\n");
  181:     close(OUT);
  182:     $lonRole='access';
  183:     $r='a';
  184:     $flag=2;
  185:   }
  186:   else {
  187: 
  188:   }
  189: }
  190: 
  191: # need to recommend a machine ID name (ipdomain.l.somenumber)
  192: my $hostname=`hostname`; chomp($hostname);
  193: my $ipdomain='';
  194: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
  195:   $ipdomain=$1;
  196: }
  197: 
  198:   print(&lt;&lt;END);
  199: 
  200: **** Domain ****
  201: [this does NOT need to correspond to internet address domains,
  202:  examples might be "msu" or "bionet" or "vermontcc"]
  203: END
  204: 
  205: # get domain name
  206: # accept if valid, if not valid, tell user and repeat
  207: $flag=0;
  208: my $lonDefDomain;
  209: while (!$flag) {
  210: if ($ipdomain) {
  211: print(&lt;&lt;END);
  212: ENTER LONCAPA DOMAIN [$ipdomain]:
  213: END
  214: }
  215: else {
  216:   print(&lt;&lt;END);
  217: ENTER LONCAPA DOMAIN:
  218: END
  219: }
  220:   my $choice=&lt;&gt;;
  221:   chomp($choice);
  222:   my $bad_domain_flag=0;
  223:   my @bad_domain_names=('raw','userfiles','priv','adm','uploaded');
  224:   foreach my $bad (@bad_domain_names) {
  225:     $bad_domain_flag=1 if $choice eq $bad;
  226:   }
  227:   if ($ipdomain and $choice=~/^\s*$/) {
  228:     $choice=$ipdomain;
  229:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  230:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  231:     close(OUT);
  232:     $lonDefDomain=$choice;
  233:     $flag=1;
  234:   }
  235:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
  236:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  237:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  238:     close(OUT);
  239:     $lonDefDomain=$choice;
  240:     $r='l';
  241:     $flag=1;
  242:   }
  243:   elsif ($bad_domain_flag) {
  244:     print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
  245:     print "Please try something different than '$choice'\n";
  246:   }
  247:   else {
  248:     print "Invalid input (only alphanumeric characters supported).\n";
  249:   }
  250: }
  251: 
  252: 
  253: # get domain description
  254: # accept if valid, if not valid, tell user and repeat
  255: $flag=0;
  256: 
  257: while (!$flag) {
  258:   print(&lt;&lt;END);
  259: 
  260: **** Domain Description ****
  261: String describing the domain, to be shown to users.
  262: [Example, msu is Michigan State University]
  263: ENTER DOMAIN DESCRIPTION:
  264: END
  265: 
  266:   my $choice=&lt;&gt;;
  267:   chomp($choice);
  268:   if ($choice!~/:/) {
  269:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  270:     print(OUT 'domainDescription'."\t".$choice."\n");
  271:     close(OUT);
  272:     $domainDescription=$choice;
  273:     $flag=1;
  274:   }
  275:   else {
  276:     print "Invalid input (no ':' allowed).\n";
  277:   }
  278: }
  279: 
  280: my $lonHostID;
  281: if ($lonDefDomain) {
  282:   $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
  283:                                               # against the hosts.tab
  284: }
  285: 
  286:   print(&lt;&lt;END);
  287: 
  288: **** Machine ID Name ****
  289: [this does NOT need to correspond to internet address names;
  290:  this name MUST be unique to the whole LON-CAPA network;
  291:  we recommend that you use a name based off of your institution;
  292:  good examples: "msul1" or "bionetl1";
  293:  bad examples: "loncapabox" or "studentsinside"]
  294: END
  295: # get machine name
  296: # accept if valid, if not valid, tell user and repeat
  297: $flag=0;
  298: while (!$flag) {
  299: if ($ipdomain) {
  300: print(&lt;&lt;END);
  301: ENTER LONCAPA MACHINE ID [$lonHostID]:
  302: END
  303: }
  304: else {
  305:   print(&lt;&lt;END);
  306: ENTER LONCAPA MACHINE ID:
  307: END
  308: }
  309:   my $choice=&lt;&gt;;
  310:   chomp($choice);
  311:   if ($lonHostID and $choice=~/^\s*$/) {
  312:     $choice=$lonHostID;
  313:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  314:     print(OUT 'lonHostID'."\t".$choice."\n");
  315:     close(OUT);
  316:     $lonHostID=$choice;
  317:     $flag=1;
  318:   }
  319:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
  320:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  321:     print(OUT 'lonHostID'."\t".$choice."\n");
  322:     close(OUT);
  323:     $lonHostID=$choice;
  324:     $flag=1;
  325:   }
  326:   else {
  327:     print "Invalid input (only alphanumeric characters supported).\n";
  328:   }
  329: }
  330: 
  331: # get e-mail address
  332: # accept if valid, if not valid, tell user and repeat
  333: $flag=0;
  334: my $lonAdmEMail;
  335: while (!$flag) {
  336:   print(&lt;&lt;END);
  337: 
  338: **** System Administrator's E-mail ****
  339: E-mail address of the person who will manage this machine
  340: [should be in the form somebody\@somewhere]
  341: ENTER E-MAIL ADDRESS:
  342: END
  343: 
  344:   my $choice=&lt;&gt;;
  345:   chomp($choice);
  346:   if ($choice=~/\@/) {
  347:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  348:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
  349:     close(OUT);
  350:     $lonAdmEMail=$choice;
  351:     $flag=1;
  352:   }
  353:   else {
  354:     print "Invalid input (this needs to look like an e-mail address!).\n";
  355:   }
  356: }
  357: 
  358: # update loncapa.conf
  359: my $confdir='/etc/httpd/conf/';
  360: #my $confdir='';
  361: my $filename='loncapa.conf';
  362: my %perlvar;
  363:     if (-e "$confdir$filename") {
  364: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
  365: 	while (my $configline=&lt;CONFIG&gt;) {
  366: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  367: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  368: 		chomp($varvalue);
  369: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
  370: 	    }
  371: 	}
  372: 	close(CONFIG);
  373:     }
  374:     $perlvar{'lonHostID'}=$lonHostID;
  375:     $perlvar{'lonDefDomain'}=$lonDefDomain;
  376:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
  377:     $perlvar{'lonRole'}=$lonRole;
  378:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  379:        $perlvar{'lonLoadLim'}='2.00';
  380:     }
  381:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  382:        $perlvar{'lonUserLoadLim'}='0';
  383:     }
  384:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  385:        $perlvar{'lonExpire'}='86400';
  386:     }
  387:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  388:        my $lonReceipt='';
  389:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  390:        my @alnum=(0..9,a..z);
  391:        foreach my $i (1..20) {
  392: 	 $lonReceipt.=$alnum[int(rand(36))];
  393:        }
  394:        $perlvar{'lonReceipt'}=$lonReceipt;
  395:     }
  396:     open(OUT,"&gt;$confdir$filename") or
  397:       die("Cannot output to $confdir$filename\n");
  398:     foreach my $key (keys %perlvar) {
  399:       my $value=$perlvar{$key};
  400:       print(OUT &lt;&lt;END);
  401: PerlSetVar     $key      $value
  402: END
  403:     }
  404:     close(OUT);
  405: }
  406: </perlscript>
  407: </file>
  408: <file>
  409: <target dist='default'>/</target>
  410: <perlscript mode='fg'>
  411: # read values from loncapa.conf
  412: my $confdir='/etc/httpd/conf/';
  413: my $filename='loncapa.conf';
  414: my %perlvar;
  415:     if (-e "$confdir$filename") {
  416: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
  417:           die("Can't read $confdir$filename");
  418: 	while (my $configline=&lt;CONFIG&gt;) {
  419: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  420: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  421: 		chomp($varvalue);
  422: 		$perlvar{$varname}=$varvalue;
  423: 	    }
  424: 	}
  425: 	close(CONFIG);
  426:     }
  427:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  428:        $perlvar{'lonLoadLim'}='2.00';
  429:     }
  430:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  431:        $perlvar{'lonUserLoadLim'}='0';
  432:     }
  433:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  434:        $perlvar{'lonExpire'}='86400';
  435:     }
  436:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  437:        my $lonReceipt='';
  438:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  439:        my @alnum=(0..9,a..z);
  440:        foreach my $i (1..20) {
  441: 	 $lonReceipt.=$alnum[int(rand(36))];
  442:        }
  443:        $perlvar{'lonReceipt'}=$lonReceipt;
  444:     }
  445: my %perlvarstatic;
  446:     if (-e "${confdir}loncapa_apache.conf") {
  447: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
  448:           die("Can't read ${confdir}loncapa_apache.conf");
  449: 	while (my $configline=&lt;CONFIG&gt;) {
  450: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
  451: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
  452: 		chomp($varvalue);
  453: 		$perlvarstatic{$varname}=$varvalue;
  454: 	    }
  455: 	}
  456: 	close(CONFIG);
  457:     }
  458:     if (!$domainDescription && $lonCluster ne 'existing') {
  459:        open(IN,'&lt;../'.$lonCluster.'_domain.tab');
  460:        while(&lt;IN&gt;) {
  461:           if (/^$perlvar{'lonDefDomain'}\:/) {
  462: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
  463: 	     chomp($domainDescription);
  464: 	     chomp($domainTabExtras);
  465:              last;
  466:           }
  467:        }
  468:        close(IN);
  469:     }
  470:     if (!$domainDescription) {
  471:        open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
  472:        while(&lt;IN&gt;) {
  473:           if (/^$perlvar{'lonDefDomain'}\:/) {
  474: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
  475: 	     chomp($domainDescription);
  476: 	     chomp($domainTabExtras);
  477:              last;
  478:           }
  479:        }
  480:        close(IN);
  481:     }
  482:    
  483: # implement editing logic below, interactively
  484: # update loncapa.conf until 8 is entered
  485: 
  486: $flag=0;
  487: 
  488: while (!$flag) {
  489:   print(&lt;&lt;END);
  490: 
  491: ===============================================================================
  492: This is now the current configuration of your machine.
  493: 1) Domain Name: $perlvar{'lonDefDomain'}
  494: 2) Domain Description: $domainDescription
  495: 3) Machine Name: $perlvar{'lonHostID'}
  496: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  497: 5) Role: $perlvar{'lonRole'}
  498: 6) Cache Expiration Time: $perlvar{'lonExpire'}
  499: 7) Server Load: $perlvar{'lonLoadLim'}
  500: 8) User Load: $perlvar{'lonUserLoadLim'}
  501: 9) Everything is correct up above
  502: END
  503: my $hbug=-1;
  504: my $dbug=-1;
  505: {
  506:   my $v=$perlvar{'lonHostID'};
  507:   $hbug=0;
  508:   $hbug=1 if $v=~/\W/;
  509:   $hbug=1 if $v=~/\_/;
  510: }
  511: {
  512:   my $v=$1;
  513:   $dbug=0;
  514:   $dbug=1 if $v=~/\W/;
  515:   $dbug=1 if $v=~/\_/;
  516: }
  517: 
  518: if ($hbug) {
  519:   print "**** ERROR **** ".
  520: 	"Invalid lonHostID (should only be letters and/or digits)\n";
  521: }
  522: if ($dbug) {
  523:   print "**** ERROR **** ".
  524: 	"Invalid lonDefDomain (should only be letters and/or digits)\n";
  525: }
  526: 
  527:   print(&lt;&lt;END);
  528: ENTER A CHOICE OF 1-8 TO CHANGE, otherwise ENTER 9:
  529: END
  530: my $choice=&lt;&gt;;
  531: chomp($choice);
  532:   if ($choice==1) {
  533:   print(&lt;&lt;END);
  534: 1) Domain Name: $perlvar{'lonDefDomain'}
  535: ENTER NEW VALUE (this is an internal value used to identify a group of
  536:                  LON-CAPA machines, it must be alphanumerical, we suggest
  537:                  using a part of your actual DNS domain. For example, for
  538:                  the machine loncapa.msu.edu, we set the Domain to msu):
  539: END
  540:     my $choice2=&lt;&gt;;
  541:     chomp($choice2);
  542:     $perlvar{'lonDefDomain'}=$choice2;
  543:   }
  544:   elsif ($choice==2) {
  545:   print(&lt;&lt;END);
  546: 2) Domain Description: $domainDescription
  547: ENTER NEW VALUE (this should be a string that describes your domain, spaces
  548:                  and punctuation are fine except for ':'):
  549: END
  550:     my $choice2=&lt;&gt;;
  551:     chomp($choice2);
  552:     $domainDescription=$choice2;
  553:   }
  554:   elsif ($choice==3) {
  555:   print(&lt;&lt;END);
  556: 3) Machine Name: $perlvar{'lonHostID'}
  557: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
  558:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
  559:                  if you are in the domain 'example' and are the first library
  560:                  server you enter 'examplel1') :
  561: END
  562:     my $choice2=&lt;&gt;;
  563:     chomp($choice2);
  564:     $perlvar{'lonHostID'}=$choice2;
  565:   }
  566:   elsif ($choice==4) {
  567:   print(&lt;&lt;END);
  568: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  569: ENTER NEW VALUE:
  570: END
  571:     my $choice2=&lt;&gt;;
  572:     chomp($choice2);
  573:     $perlvar{'lonAdmEMail'}=$choice2;
  574:   }
  575:   elsif ($choice==5) {
  576:   print(&lt;&lt;END);
  577: 5) Role: $perlvar{'lonRole'}
  578: ENTER NEW VALUE (this should be either 'access' or 'library' 
  579:                  if in doubt select 'library'):
  580: END
  581:     my $choice2=&lt;&gt;;
  582:     chomp($choice2);
  583:     $perlvar{'lonRole'}=$choice2;
  584:   }
  585:   elsif ($choice==6) {
  586:   print(&lt;&lt;END);
  587: 6) Cache Expiration Time: $perlvar{'lonExpire'}
  588: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
  589: END
  590:     my $choice2=&lt;&gt;;
  591:     chomp($choice2);
  592:     $perlvar{'lonExpire'}=$choice2;
  593:   }
  594:   elsif ($choice==7) {
  595:   print(&lt;&lt;END);
  596: 7) Server Load: $perlvar{'lonLoadLim'}
  597: ENTER NEW VALUE:
  598: END
  599:     my $choice2=&lt;&gt;;
  600:     chomp($choice2);
  601:     $perlvar{'lonLoadLim'}=$choice2;
  602:   }
  603:   elsif ($choice==8) {
  604:   print(&lt;&lt;END);
  605: 8) User Load: $perlvar{'lonUserLoadLim'}
  606: Numer of users that can login before machine is 'overloaded'
  607: ENTER NEW VALUE (integer value, 0 means there is no limit):
  608: END
  609:     my $choice2=&lt;&gt;;
  610:     chomp($choice2);
  611:     $perlvar{'lonUserLoadLim'}=$choice2;
  612:   }
  613:   elsif ($choice==9) {
  614:     $flag=1;
  615:   }
  616:   else {
  617: 
  618:   }
  619: }
  620:     open(OUT,"&gt;$confdir$filename") or
  621:       die("Cannot output to $confdir$filename\n");
  622:     foreach my $key (keys %perlvar) {
  623:       my $value=$perlvar{$key};
  624:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
  625: PerlSetVar     $key      $value
  626: END
  627:     }
  628:     close(OUT);
  629: </perlscript>
  630: </file>
  631: <file>
  632: <target dist='default'>loncom/hosts.tab</target>
  633: <perlscript mode='fg'>
  634: unless (-l "<TARGET />") {
  635:   my $hostname=`hostname`;chomp($hostname);
  636:   my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
  637:   $hostaddress=~s/\s//;
  638:   $date=`date -I`; chomp($date);
  639:   $lonHostID=$perlvar{'lonHostID'};
  640:   $lonHostID=~s/\W//g;
  641:   $lineexistflag=0;
  642:   $hostidexistflag=0;
  643:   $line2insert=&lt;&lt;END;
  644: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
  645: END
  646:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
  647:   if ($lonCluster eq 'standalone') {
  648:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
  649:       die('file generation error');
  650:       print(OUT $line2insert);
  651:     close(OUT);
  652:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
  653:       die('file generation error');
  654:       print(OUT $domaininsert);
  655:     close(OUT);
  656:   }
  657:   if ($flag==1) {
  658:     `rm -f ../hosts.tab`;
  659:     open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
  660:     while(&lt;IN&gt;) {
  661:       if (/^$line2insert$/) {
  662:         $lineexistflag=1;
  663:       }
  664:       if (/^$lonHostID\:/) {
  665:         $hostidexistflag=1;
  666:       }
  667:     }
  668:     close(IN);
  669:     if ($hostidexistflag and !$lineexistflag) {
  670:       print &lt;&lt;END;
  671: WARNING: $lonHostID already exists inside
  672: loncapa/loncom/${lonCluster}_hosts.tab.  The entry inside
  673: ${lonCluster}_hosts.tab does not match your settings.
  674: The entry inside ${lonCluster}_hosts.tab is being replaced
  675: with your new values.
  676: END
  677:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
  678:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
  679:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
  680:          print(OUT $line2insert);
  681:        close(OUT);
  682:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
  683:       # email appropriate message
  684:       system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
  685:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
  686:     }
  687:     elsif ($hostidexistflag and $lineexistflag) {
  688:       print &lt;&lt;END;
  689: Entry exists in ${lonCluster}_hosts.tab.
  690: END
  691:       `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
  692:       # email appropriate message
  693:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  694:     }
  695:     elsif (!$hostidexistflag and !$lineexistflag) {
  696:       print &lt;&lt;END;
  697: New entry for $lonCluster.
  698: END
  699:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
  700:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
  701:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
  702:          print(OUT $line2insert);
  703:        close(OUT);
  704:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
  705:       # email appropriate message
  706:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  707:     }
  708:   }
  709:   $lineexistflag=0;
  710:   if ($flag==1) {
  711:     `rm -f ../domain.tab`;
  712:     open(IN,'&lt;../'.$lonCluster.'_domain.tab');
  713:     while(&lt;IN&gt;) {
  714:       if (/^$domaininsert$/) {
  715:         $lineexistflag=1;
  716:       }
  717:       if (/^$perlvar{'lonDefDomain'}\:/) {
  718:         $domainexistflag=1;
  719:       }
  720:     }
  721:     close(IN);
  722:     if ($domainexistflag and !$lineexistflag) {
  723:       print &lt;&lt;END;
  724: WARNING: $perlvar{'lonDefDomain'} already exists inside
  725: loncapa/loncom/${lonCluster}_domain.tab.  The entry inside
  726: ${lonCluster}_domain.tab does not match your settings.
  727: The entry inside ${lonCluster}_domain.tab is being replaced
  728: with your new values.
  729: END
  730:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
  731:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
  732:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
  733:          print(OUT $domaininsert);
  734:        close(OUT);
  735:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
  736:       # email appropriate message
  737:       system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
  738:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
  739:     }
  740:     elsif ($domainexistflag and $lineexistflag) {
  741:       print &lt;&lt;END;
  742: Entry exists in ${lonCluster}_domain.tab.
  743: END
  744:       `ln -s ${lonCluster}_domain.tab ../domain.tab`;
  745:       # email appropriate message
  746:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  747:     }
  748:     elsif (!$domainexistflag and !$lineexistflag) {
  749:       print &lt;&lt;END;
  750: New entry for $lonCluster.
  751: END
  752:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
  753:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
  754:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
  755:          print(OUT $domaininsert);
  756:        close(OUT);
  757:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
  758:       # email appropriate message
  759:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  760:     }
  761:   }
  762: }
  763: </perlscript>
  764: </file>
  765: </files>
  766: </piml>

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