File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.26: download - view: text, annotated - select for diffs
Thu May 8 22:17:33 2003 UTC (21 years ago) by albertel
Branches: MAIN
CVS tags: HEAD
- typo

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

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