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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.36    ! albertel    3: <!-- $Id: updatequery.piml,v 1.35 2005/02/06 07:57:57 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.32      raeburn   137: or contact helpdesk\@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.
1.32      raeburn   145: ===============================================================================
                    146: 
                    147: In addition, a Support E-mail Address can also be included. If
                    148: an address is included then one of the options in the LON-CAPA 
                    149: help menu will be a link to a form that a user will complete to
                    150: request LON-CAPA help.  
                    151: 
1.1       harris41  152: END
1.3       harris41  153: 
1.4       harris41  154: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
                    155: close(OUT);
                    156: 
1.3       harris41  157: # query for Machine Role
                    158:   print(&lt;&lt;END);
                    159: **** Machine Role ****
                    160: Library server (recommended if first-time installation of LON-CAPA):
                    161:    Servers that are repositories of authoritative educational resources.
                    162:    These servers also provide the construction space by which instructors
                    163:    assemble their classroom online material.
                    164: Access server:
                    165:    Servers that load-balance high-traffic delivery of educational resources
                    166:    over the world-wide web.
1.4       harris41  167: 1) Will this be a library server? (recommended if this is your first install)
1.3       harris41  168: 2) Or, will this be an access server?
                    169: END
1.4       harris41  170: my $flag=0;
                    171: my $r='';
                    172: my $lonRole;
                    173: while (!$flag) {
                    174:   print "ENTER A CHOICE OF 1 or 2:\n";
                    175:   my $choice=&lt;&gt;;
                    176:   chomp($choice);
                    177:   if ($choice==1) {
                    178:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    179:     print(OUT 'lonRole'."\t".'library'."\n");
                    180:     close(OUT);
                    181:     $lonRole='library';
                    182:     $r='l';
                    183:     $flag=1;
                    184:   }
                    185:   elsif ($choice==2) {
                    186:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    187:     print(OUT 'lonRole'."\t".'access'."\n");
                    188:     close(OUT);
                    189:     $lonRole='access';
                    190:     $r='a';
                    191:     $flag=2;
                    192:   }
                    193:   else {
                    194: 
                    195:   }
                    196: }
1.3       harris41  197: 
                    198: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.36    ! albertel  199: my $hostname=`hostname -f`; chomp($hostname);
1.4       harris41  200: my $ipdomain='';
                    201: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
                    202:   $ipdomain=$1;
                    203: }
1.1       harris41  204: 
                    205:   print(&lt;&lt;END);
                    206: 
1.8       harris41  207: **** Domain ****
                    208: [this does NOT need to correspond to internet address domains,
                    209:  examples might be "msu" or "bionet" or "vermontcc"]
1.1       harris41  210: END
1.8       harris41  211: 
                    212: # get domain name
1.1       harris41  213: # accept if valid, if not valid, tell user and repeat
1.4       harris41  214: $flag=0;
1.8       harris41  215: my $lonDefDomain;
1.4       harris41  216: while (!$flag) {
                    217: if ($ipdomain) {
                    218: print(&lt;&lt;END);
1.8       harris41  219: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4       harris41  220: END
                    221: }
                    222: else {
                    223:   print(&lt;&lt;END);
1.8       harris41  224: ENTER LONCAPA DOMAIN:
1.4       harris41  225: END
                    226: }
                    227:   my $choice=&lt;&gt;;
                    228:   chomp($choice);
1.18      harris41  229:   my $bad_domain_flag=0;
                    230:   my @bad_domain_names=('raw','userfiles','priv','adm','uploaded');
                    231:   foreach my $bad (@bad_domain_names) {
                    232:     $bad_domain_flag=1 if $choice eq $bad;
                    233:   }
1.8       harris41  234:   if ($ipdomain and $choice=~/^\s*$/) {
                    235:     $choice=$ipdomain;
1.4       harris41  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;
1.4       harris41  240:     $flag=1;
                    241:   }
                    242:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    243:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  244:     print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4       harris41  245:     close(OUT);
1.8       harris41  246:     $lonDefDomain=$choice;
                    247:     $r='l';
1.4       harris41  248:     $flag=1;
1.18      harris41  249:   }
                    250:   elsif ($bad_domain_flag) {
                    251:     print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
                    252:     print "Please try something different than '$choice'\n";
1.4       harris41  253:   }
                    254:   else {
                    255:     print "Invalid input (only alphanumeric characters supported).\n";
                    256:   }
                    257: }
