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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.24    ! harris41    3: <!-- $Id: updatequery.piml,v 1.23 2002/12/09 21:27:36 albertel Exp $ -->
1.1       harris41    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>
1.4       harris41   33: <target dist='default'>/</target>
1.1       harris41   34: <perlscript mode='fg'>
1.4       harris41   35: $|=1;
1.1       harris41   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
1.4       harris41   50: sleep(3);
1.1       harris41   51: </perlscript>
                     52: </file>
                     53: <file>
1.22      albertel   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>
1.10      harris41  113: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1       harris41  114: <perlscript mode='fg'>
1.4       harris41  115: $|=1;
1.20      albertel  116: my $domainDescription;
1.1       harris41  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
1.5       harris41  122: or contact sharrison\@mail.lon-capa.org.
1.1       harris41  123: 
                    124: ===============================================================================
1.4       harris41  125: The following 4 values are needed to configure LON-CAPA:
                    126: * Machine Role
1.8       harris41  127: * LON-CAPA Domain Name
                    128: * LON-CAPA Machine ID Name, and
1.1       harris41  129: * System Administration E-mail Address.
                    130: END
1.3       harris41  131: 
1.4       harris41  132: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
                    133: close(OUT);
                    134: 
1.3       harris41  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.
1.4       harris41  145: 1) Will this be a library server? (recommended if this is your first install)
1.3       harris41  146: 2) Or, will this be an access server?
                    147: END
1.4       harris41  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: }
1.3       harris41  175: 
                    176: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.4       harris41  177: my $hostname=`hostname`; chomp($hostname);
                    178: my $ipdomain='';
                    179: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
                    180:   $ipdomain=$1;
                    181: }
1.1       harris41  182: 
                    183:   print(&lt;&lt;END);
                    184: 
1.8       harris41  185: **** Domain ****
                    186: [this does NOT need to correspond to internet address domains,
                    187:  examples might be "msu" or "bionet" or "vermontcc"]
1.1       harris41  188: END
1.8       harris41  189: 
                    190: # get domain name
1.1       harris41  191: # accept if valid, if not valid, tell user and repeat
1.4       harris41  192: $flag=0;
1.8       harris41  193: my $lonDefDomain;
1.4       harris41  194: while (!$flag) {
                    195: if ($ipdomain) {
                    196: print(&lt;&lt;END);
1.8       harris41  197: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4       harris41  198: END
                    199: }
                    200: else {
                    201:   print(&lt;&lt;END);
1.8       harris41  202: ENTER LONCAPA DOMAIN:
1.4       harris41  203: END
                    204: }
                    205:   my $choice=&lt;&gt;;
                    206:   chomp($choice);
1.18      harris41  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:   }
1.8       harris41  212:   if ($ipdomain and $choice=~/^\s*$/) {
                    213:     $choice=$ipdomain;
1.4       harris41  214:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  215:     print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4       harris41  216:     close(OUT);
1.8       harris41  217:     $lonDefDomain=$choice;
1.4       harris41  218:     $flag=1;
                    219:   }
                    220:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    221:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  222:     print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4       harris41  223:     close(OUT);
1.8       harris41  224:     $lonDefDomain=$choice;
                    225:     $r='l';
1.4       harris41  226:     $flag=1;
1.18      harris41  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";
1.4       harris41  231:   }
                    232:   else {
                    233:     print "Invalid input (only alphanumeric characters supported).\n";
                    234:   }
                    235: }
1.1       harris41  236: 
1.20      albertel  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: 
1.8       harris41  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: 
1.1       harris41  271:   print(&lt;&lt;END);
                    272: 
1.8       harris41  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"]
1.1       harris41  279: END
1.8       harris41  280: # get machine name
1.1       harris41  281: # accept if valid, if not valid, tell user and repeat
1.4       harris41  282: $flag=0;
                    283: while (!$flag) {
                    284: if ($ipdomain) {
                    285: print(&lt;&lt;END);
1.8       harris41  286: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4       harris41  287: END
                    288: }
                    289: else {
                    290:   print(&lt;&lt;END);
1.8       harris41  291: ENTER LONCAPA MACHINE ID:
1.4       harris41  292: END
                    293: }
                    294:   my $choice=&lt;&gt;;
                    295:   chomp($choice);
1.8       harris41  296:   if ($lonHostID and $choice=~/^\s*$/) {
                    297:     $choice=$lonHostID;
1.4       harris41  298:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  299:     print(OUT 'lonHostID'."\t".$choice."\n");
1.4       harris41  300:     close(OUT);
1.8       harris41  301:     $lonHostID=$choice;
1.4       harris41  302:     $flag=1;
                    303:   }
                    304:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    305:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  306:     print(OUT 'lonHostID'."\t".$choice."\n");
1.4       harris41  307:     close(OUT);
1.8       harris41  308:     $lonHostID=$choice;
1.4       harris41  309:     $flag=1;
                    310:   }
                    311:   else {
                    312:     print "Invalid input (only alphanumeric characters supported).\n";
                    313:   }
                    314: }
