File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.28: download - view: text, annotated - select for diffs
Fri Aug 29 18:54:52 2003 UTC (20 years, 8 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- fixes BUG#2088, pings would wait for a really long time sometimes

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

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