1.1       harris41  258: 
1.20      albertel  259: 
                    260: # get domain description
                    261: # accept if valid, if not valid, tell user and repeat
                    262: $flag=0;
                    263: 
                    264: while (!$flag) {
                    265:   print(&lt;&lt;END);
                    266: 
                    267: **** Domain Description ****
                    268: String describing the domain, to be shown to users.
                    269: [Example, msu is Michigan State University]
                    270: ENTER DOMAIN DESCRIPTION:
                    271: END
                    272: 
                    273:   my $choice=&lt;&gt;;
                    274:   chomp($choice);
                    275:   if ($choice!~/:/) {
                    276:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    277:     print(OUT 'domainDescription'."\t".$choice."\n");
                    278:     close(OUT);
                    279:     $domainDescription=$choice;
                    280:     $flag=1;
                    281:   }
                    282:   else {
                    283:     print "Invalid input (no ':' allowed).\n";
                    284:   }
                    285: }
                    286: 
1.8       harris41  287: my $lonHostID;
                    288: if ($lonDefDomain) {
                    289:   $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
                    290:                                               # against the hosts.tab
                    291: }
                    292: 
1.1       harris41  293:   print(&lt;&lt;END);
                    294: 
1.8       harris41  295: **** Machine ID Name ****
                    296: [this does NOT need to correspond to internet address names;
                    297:  this name MUST be unique to the whole LON-CAPA network;
                    298:  we recommend that you use a name based off of your institution;
                    299:  good examples: "msul1" or "bionetl1";
                    300:  bad examples: "loncapabox" or "studentsinside"]
1.1       harris41  301: END
1.8       harris41  302: # get machine name
1.1       harris41  303: # accept if valid, if not valid, tell user and repeat
1.4       harris41  304: $flag=0;
                    305: while (!$flag) {
                    306: if ($ipdomain) {
                    307: print(&lt;&lt;END);
1.8       harris41  308: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4       harris41  309: END
                    310: }
                    311: else {
                    312:   print(&lt;&lt;END);
1.8       harris41  313: ENTER LONCAPA MACHINE ID:
1.4       harris41  314: END
                    315: }
                    316:   my $choice=&lt;&gt;;
                    317:   chomp($choice);
1.8       harris41  318:   if ($lonHostID and $choice=~/^\s*$/) {
                    319:     $choice=$lonHostID;
1.4       harris41  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:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    327:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  328:     print(OUT 'lonHostID'."\t".$choice."\n");
1.4       harris41  329:     close(OUT);
1.8       harris41  330:     $lonHostID=$choice;
1.4       harris41  331:     $flag=1;
                    332:   }
                    333:   else {
                    334:     print "Invalid input (only alphanumeric characters supported).\n";
                    335:   }
                    336: }
1.1       harris41  337: 
1.32      raeburn   338: # get admin e-mail address
1.4       harris41  339: # accept if valid, if not valid, tell user and repeat
                    340: $flag=0;
1.9       harris41  341: my $lonAdmEMail;
1.4       harris41  342: while (!$flag) {
1.1       harris41  343:   print(&lt;&lt;END);
                    344: 
                    345: **** System Administrator's E-mail ****
                    346: E-mail address of the person who will manage this machine
1.4       harris41  347: [should be in the form somebody\@somewhere]
1.32      raeburn   348: ENTER ADMIN E-MAIL ADDRESS:
1.1       harris41  349: END
                    350: 
1.4       harris41  351:   my $choice=&lt;&gt;;
                    352:   chomp($choice);
                    353:   if ($choice=~/\@/) {
                    354:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.9       harris41  355:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4       harris41  356:     close(OUT);
1.9       harris41  357:     $lonAdmEMail=$choice;
1.4       harris41  358:     $flag=1;
                    359:   }
                    360:   else {
                    361:     print "Invalid input (this needs to look like an e-mail address!).\n";
                    362:   }
                    363: }
                    364: 
