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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.26    ! albertel    3: <!-- $Id: updatequery.piml,v 1.25 2003/05/08 22:16:23 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.25      albertel  366:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    367:        $perlvar{'lonUserLoadLim'}='0';
                    368:     }
1.16      harris41  369:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5       harris41  370:        $perlvar{'lonExpire'}='86400';
                    371:     }
1.16      harris41  372:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5       harris41  373:        my $lonReceipt='';
1.11      harris41  374:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5       harris41  375:        my @alnum=(0..9,a..z);
                    376:        foreach my $i (1..20) {
                    377: 	 $lonReceipt.=$alnum[int(rand(36))];
                    378:        }
                    379:        $perlvar{'lonReceipt'}=$lonReceipt;
                    380:     }
                    381:     open(OUT,"&gt;$confdir$filename") or
                    382:       die("Cannot output to $confdir$filename\n");
                    383:     foreach my $key (keys %perlvar) {
                    384:       my $value=$perlvar{$key};
                    385:       print(OUT &lt;&lt;END);
                    386: PerlSetVar     $key      $value
                    387: END
                    388:     }
                    389:     close(OUT);
1.1       harris41  390: }
                    391: </perlscript>
                    392: </file>
                    393: <file>
1.5       harris41  394: <target dist='default'>/</target>
1.1       harris41  395: <perlscript mode='fg'>
                    396: # read values from loncapa.conf
1.7       harris41  397: my $confdir='/etc/httpd/conf/';
1.5       harris41  398: my $filename='loncapa.conf';
                    399: my %perlvar;
                    400:     if (-e "$confdir$filename") {
                    401: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    402:           die("Can't read $confdir$filename");
                    403: 	while (my $configline=&lt;CONFIG&gt;) {
                    404: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    405: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    406: 		chomp($varvalue);
                    407: 		$perlvar{$varname}=$varvalue;
                    408: 	    }
                    409: 	}
                    410: 	close(CONFIG);
                    411:     }
1.16      harris41  412:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
                    413:        $perlvar{'lonLoadLim'}='2.00';
                    414:     }
1.25      albertel  415:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    416:        $perlvar{'lonUserLoadLim'}='0';
                    417:     }
1.16      harris41  418:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
                    419:        $perlvar{'lonExpire'}='86400';
                    420:     }
                    421:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
                    422:        my $lonReceipt='';
                    423:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
                    424:        my @alnum=(0..9,a..z);
                    425:        foreach my $i (1..20) {
                    426: 	 $lonReceipt.=$alnum[int(rand(36))];
                    427:        }
                    428:        $perlvar{'lonReceipt'}=$lonReceipt;
                    429:     }
1.7       harris41  430: my %perlvarstatic;
                    431:     if (-e "${confdir}loncapa_apache.conf") {
                    432: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
                    433:           die("Can't read ${confdir}loncapa_apache.conf");
                    434: 	while (my $configline=&lt;CONFIG&gt;) {
                    435: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    436: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    437: 		chomp($varvalue);
                    438: 		$perlvarstatic{$varname}=$varvalue;
                    439: 	    }
                    440: 	}
                    441: 	close(CONFIG);
                    442:     }
1.23      albertel  443:     if (!$domainDescription && $lonCluster ne 'existing') {
1.22      albertel  444:        open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
                    445:        while(&lt;IN&gt;) {
                    446:           if (/^$perlvar{'lonHostID'}\:/) {
                    447: 	     (undef,undef,undef,undef,undef,$domainDescription)=split(/:/,$_);
                    448: 	     chomp($domainDescription);
                    449:              last;
                    450:           }
                    451:        }
1.23      albertel  452:        close(IN);
1.22      albertel  453:     }
1.23      albertel  454:     if (!$domainDescription) {
                    455:        open(IN,'&lt;/home/httpd/lonTabs/hosts.tab');
                    456:        while(&lt;IN&gt;) {
                    457:           if (/^$perlvar{'lonHostID'}\:/) {
                    458: 	     (undef,undef,undef,undef,undef,$domainDescription)=split(/:/,$_);
                    459: 	     chomp($domainDescription);
                    460:              last;
                    461:           }
                    462:        }
                    463:        close(IN);
                    464:     }
                    465:    
1.6       harris41  466: # implement editing logic below, interactively
1.22      albertel  467: # update loncapa.conf until 8 is entered
1.6       harris41  468: 
                    469: $flag=0;