1.1       harris41  315: 
1.4       harris41  316: # get e-mail address
                    317: # accept if valid, if not valid, tell user and repeat
                    318: $flag=0;
1.9       harris41  319: my $lonAdmEMail;
1.4       harris41  320: while (!$flag) {
1.1       harris41  321:   print(&lt;&lt;END);
                    322: 
                    323: **** System Administrator's E-mail ****
                    324: E-mail address of the person who will manage this machine
1.4       harris41  325: [should be in the form somebody\@somewhere]
1.1       harris41  326: ENTER E-MAIL ADDRESS:
                    327: END
                    328: 
1.4       harris41  329:   my $choice=&lt;&gt;;
                    330:   chomp($choice);
                    331:   if ($choice=~/\@/) {
                    332:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.9       harris41  333:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4       harris41  334:     close(OUT);
1.9       harris41  335:     $lonAdmEMail=$choice;
1.4       harris41  336:     $flag=1;
                    337:   }
                    338:   else {
                    339:     print "Invalid input (this needs to look like an e-mail address!).\n";
                    340:   }
                    341: }
                    342: 
1.1       harris41  343: # update loncapa.conf
1.7       harris41  344: my $confdir='/etc/httpd/conf/';
                    345: #my $confdir='';
1.5       harris41  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);
1.12      harris41  354: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5       harris41  355: 	    }
                    356: 	}
                    357: 	close(CONFIG);
                    358:     }
                    359:     $perlvar{'lonHostID'}=$lonHostID;
                    360:     $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9       harris41  361:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.5       harris41  362:     $perlvar{'lonRole'}=$lonRole;
1.16      harris41  363:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5       harris41  364:        $perlvar{'lonLoadLim'}='2.00';
                    365:     }
1.16      harris41  366:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5       harris41  367:        $perlvar{'lonExpire'}='86400';
                    368:     }
1.16      harris41  369:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5       harris41  370:        my $lonReceipt='';
1.11      harris41  371:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5       harris41  372:        my @alnum=(0..9,a..z);
                    373:        foreach my $i (1..20) {
                    374: 	 $lonReceipt.=$alnum[int(rand(36))];
                    375:        }
                    376:        $perlvar{'lonReceipt'}=$lonReceipt;
                    377:     }
                    378:     open(OUT,"&gt;$confdir$filename") or
                    379:       die("Cannot output to $confdir$filename\n");
                    380:     foreach my $key (keys %perlvar) {
                    381:       my $value=$perlvar{$key};
                    382:       print(OUT &lt;&lt;END);
                    383: PerlSetVar     $key      $value
                    384: END
                    385:     }
                    386:     close(OUT);
1.1       harris41  387: }
                    388: </perlscript>
                    389: </file>
                    390: <file>
1.5       harris41  391: <target dist='default'>/</target>
1.1       harris41  392: <perlscript mode='fg'>
                    393: # read values from loncapa.conf
1.7       harris41  394: my $confdir='/etc/httpd/conf/';
1.5       harris41  395: my $filename='loncapa.conf';
                    396: my %perlvar;
                    397:     if (-e "$confdir$filename") {
                    398: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    399:           die("Can't read $confdir$filename");
                    400: 	while (my $configline=&lt;CONFIG&gt;) {
                    401: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    402: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    403: 		chomp($varvalue);
                    404: 		$perlvar{$varname}=$varvalue;
                    405: 	    }
                    406: 	}
                    407: 	close(CONFIG);
                    408:     }
1.16      harris41  409:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
                    410:        $perlvar{'lonLoadLim'}='2.00';
                    411:     }
                    412:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
                    413:        $perlvar{'lonExpire'}='86400';
                    414:     }
                    415:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
                    416:        my $lonReceipt='';
                    417:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
                    418:        my @alnum=(0..9,a..z);
                    419:        foreach my $i (1..20) {
                    420: 	 $lonReceipt.=$alnum[int(rand(36))];
                    421:        }
                    422:        $perlvar{'lonReceipt'}=$lonReceipt;
                    423:     }
1.7       harris41  424: my %perlvarstatic;
                    425:     if (-e "${confdir}loncapa_apache.conf") {
                    426: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
                    427:           die("Can't read ${confdir}loncapa_apache.conf");
                    428: 	while (my $configline=&lt;CONFIG&gt;) {
                    429: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    430: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    431: 		chomp($varvalue);
                    432: 		$perlvarstatic{$varname}=$varvalue;
                    433: 	    }
                    434: 	}
                    435: 	close(CONFIG);
                    436:     }