1.32      raeburn   365: 
                    366: # get support e-mail address
                    367: # accept if valid, if not valid, tell user and repeat
                    368: $flag=0;
                    369: my $lonSupportEMail;
                    370: while (!$flag) {
                    371:   print(&lt;&lt;END);
                    372: 
                    373: **** Support E-mail ****
                    374: E-mail address of the person who will receive 
                    375: help requests from LON-CAPA users who access 
                    376: the system via this server. If the address is left blank,
                    377: then a help support form will not be displayed 
                    378: as part of the help menu.
                    379: [should be in the form somebody\@somewhere]
                    380: ENTER SUPPORT E-MAIL ADDRESS:
                    381: END
                    382: 
                    383:   my $choice=&lt;&gt;;
                    384:   chomp($choice);
                    385:   $choice =~ s/\s//g;
1.33      albertel  386:   if ( ($choice=~/\@/) || $choice eq '') {
1.32      raeburn   387:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    388:     print(OUT 'lonSupportEMail'."\t".$choice."\n");
                    389:     close(OUT);
                    390:     $lonSupportEMail=$choice;
                    391:     $flag=1;
                    392:   }
                    393:   else {
                    394:     print "Invalid input (this either needs to be blank, or look like an e-mail address!).\n";
                    395:   }
                    396: }
                    397: 
                    398: 
1.1       harris41  399: # update loncapa.conf
1.7       harris41  400: my $confdir='/etc/httpd/conf/';
                    401: #my $confdir='';
1.5       harris41  402: my $filename='loncapa.conf';
                    403: my %perlvar;
                    404:     if (-e "$confdir$filename") {
                    405: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
                    406: 	while (my $configline=&lt;CONFIG&gt;) {
                    407: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    408: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    409: 		chomp($varvalue);
1.12      harris41  410: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5       harris41  411: 	    }
                    412: 	}
                    413: 	close(CONFIG);
                    414:     }
                    415:     $perlvar{'lonHostID'}=$lonHostID;
                    416:     $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9       harris41  417:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.32      raeburn   418:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
1.5       harris41  419:     $perlvar{'lonRole'}=$lonRole;
1.16      harris41  420:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5       harris41  421:        $perlvar{'lonLoadLim'}='2.00';
                    422:     }
1.25      albertel  423:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    424:        $perlvar{'lonUserLoadLim'}='0';
                    425:     }
1.16      harris41  426:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5       harris41  427:        $perlvar{'lonExpire'}='86400';
                    428:     }
1.16      harris41  429:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5       harris41  430:        my $lonReceipt='';
1.11      harris41  431:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5       harris41  432:        my @alnum=(0..9,a..z);
                    433:        foreach my $i (1..20) {
                    434: 	 $lonReceipt.=$alnum[int(rand(36))];
                    435:        }
                    436:        $perlvar{'lonReceipt'}=$lonReceipt;
                    437:     }
                    438:     open(OUT,"&gt;$confdir$filename") or
                    439:       die("Cannot output to $confdir$filename\n");
                    440:     foreach my $key (keys %perlvar) {
                    441:       my $value=$perlvar{$key};
                    442:       print(OUT &lt;&lt;END);
                    443: PerlSetVar     $key      $value
                    444: END
                    445:     }
                    446:     close(OUT);
1.1       harris41  447: }
                    448: </perlscript>
                    449: </file>
                    450: <file>
1.5       harris41  451: <target dist='default'>/</target>
1.1       harris41  452: <perlscript mode='fg'>
1.31      albertel  453: sub securesetting {
                    454:     my (%perlvar)=@_;
                    455:     my $securestatus='unknown';
                    456:     my $securenum='';
                    457:     if      ( $perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    458: 	$securestatus='no';                  $securenum='4';
                    459:     } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    460: 	$securestatus='lond';                $securenum='3';
                    461:     } elsif (!$perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    462: 	$securestatus='lonc';                $securenum='2';
                    463:     } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    464: 	$securestatus='yes (lond and lonc)'; $securenum='1';
                    465:     }
                    466:     return ($securestatus,$securenum);
                    467: }