1.17      harris41  470: 
1.6       harris41  471: while (!$flag) {
1.1       harris41  472:   print(&lt;&lt;END);
                    473: 
                    474: ===============================================================================
                    475: This is now the current configuration of your machine.
1.8       harris41  476: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  477: 2) Domain Description: $domainDescription
                    478: 3) Machine Name: $perlvar{'lonHostID'}
                    479: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
                    480: 5) Role: $perlvar{'lonRole'}
                    481: 6) Cache Expiration Time: $perlvar{'lonExpire'}
                    482: 7) Server Load: $perlvar{'lonLoadLim'}
1.25      albertel  483: 8) User Load: $perlvar{'lonUserLoadLim'}
                    484: 9) Everything is correct up above
1.6       harris41  485: END
1.17      harris41  486: my $hbug=-1;
                    487: my $dbug=-1;
                    488: {
                    489:   my $v=$perlvar{'lonHostID'};
                    490:   $hbug=0;
                    491:   $hbug=1 if $v=~/\W/;
                    492:   $hbug=1 if $v=~/\_/;
                    493: }
                    494: {
                    495:   my $v=$1;
                    496:   $dbug=0;
                    497:   $dbug=1 if $v=~/\W/;
                    498:   $dbug=1 if $v=~/\_/;
                    499: }
                    500: 
                    501: if ($hbug) {
                    502:   print "**** ERROR **** ".
                    503: 	"Invalid lonHostID (should only be letters and/or digits)\n";
                    504: }
                    505: if ($dbug) {
                    506:   print "**** ERROR **** ".
                    507: 	"Invalid lonDefDomain (should only be letters and/or digits)\n";
                    508: }
                    509: 
1.6       harris41  510:   print(&lt;&lt;END);
1.25      albertel  511: ENTER A CHOICE OF 1-8 TO CHANGE, otherwise ENTER 9:
1.1       harris41  512: END
1.5       harris41  513: my $choice=&lt;&gt;;
                    514: chomp($choice);
1.6       harris41  515:   if ($choice==1) {
                    516:   print(&lt;&lt;END);
1.16      harris41  517: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  518: ENTER NEW VALUE (this is an internal value used to identify a group of
                    519:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    520:                  using a part of your actual DNS domain. For example, for
                    521:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  522: END
                    523:     my $choice2=&lt;&gt;;
                    524:     chomp($choice2);
1.8       harris41  525:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  526:   }
                    527:   elsif ($choice==2) {
                    528:   print(&lt;&lt;END);
1.20      albertel  529: 2) Domain Description: $domainDescription
                    530: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    531:                  and punctuation are fine except for ':'):
                    532: END
                    533:     my $choice2=&lt;&gt;;
                    534:     chomp($choice2);
                    535:     $domainDescription=$choice2;
                    536:   }
                    537:   elsif ($choice==3) {
                    538:   print(&lt;&lt;END);
                    539: 3) Machine Name: $perlvar{'lonHostID'}
                    540: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    541:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    542:                  if you are in the domain 'example' and are the first library
                    543:                  server you enter 'examplel1') :
1.6       harris41  544: END
                    545:     my $choice2=&lt;&gt;;
                    546:     chomp($choice2);
1.8       harris41  547:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  548:   }
1.20      albertel  549:   elsif ($choice==4) {
1.6       harris41  550:   print(&lt;&lt;END);
1.20      albertel  551: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  552: ENTER NEW VALUE:
                    553: END
                    554:     my $choice2=&lt;&gt;;
                    555:     chomp($choice2);
1.9       harris41  556:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  557:   }
1.20      albertel  558:   elsif ($choice==5) {
1.6       harris41  559:   print(&lt;&lt;END);
1.20      albertel  560: 5) Role: $perlvar{'lonRole'}
                    561: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    562:                  if in doubt select 'library'):
1.6       harris41  563: END
                    564:     my $choice2=&lt;&gt;;
                    565:     chomp($choice2);
                    566:     $perlvar{'lonRole'}=$choice2;
                    567:   }
1.20      albertel  568:   elsif ($choice==6) {
1.6       harris41  569:   print(&lt;&lt;END);
1.20      albertel  570: 6) Cache Expiration Time: $perlvar{'lonExpire'}
                    571: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  572: END
                    573:     my $choice2=&lt;&gt;;
                    574:     chomp($choice2);
                    575:     $perlvar{'lonExpire'}=$choice2;
                    576:   }
