File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.20: download - view: text, annotated - select for diffs
Mon Dec 9 18:37:15 2002 UTC (21 years, 4 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- attempting to fix BUG#1034, still doesn't pick up old values from existing hosts.tab files
- doesn't actually set the value

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

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