1.1       harris41  468: # read values from loncapa.conf
1.7       harris41  469: my $confdir='/etc/httpd/conf/';
1.5       harris41  470: my $filename='loncapa.conf';
                    471: my %perlvar;
1.31      albertel  472: my ($securestatus,$securenum);
1.5       harris41  473:     if (-e "$confdir$filename") {
                    474: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    475:           die("Can't read $confdir$filename");
                    476: 	while (my $configline=&lt;CONFIG&gt;) {
                    477: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    478: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    479: 		chomp($varvalue);
                    480: 		$perlvar{$varname}=$varvalue;
                    481: 	    }
                    482: 	}
                    483: 	close(CONFIG);
                    484:     }
1.16      harris41  485:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
                    486:        $perlvar{'lonLoadLim'}='2.00';
                    487:     }
1.25      albertel  488:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    489:        $perlvar{'lonUserLoadLim'}='0';
                    490:     }
1.16      harris41  491:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
                    492:        $perlvar{'lonExpire'}='86400';
                    493:     }
1.31      albertel  494:     unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
                    495:        $perlvar{'londAllowInsecure'}='1';
                    496:     }
                    497:     unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
                    498:        $perlvar{'loncAllowInsecure'}='1';
                    499:     }
                    500:     ($securestatus,$securenum)=&securesetting(%perlvar);
1.16      harris41  501:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
                    502:        my $lonReceipt='';
                    503:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
                    504:        my @alnum=(0..9,a..z);
                    505:        foreach my $i (1..20) {
                    506: 	 $lonReceipt.=$alnum[int(rand(36))];
                    507:        }
                    508:        $perlvar{'lonReceipt'}=$lonReceipt;
                    509:     }
1.7       harris41  510: my %perlvarstatic;
                    511:     if (-e "${confdir}loncapa_apache.conf") {
                    512: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
                    513:           die("Can't read ${confdir}loncapa_apache.conf");
                    514: 	while (my $configline=&lt;CONFIG&gt;) {
                    515: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    516: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    517: 		chomp($varvalue);
                    518: 		$perlvarstatic{$varname}=$varvalue;
                    519: 	    }
                    520: 	}
                    521: 	close(CONFIG);
                    522:     }
1.23      albertel  523:     if (!$domainDescription && $lonCluster ne 'existing') {
1.27      albertel  524:        open(IN,'&lt;../'.$lonCluster.'_domain.tab');
1.22      albertel  525:        while(&lt;IN&gt;) {
1.27      albertel  526:           if (/^$perlvar{'lonDefDomain'}\:/) {
1.29      albertel  527: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.22      albertel  528: 	     chomp($domainDescription);
1.29      albertel  529: 	     chomp($domainTabExtras);
1.22      albertel  530:              last;
                    531:           }
                    532:        }
1.23      albertel  533:        close(IN);
1.22      albertel  534:     }
1.23      albertel  535:     if (!$domainDescription) {
1.27      albertel  536:        open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
1.23      albertel  537:        while(&lt;IN&gt;) {
1.27      albertel  538:           if (/^$perlvar{'lonDefDomain'}\:/) {
1.29      albertel  539: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.23      albertel  540: 	     chomp($domainDescription);
1.29      albertel  541: 	     chomp($domainTabExtras);
1.23      albertel  542:              last;
                    543:           }
                    544:        }
                    545:        close(IN);
                    546:     }
                    547:    
1.6       harris41  548: # implement editing logic below, interactively
1.22      albertel  549: # update loncapa.conf until 8 is entered
1.6       harris41  550: 
                    551: $flag=0;
1.17      harris41  552: 
1.6       harris41  553: while (!$flag) {
1.1       harris41  554:   print(&lt;&lt;END);
                    555: 
                    556: ===============================================================================
                    557: This is now the current configuration of your machine.
1.31      albertel  558:  1) Domain Name: $perlvar{'lonDefDomain'}
                    559:  2) Domain Description: $domainDescription
                    560:  3) Machine Name: $perlvar{'lonHostID'}
                    561:  4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.33      albertel  562:  5) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.32      raeburn   563:  6) Role: $perlvar{'lonRole'}
                    564:  7) Cache Expiration Time: $perlvar{'lonExpire'}
                    565:  8) Server Load: $perlvar{'lonLoadLim'}
                    566:  9) User Load: $perlvar{'lonUserLoadLim'}
                    567: 10) Allow only secure connections: $securestatus 
                    568: 11) Everything is correct up above
