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

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

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