1.20      albertel  577:   elsif ($choice==7) {
1.6       harris41  578:   print(&lt;&lt;END);
1.20      albertel  579: 7) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  580: ENTER NEW VALUE:
                    581: END
                    582:     my $choice2=&lt;&gt;;
                    583:     chomp($choice2);
                    584:     $perlvar{'lonLoadLim'}=$choice2;
                    585:   }
1.20      albertel  586:   elsif ($choice==8) {
1.25      albertel  587:   print(&lt;&lt;END);
                    588: 8) User Load: $perlvar{'lonUserLoadLim'}
                    589: Numer of users that can login before machine is 'overloaded'
1.26    ! albertel  590: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25      albertel  591: END
                    592:     my $choice2=&lt;&gt;;
                    593:     chomp($choice2);
                    594:     $perlvar{'lonUserLoadLim'}=$choice2;
                    595:   }
                    596:   elsif ($choice==9) {
1.6       harris41  597:     $flag=1;
                    598:   }
                    599:   else {
1.1       harris41  600: 
1.6       harris41  601:   }
                    602: }
1.7       harris41  603:     open(OUT,"&gt;$confdir$filename") or
                    604:       die("Cannot output to $confdir$filename\n");
                    605:     foreach my $key (keys %perlvar) {
                    606:       my $value=$perlvar{$key};
1.8       harris41  607:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.7       harris41  608: PerlSetVar     $key      $value
                    609: END
                    610:     }
                    611:     close(OUT);
1.1       harris41  612: </perlscript>
                    613: </file>
                    614: <file>
                    615: <target dist='default'>loncom/hosts.tab</target>
                    616: <perlscript mode='fg'>
                    617: unless (-l "<TARGET />") {
1.22      albertel  618:   my $hostname=`hostname`;chomp($hostname);
                    619:   my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
                    620:   $hostaddress=~s/\s//;
1.15      harris41  621:   $date=`date -I`; chomp($date);
                    622:   $lonHostID=$perlvar{'lonHostID'};
                    623:   $lonHostID=~s/\W//g;
                    624:   $lineexistflag=0;
                    625:   $hostidexistflag=0;
1.22      albertel  626:   $line2insert=&lt;&lt;END;
                    627: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress:$domainDescription
1.15      harris41  628: END
1.23      albertel  629:   if ($lonCluster eq 'standalone') {
                    630:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                    631:       die('file generation error');
                    632:       print(OUT $line2insert);
                    633:     close(OUT);
                    634:   }
1.15      harris41  635:   if ($flag==1) {
1.6       harris41  636:     `rm -f ../hosts.tab`;
1.15      harris41  637:     open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
1.13      harris41  638:     while(&lt;IN&gt;) {
                    639:       if (/^$line2insert$/) {
                    640:         $lineexistflag=1;
                    641:       }
1.15      harris41  642:       if (/^$lonHostID\:/) {
1.13      harris41  643:         $hostidexistflag=1;
                    644:       }
                    645:     }
                    646:     close(IN);
                    647:     if ($hostidexistflag and !$lineexistflag) {
                    648:       print &lt;&lt;END;
                    649: WARNING: $lonHostID already exists inside
1.15      harris41  650: loncapa/loncom/${lonCluster}_hosts.tab.  The entry inside
                    651: ${lonCluster}_hosts.tab does not match your settings.
                    652: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13      harris41  653: with your new values.
                    654: END
1.15      harris41  655:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                    656:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    657:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41  658:          print(OUT $line2insert);
1.13      harris41  659:        close(OUT);
1.15      harris41  660:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41  661:       # email appropriate message
1.19      harris41  662:       system('ping -c 1 www.lon-capa.org > /dev/null || ping -c 1 www.msu.edu > /dev/null || ping -c 1 www.mit.edu > /dev/null');
                    663:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
1.13      harris41  664:     }
                    665:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41  666:       print &lt;&lt;END;
                    667: Entry exists in ${lonCluster}_hosts.tab.
                    668: END
                    669:       `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
                    670:       # email appropriate message
                    671:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  672:     }
1.15      harris41  673:     elsif (!$hostidexistflag and !$lineexistflag) {
                    674:       print &lt;&lt;END;
                    675: New entry for $lonCluster.
1.6       harris41  676: END
1.15      harris41  677:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel  678:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    679:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41  680:          print(OUT $line2insert);
                    681:        close(OUT);
                    682:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                    683:       # email appropriate message
                    684:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41  685:     }
                    686:   }
1.1       harris41  687: }
                    688: </perlscript>
                    689: </file>
                    690: </files>
                    691: </piml>

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