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

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

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