1.6       harris41  569: END
1.17      harris41  570: my $hbug=-1;
                    571: my $dbug=-1;
                    572: {
                    573:   my $v=$perlvar{'lonHostID'};
                    574:   $hbug=0;
                    575:   $hbug=1 if $v=~/\W/;
                    576:   $hbug=1 if $v=~/\_/;
                    577: }
                    578: {
                    579:   my $v=$1;
                    580:   $dbug=0;
                    581:   $dbug=1 if $v=~/\W/;
                    582:   $dbug=1 if $v=~/\_/;
                    583: }
                    584: 
                    585: if ($hbug) {
                    586:   print "**** ERROR **** ".
                    587: 	"Invalid lonHostID (should only be letters and/or digits)\n";
                    588: }
                    589: if ($dbug) {
                    590:   print "**** ERROR **** ".
                    591: 	"Invalid lonDefDomain (should only be letters and/or digits)\n";
                    592: }
                    593: 
1.6       harris41  594:   print(&lt;&lt;END);
1.32      raeburn   595: ENTER A CHOICE OF 1-10 TO CHANGE, otherwise ENTER 11:
1.1       harris41  596: END
1.5       harris41  597: my $choice=&lt;&gt;;
                    598: chomp($choice);
1.6       harris41  599:   if ($choice==1) {
                    600:   print(&lt;&lt;END);
1.16      harris41  601: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  602: ENTER NEW VALUE (this is an internal value used to identify a group of
                    603:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    604:                  using a part of your actual DNS domain. For example, for
                    605:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  606: END
                    607:     my $choice2=&lt;&gt;;
                    608:     chomp($choice2);
1.8       harris41  609:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  610:   }
                    611:   elsif ($choice==2) {
                    612:   print(&lt;&lt;END);
1.20      albertel  613: 2) Domain Description: $domainDescription
                    614: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    615:                  and punctuation are fine except for ':'):
                    616: END
                    617:     my $choice2=&lt;&gt;;
                    618:     chomp($choice2);
                    619:     $domainDescription=$choice2;
                    620:   }
                    621:   elsif ($choice==3) {
                    622:   print(&lt;&lt;END);
                    623: 3) Machine Name: $perlvar{'lonHostID'}
                    624: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    625:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    626:                  if you are in the domain 'example' and are the first library
                    627:                  server you enter 'examplel1') :
1.6       harris41  628: END
                    629:     my $choice2=&lt;&gt;;
                    630:     chomp($choice2);
1.8       harris41  631:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  632:   }
1.20      albertel  633:   elsif ($choice==4) {
1.6       harris41  634:   print(&lt;&lt;END);
1.20      albertel  635: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  636: ENTER NEW VALUE:
                    637: END
                    638:     my $choice2=&lt;&gt;;
                    639:     chomp($choice2);
1.9       harris41  640:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  641:   }
1.20      albertel  642:   elsif ($choice==5) {
1.6       harris41  643:   print(&lt;&lt;END);
1.32      raeburn   644: 5) Support E-mail Address: $perlvar{'lonSupportEMail'}
                    645: ENTER NEW VALUE:
                    646: END
                    647:     my $choice2=&lt;&gt;;
                    648:     chomp($choice2);
                    649:     $perlvar{'lonSupportEMail'}=$choice2;
                    650:   }
                    651:   elsif ($choice==6) {
                    652:   print(&lt;&lt;END);
                    653: 6) Role: $perlvar{'lonRole'}
1.20      albertel  654: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    655:                  if in doubt select 'library'):
1.6       harris41  656: END
                    657:     my $choice2=&lt;&gt;;
                    658:     chomp($choice2);
                    659:     $perlvar{'lonRole'}=$choice2;
                    660:   }
