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

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

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