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

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

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