1.32      raeburn   661:   elsif ($choice==7) {
1.6       harris41  662:   print(&lt;&lt;END);
1.32      raeburn   663: 7) Cache Expiration Time: $perlvar{'lonExpire'}
1.20      albertel  664: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  665: END
                    666:     my $choice2=&lt;&gt;;
                    667:     chomp($choice2);
                    668:     $perlvar{'lonExpire'}=$choice2;
                    669:   }
1.32      raeburn   670:   elsif ($choice==8) {
1.6       harris41  671:   print(&lt;&lt;END);
1.32      raeburn   672: 8) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  673: ENTER NEW VALUE:
                    674: END
                    675:     my $choice2=&lt;&gt;;
                    676:     chomp($choice2);
                    677:     $perlvar{'lonLoadLim'}=$choice2;
                    678:   }
1.32      raeburn   679:   elsif ($choice==9) {
1.25      albertel  680:   print(&lt;&lt;END);
1.32      raeburn   681: 9) User Load: $perlvar{'lonUserLoadLim'}
1.25      albertel  682: Numer of users that can login before machine is 'overloaded'
1.26      albertel  683: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25      albertel  684: END
                    685:     my $choice2=&lt;&gt;;
                    686:     chomp($choice2);
                    687:     $perlvar{'lonUserLoadLim'}=$choice2;
                    688:   }
1.32      raeburn   689:   elsif ($choice==10) {
1.31      albertel  690:   print(&lt;&lt;END);
1.32      raeburn   691: 10) Allow only secure connections: $securestatus 
1.31      albertel  692: The Lon-CAPA communication daemons lonc and lond can be configured to
                    693: allow only secure connections by default.
                    694: 
                    695: POSSIBLE CHOICES:
                    696: 1) allow only secure connections and don't connect to machines that
                    697:     can not be connected to securely
                    698: 2) allow only secure connections but allow this machine to connect to 
                    699:     machines that don't support secure connections
                    700: 3) allow insecure connections to this machine but only allow connections
                    701:     to machines that support secure connections
                    702: 4) allow insecure connections
                    703: ENTER NEW VALUE (currenly $securenum):
                    704: END
                    705:     my $choice2=&lt;&gt;;
                    706:     chomp($choice2);
                    707:     if      ($choice2 eq '1') {
                    708: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
                    709:     } elsif ($choice2 eq '2') {
                    710: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
                    711:     } elsif ($choice2 eq '3') {
                    712: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
                    713:     } elsif ($choice2 eq '4') {
                    714: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
                    715:     }
                    716:     ($securestatus,$securenum)=&securesetting(%perlvar);
                    717:   }
1.32      raeburn   718:   elsif ($choice==11) {
1.6       harris41  719:     $flag=1;
                    720:   }
                    721:   else {
1.1       harris41  722: 
1.6       harris41  723:   }
                    724: }
1.7       harris41  725:     open(OUT,"&gt;$confdir$filename") or
                    726:       die("Cannot output to $confdir$filename\n");
                    727:     foreach my $key (keys %perlvar) {
                    728:       my $value=$perlvar{$key};
1.8       harris41  729:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.7       harris41  730: PerlSetVar     $key      $value
                    731: END
                    732:     }
                    733:     close(OUT);