1.23      albertel  437:     if (!$domainDescription && $lonCluster ne 'existing') {
1.22      albertel  438:        open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
                    439:        while(&lt;IN&gt;) {
                    440:           if (/^$perlvar{'lonHostID'}\:/) {
                    441: 	     (undef,undef,undef,undef,undef,$domainDescription)=split(/:/,$_);
                    442: 	     chomp($domainDescription);
                    443:              last;
                    444:           }
                    445:        }
1.23      albertel  446:        close(IN);
1.22      albertel  447:     }
1.23      albertel  448:     if (!$domainDescription) {
                    449:        open(IN,'&lt;/home/httpd/lonTabs/hosts.tab');
                    450:        while(&lt;IN&gt;) {
                    451:           if (/^$perlvar{'lonHostID'}\:/) {
                    452: 	     (undef,undef,undef,undef,undef,$domainDescription)=split(/:/,$_);
                    453: 	     chomp($domainDescription);
                    454:              last;
                    455:           }
                    456:        }
                    457:        close(IN);
                    458:     }
                    459:    
1.6       harris41  460: # implement editing logic below, interactively
1.22      albertel  461: # update loncapa.conf until 8 is entered
1.6       harris41  462: 
                    463: $flag=0;
1.17      harris41  464: 
1.6       harris41  465: while (!$flag) {
1.1       harris41  466:   print(&lt;&lt;END);
                    467: 
                    468: ===============================================================================
                    469: This is now the current configuration of your machine.
1.8       harris41  470: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  471: 2) Domain Description: $domainDescription
                    472: 3) Machine Name: $perlvar{'lonHostID'}
                    473: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
                    474: 5) Role: $perlvar{'lonRole'}
                    475: 6) Cache Expiration Time: $perlvar{'lonExpire'}
                    476: 7) Server Load: $perlvar{'lonLoadLim'}
                    477: 8) Everything is correct up above
1.6       harris41  478: END
1.17      harris41  479: my $hbug=-1;
                    480: my $dbug=-1;
                    481: {
                    482:   my $v=$perlvar{'lonHostID'};
                    483:   $hbug=0;
                    484:   $hbug=1 if $v=~/\W/;
                    485:   $hbug=1 if $v=~/\_/;
                    486: }
                    487: {
                    488:   my $v=$1;
                    489:   $dbug=0;
                    490:   $dbug=1 if $v=~/\W/;
                    491:   $dbug=1 if $v=~/\_/;
                    492: }
                    493: 
                    494: if ($hbug) {
                    495:   print "**** ERROR **** ".
                    496: 	"Invalid lonHostID (should only be letters and/or digits)\n";
                    497: }
                    498: if ($dbug) {
                    499:   print "**** ERROR **** ".
                    500: 	"Invalid lonDefDomain (should only be letters and/or digits)\n";
                    501: }
                    502: 
1.6       harris41  503:   print(&lt;&lt;END);
1.20      albertel  504: ENTER A CHOICE OF 1-7 TO CHANGE, otherwise ENTER 8:
1.1       harris41  505: END
1.5       harris41  506: my $choice=&lt;&gt;;
                    507: chomp($choice);
1.6       harris41  508:   if ($choice==1) {
                    509:   print(&lt;&lt;END);
1.16      harris41  510: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  511: ENTER NEW VALUE (this is an internal value used to identify a group of
                    512:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    513:                  using a part of your actual DNS domain. For example, for
                    514:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  515: END
                    516:     my $choice2=&lt;&gt;;
                    517:     chomp($choice2);
1.8       harris41  518:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  519:   }
                    520:   elsif ($choice==2) {
                    521:   print(&lt;&lt;END);
1.20      albertel  522: 2) Domain Description: $domainDescription
                    523: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    524:                  and punctuation are fine except for ':'):
                    525: END
                    526:     my $choice2=&lt;&gt;;
                    527:     chomp($choice2);
                    528:     $domainDescription=$choice2;
                    529:   }
                    530:   elsif ($choice==3) {
                    531:   print(&lt;&lt;END);
                    532: 3) Machine Name: $perlvar{'lonHostID'}
                    533: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    534:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    535:                  if you are in the domain 'example' and are the first library
                    536:                  server you enter 'examplel1') :
1.6       harris41  537: END
                    538:     my $choice2=&lt;&gt;;
                    539:     chomp($choice2);
1.8       harris41  540:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  541:   }
1.20      albertel  542:   elsif ($choice==4) {
1.6       harris41  543:   print(&lt;&lt;END);
1.20      albertel  544: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  545: ENTER NEW VALUE:
                    546: END
                    547:     my $choice2=&lt;&gt;;
                    548:     chomp($choice2);
1.9       harris41  549:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  550:   }
1.20      albertel  551:   elsif ($choice==5) {
1.6       harris41  552:   print(&lt;&lt;END);
1.20      albertel  553: 5) Role: $perlvar{'lonRole'}
                    554: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    555:                  if in doubt select 'library'):
