Annotation of doc/loncapafiles/updatequery.piml, revision 1.17

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

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