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

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

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