1.1       harris41  734: </perlscript>
                    735: </file>
                    736: <file>
                    737: <target dist='default'>loncom/hosts.tab</target>
                    738: <perlscript mode='fg'>
                    739: unless (-l "<TARGET />") {
1.36    ! albertel  740:   my $hostname=`hostname -f`;chomp($hostname);
1.15      harris41  741:   $date=`date -I`; chomp($date);
                    742:   $lonHostID=$perlvar{'lonHostID'};
                    743:   $lonHostID=~s/\W//g;
                    744:   $lineexistflag=0;
                    745:   $hostidexistflag=0;
1.22      albertel  746:   $line2insert=&lt;&lt;END;
1.35      albertel  747: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
1.15      harris41  748: END
1.29      albertel  749:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
1.23      albertel  750:   if ($lonCluster eq 'standalone') {
                    751:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                    752:       die('file generation error');
                    753:       print(OUT $line2insert);
                    754:     close(OUT);
1.27      albertel  755:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
                    756:       die('file generation error');
                    757:       print(OUT $domaininsert);
                    758:     close(OUT);
1.23      albertel  759:   }
1.15      harris41  760:   if ($flag==1) {
1.6       harris41  761:     `rm -f ../hosts.tab`;
1.15      harris41  762:     open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
1.13      harris41  763:     while(&lt;IN&gt;) {
                    764:       if (/^$line2insert$/) {
                    765:         $lineexistflag=1;
                    766:       }
1.15      harris41  767:       if (/^$lonHostID\:/) {
1.13      harris41  768:         $hostidexistflag=1;
                    769:       }
                    770:     }
                    771:     close(IN);
                    772:     if ($hostidexistflag and !$lineexistflag) {
                    773:       print &lt;&lt;END;
                    774: WARNING: $lonHostID already exists inside
1.15      harris41  775: loncapa/loncom/${lonCluster}_hosts.tab.  The entry inside
                    776: ${lonCluster}_hosts.tab does not match your settings.
                    777: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13      harris41  778: with your new values.
                    779: END
1.15      harris41  780:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                    781:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    782:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41  783:          print(OUT $line2insert);
1.13      harris41  784:        close(OUT);
1.15      harris41  785:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41  786:       # email appropriate message
1.34      albertel  787:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  788:     }
                    789:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41  790:       print &lt;&lt;END;
                    791: Entry exists in ${lonCluster}_hosts.tab.
                    792: END
                    793:       `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
                    794:       # email appropriate message
                    795:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  796:     }
1.15      harris41  797:     elsif (!$hostidexistflag and !$lineexistflag) {
                    798:       print &lt;&lt;END;
                    799: New entry for $lonCluster.
1.6       harris41  800: END
1.15      harris41  801:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel  802:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    803:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41  804:          print(OUT $line2insert);
                    805:        close(OUT);
                    806:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                    807:       # email appropriate message
                    808:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel  809:     }
                    810:   }
                    811:   $lineexistflag=0;
                    812:   if ($flag==1) {
                    813:     `rm -f ../domain.tab`;
                    814:     open(IN,'&lt;../'.$lonCluster.'_domain.tab');
                    815:     while(&lt;IN&gt;) {
                    816:       if (/^$domaininsert$/) {
                    817:         $lineexistflag=1;
                    818:       }
                    819:       if (/^$perlvar{'lonDefDomain'}\:/) {
                    820:         $domainexistflag=1;
                    821:       }
                    822:     }
                    823:     close(IN);
                    824:     if ($domainexistflag and !$lineexistflag) {
                    825:       print &lt;&lt;END;
                    826: WARNING: $perlvar{'lonDefDomain'} already exists inside
                    827: loncapa/loncom/${lonCluster}_domain.tab.  The entry inside
                    828: ${lonCluster}_domain.tab does not match your settings.
                    829: The entry inside ${lonCluster}_domain.tab is being replaced
                    830: with your new values.
                    831: END
                    832:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                    833:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                    834:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                    835:          print(OUT $domaininsert);
                    836:        close(OUT);
                    837:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                    838:       # email appropriate message
1.34      albertel  839:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel  840:     }
                    841:     elsif ($domainexistflag and $lineexistflag) {
                    842:       print &lt;&lt;END;
                    843: Entry exists in ${lonCluster}_domain.tab.
                    844: END
                    845:       `ln -s ${lonCluster}_domain.tab ../domain.tab`;
                    846:       # email appropriate message
                    847:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
                    848:     }
                    849:     elsif (!$domainexistflag and !$lineexistflag) {
                    850:       print &lt;&lt;END;
                    851: New entry for $lonCluster.
                    852: END
                    853:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                    854:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                    855:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
                    856:          print(OUT $domaininsert);
                    857:        close(OUT);
                    858:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                    859:       # email appropriate message
                    860:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41  861:     }
                    862:   }
1.1       harris41  863: }
                    864: </perlscript>
                    865: </file>
                    866: </files>
                    867: </piml>

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