1.6       harris41  556: END
                    557:     my $choice2=&lt;&gt;;
                    558:     chomp($choice2);
                    559:     $perlvar{'lonRole'}=$choice2;
                    560:   }
1.20      albertel  561:   elsif ($choice==6) {
1.6       harris41  562:   print(&lt;&lt;END);
1.20      albertel  563: 6) Cache Expiration Time: $perlvar{'lonExpire'}
                    564: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  565: END
                    566:     my $choice2=&lt;&gt;;
                    567:     chomp($choice2);
                    568:     $perlvar{'lonExpire'}=$choice2;
                    569:   }
1.20      albertel  570:   elsif ($choice==7) {
1.6       harris41  571:   print(&lt;&lt;END);
1.20      albertel  572: 7) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  573: ENTER NEW VALUE:
                    574: END
                    575:     my $choice2=&lt;&gt;;
                    576:     chomp($choice2);
                    577:     $perlvar{'lonLoadLim'}=$choice2;
                    578:   }
1.20      albertel  579:   elsif ($choice==8) {
1.6       harris41  580:     $flag=1;
                    581:   }
                    582:   else {
1.1       harris41  583: 
1.6       harris41  584:   }
                    585: }
1.7       harris41  586:     open(OUT,"&gt;$confdir$filename") or
                    587:       die("Cannot output to $confdir$filename\n");
                    588:     foreach my $key (keys %perlvar) {
                    589:       my $value=$perlvar{$key};
1.8       harris41  590:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.7       harris41  591: PerlSetVar     $key      $value
                    592: END
                    593:     }
                    594:     close(OUT);
1.1       harris41  595: </perlscript>
                    596: </file>
                    597: <file>
                    598: <target dist='default'>loncom/hosts.tab</target>
                    599: <perlscript mode='fg'>
                    600: unless (-l "<TARGET />") {
1.22      albertel  601:   my $hostname=`hostname`;chomp($hostname);
                    602:   my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
                    603:   $hostaddress=~s/\s//;
1.15      harris41  604:   $date=`date -I`; chomp($date);
                    605:   $lonHostID=$perlvar{'lonHostID'};
                    606:   $lonHostID=~s/\W//g;
                    607:   $lineexistflag=0;
                    608:   $hostidexistflag=0;
1.22      albertel  609:   $line2insert=&lt;&lt;END;
                    610: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress:$domainDescription
1.15      harris41  611: END
1.23      albertel  612:   if ($lonCluster eq 'standalone') {
                    613:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                    614:       die('file generation error');
                    615:       print(OUT $line2insert);
                    616:     close(OUT);
                    617:   }
1.15      harris41  618:   if ($flag==1) {
1.6       harris41  619:     `rm -f ../hosts.tab`;
1.15      harris41  620:     open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
1.13      harris41  621:     while(&lt;IN&gt;) {
                    622:       if (/^$line2insert$/) {
                    623:         $lineexistflag=1;
                    624:       }
1.15      harris41  625:       if (/^$lonHostID\:/) {
1.13      harris41  626:         $hostidexistflag=1;
                    627:       }
                    628:     }
                    629:     close(IN);
                    630:     if ($hostidexistflag and !$lineexistflag) {
                    631:       print &lt;&lt;END;
                    632: WARNING: $lonHostID already exists inside
1.15      harris41  633: loncapa/loncom/${lonCluster}_hosts.tab.  The entry inside
                    634: ${lonCluster}_hosts.tab does not match your settings.
                    635: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13      harris41  636: with your new values.
                    637: END
1.15      harris41  638:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                    639:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    640:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41  641:          print(OUT $line2insert);
1.13      harris41  642:        close(OUT);
1.15      harris41  643:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41  644:       # email appropriate message
1.19      harris41  645:       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');
                    646:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
1.13      harris41  647:     }
                    648:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41  649:       print &lt;&lt;END;
                    650: Entry exists in ${lonCluster}_hosts.tab.
                    651: END
                    652:       `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
                    653:       # email appropriate message
                    654:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  655:     }
1.15      harris41  656:     elsif (!$hostidexistflag and !$lineexistflag) {
                    657:       print &lt;&lt;END;
                    658: New entry for $lonCluster.
1.6       harris41  659: END
1.15      harris41  660:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel  661:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    662:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41  663:          print(OUT $line2insert);
                    664:        close(OUT);
                    665:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                    666:       # email appropriate message
                    667:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41  668:     }
                    669:   }
1.1       harris41  670: }
                    671: </perlscript>
                    672: </file>
                    673: </files>
                    674: </piml>

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