File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.35: download - view: text, annotated - select for diffs
Sun Feb 6 07:57:57 2005 UTC (19 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- BUG#2330 removal of IP from hosts.tab, and from the installation process

    1: <!-- updatequery.piml -->
    2: 
    3: <!-- $Id: updatequery.piml,v 1.35 2005/02/06 07:57:57 albertel Exp $ -->
    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>
   33: <target dist='default'>/</target>
   34: <perlscript mode='fg'>
   35: $|=1;
   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
   50: sleep(3);
   51: </perlscript>
   52: </file>
   53: <file>
   54: <target dist='default'>loncom/hosts.tab</target>
   55: <perlscript mode='fg'>
   56: unless (-l "<TARGET />") {
   57:   print(&lt;&lt;END);
   58: 
   59: ===============================================================================
   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
   68: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
   69:                  not be connected to other LON-CAPA machines for now
   70: 3) DEVELOPMENT - you want to do software (not content!) development with
   71:                  this workstation and eventually link it with the
   72:                  workstations of other LON-CAPA software developers.
   73: 4) PRESERVE the existing hosts.tab and domain.tab
   74:                 (/home/httpd/lonTabs/hosts.tab and
   75:                  /home/httpd/lonTabs/domain.tab)
   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:     }
  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:     }
  118:   }
  119:   elsif ($choice==26) {
  120:     $lonCluster='rawhide'; $flag=1;
  121:   }
  122: }
  123: }
  124: </perlscript>
  125: </file>
  126: <file>
  127: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  128: <perlscript mode='fg'>
  129: $|=1;
  130: my $domainDescription;
  131: my $domainTabExtras;
  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
  137: or contact helpdesk\@lon-capa.org.
  138: 
  139: ===============================================================================
  140: The following 4 values are needed to configure LON-CAPA:
  141: * Machine Role
  142: * LON-CAPA Domain Name
  143: * LON-CAPA Machine ID Name, and
  144: * System Administration E-mail Address.
  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: 
  152: END
  153: 
  154: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
  155: close(OUT);
  156: 
  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.
  167: 1) Will this be a library server? (recommended if this is your first install)
  168: 2) Or, will this be an access server?
  169: END
  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: }
  197: 
  198: # need to recommend a machine ID name (ipdomain.l.somenumber)
  199: my $hostname=`hostname`; chomp($hostname);
  200: my $ipdomain='';
  201: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
  202:   $ipdomain=$1;
  203: }
  204: 
  205:   print(&lt;&lt;END);
  206: 
  207: **** Domain ****
  208: [this does NOT need to correspond to internet address domains,
  209:  examples might be "msu" or "bionet" or "vermontcc"]
  210: END
  211: 
  212: # get domain name
  213: # accept if valid, if not valid, tell user and repeat
  214: $flag=0;
  215: my $lonDefDomain;
  216: while (!$flag) {
  217: if ($ipdomain) {
  218: print(&lt;&lt;END);
  219: ENTER LONCAPA DOMAIN [$ipdomain]:
  220: END
  221: }
  222: else {
  223:   print(&lt;&lt;END);
  224: ENTER LONCAPA DOMAIN:
  225: END
  226: }
  227:   my $choice=&lt;&gt;;
  228:   chomp($choice);
  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:   }
  234:   if ($ipdomain and $choice=~/^\s*$/) {
  235:     $choice=$ipdomain;
  236:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  237:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  238:     close(OUT);
  239:     $lonDefDomain=$choice;
  240:     $flag=1;
  241:   }
  242:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
  243:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  244:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  245:     close(OUT);
  246:     $lonDefDomain=$choice;
  247:     $r='l';
  248:     $flag=1;
  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";
  253:   }
  254:   else {
  255:     print "Invalid input (only alphanumeric characters supported).\n";
  256:   }
  257: }
  258: 
  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: 
  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: 
  293:   print(&lt;&lt;END);
  294: 
  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"]
  301: END
  302: # get machine name
  303: # accept if valid, if not valid, tell user and repeat
  304: $flag=0;
  305: while (!$flag) {
  306: if ($ipdomain) {
  307: print(&lt;&lt;END);
  308: ENTER LONCAPA MACHINE ID [$lonHostID]:
  309: END
  310: }
  311: else {
  312:   print(&lt;&lt;END);
  313: ENTER LONCAPA MACHINE ID:
  314: END
  315: }
  316:   my $choice=&lt;&gt;;
  317:   chomp($choice);
  318:   if ($lonHostID and $choice=~/^\s*$/) {
  319:     $choice=$lonHostID;
  320:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  321:     print(OUT 'lonHostID'."\t".$choice."\n");
  322:     close(OUT);
  323:     $lonHostID=$choice;
  324:     $flag=1;
  325:   }
  326:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
  327:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  328:     print(OUT 'lonHostID'."\t".$choice."\n");
  329:     close(OUT);
  330:     $lonHostID=$choice;
  331:     $flag=1;
  332:   }
  333:   else {
  334:     print "Invalid input (only alphanumeric characters supported).\n";
  335:   }
  336: }
  337: 
  338: # get admin e-mail address
  339: # accept if valid, if not valid, tell user and repeat
  340: $flag=0;
  341: my $lonAdmEMail;
  342: while (!$flag) {
  343:   print(&lt;&lt;END);
  344: 
  345: **** System Administrator's E-mail ****
  346: E-mail address of the person who will manage this machine
  347: [should be in the form somebody\@somewhere]
  348: ENTER ADMIN E-MAIL ADDRESS:
  349: END
  350: 
  351:   my $choice=&lt;&gt;;
  352:   chomp($choice);
  353:   if ($choice=~/\@/) {
  354:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  355:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
  356:     close(OUT);
  357:     $lonAdmEMail=$choice;
  358:     $flag=1;
  359:   }
  360:   else {
  361:     print "Invalid input (this needs to look like an e-mail address!).\n";
  362:   }
  363: }
  364: 
  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;
  386:   if ( ($choice=~/\@/) || $choice eq '') {
  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: 
  399: # update loncapa.conf
  400: my $confdir='/etc/httpd/conf/';
  401: #my $confdir='';
  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);
  410: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
  411: 	    }
  412: 	}
  413: 	close(CONFIG);
  414:     }
  415:     $perlvar{'lonHostID'}=$lonHostID;
  416:     $perlvar{'lonDefDomain'}=$lonDefDomain;
  417:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
  418:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
  419:     $perlvar{'lonRole'}=$lonRole;
  420:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  421:        $perlvar{'lonLoadLim'}='2.00';
  422:     }
  423:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  424:        $perlvar{'lonUserLoadLim'}='0';
  425:     }
  426:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  427:        $perlvar{'lonExpire'}='86400';
  428:     }
  429:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  430:        my $lonReceipt='';
  431:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  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);
  447: }
  448: </perlscript>
  449: </file>
  450: <file>
  451: <target dist='default'>/</target>
  452: <perlscript mode='fg'>
  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: }
  468: # read values from loncapa.conf
  469: my $confdir='/etc/httpd/conf/';
  470: my $filename='loncapa.conf';
  471: my %perlvar;
  472: my ($securestatus,$securenum);
  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:     }
  485:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  486:        $perlvar{'lonLoadLim'}='2.00';
  487:     }
  488:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  489:        $perlvar{'lonUserLoadLim'}='0';
  490:     }
  491:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  492:        $perlvar{'lonExpire'}='86400';
  493:     }
  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);
  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:     }
  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:     }
  523:     if (!$domainDescription && $lonCluster ne 'existing') {
  524:        open(IN,'&lt;../'.$lonCluster.'_domain.tab');
  525:        while(&lt;IN&gt;) {
  526:           if (/^$perlvar{'lonDefDomain'}\:/) {
  527: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
  528: 	     chomp($domainDescription);
  529: 	     chomp($domainTabExtras);
  530:              last;
  531:           }
  532:        }
  533:        close(IN);
  534:     }
  535:     if (!$domainDescription) {
  536:        open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
  537:        while(&lt;IN&gt;) {
  538:           if (/^$perlvar{'lonDefDomain'}\:/) {
  539: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
  540: 	     chomp($domainDescription);
  541: 	     chomp($domainTabExtras);
  542:              last;
  543:           }
  544:        }
  545:        close(IN);
  546:     }
  547:    
  548: # implement editing logic below, interactively
  549: # update loncapa.conf until 8 is entered
  550: 
  551: $flag=0;
  552: 
  553: while (!$flag) {
  554:   print(&lt;&lt;END);
  555: 
  556: ===============================================================================
  557: This is now the current configuration of your machine.
  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'}
  562:  5) Support E-mail Address: $perlvar{'lonSupportEMail'}
  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
  569: END
  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: 
  594:   print(&lt;&lt;END);
  595: ENTER A CHOICE OF 1-10 TO CHANGE, otherwise ENTER 11:
  596: END
  597: my $choice=&lt;&gt;;
  598: chomp($choice);
  599:   if ($choice==1) {
  600:   print(&lt;&lt;END);
  601: 1) Domain Name: $perlvar{'lonDefDomain'}
  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):
  606: END
  607:     my $choice2=&lt;&gt;;
  608:     chomp($choice2);
  609:     $perlvar{'lonDefDomain'}=$choice2;
  610:   }
  611:   elsif ($choice==2) {
  612:   print(&lt;&lt;END);
  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') :
  628: END
  629:     my $choice2=&lt;&gt;;
  630:     chomp($choice2);
  631:     $perlvar{'lonHostID'}=$choice2;
  632:   }
  633:   elsif ($choice==4) {
  634:   print(&lt;&lt;END);
  635: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  636: ENTER NEW VALUE:
  637: END
  638:     my $choice2=&lt;&gt;;
  639:     chomp($choice2);
  640:     $perlvar{'lonAdmEMail'}=$choice2;
  641:   }
  642:   elsif ($choice==5) {
  643:   print(&lt;&lt;END);
  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'}
  654: ENTER NEW VALUE (this should be either 'access' or 'library' 
  655:                  if in doubt select 'library'):
  656: END
  657:     my $choice2=&lt;&gt;;
  658:     chomp($choice2);
  659:     $perlvar{'lonRole'}=$choice2;
  660:   }
  661:   elsif ($choice==7) {
  662:   print(&lt;&lt;END);
  663: 7) Cache Expiration Time: $perlvar{'lonExpire'}
  664: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
  665: END
  666:     my $choice2=&lt;&gt;;
  667:     chomp($choice2);
  668:     $perlvar{'lonExpire'}=$choice2;
  669:   }
  670:   elsif ($choice==8) {
  671:   print(&lt;&lt;END);
  672: 8) Server Load: $perlvar{'lonLoadLim'}
  673: ENTER NEW VALUE:
  674: END
  675:     my $choice2=&lt;&gt;;
  676:     chomp($choice2);
  677:     $perlvar{'lonLoadLim'}=$choice2;
  678:   }
  679:   elsif ($choice==9) {
  680:   print(&lt;&lt;END);
  681: 9) User Load: $perlvar{'lonUserLoadLim'}
  682: Numer of users that can login before machine is 'overloaded'
  683: ENTER NEW VALUE (integer value, 0 means there is no limit):
  684: END
  685:     my $choice2=&lt;&gt;;
  686:     chomp($choice2);
  687:     $perlvar{'lonUserLoadLim'}=$choice2;
  688:   }
  689:   elsif ($choice==10) {
  690:   print(&lt;&lt;END);
  691: 10) Allow only secure connections: $securestatus 
  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:   }
  718:   elsif ($choice==11) {
  719:     $flag=1;
  720:   }
  721:   else {
  722: 
  723:   }
  724: }
  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};
  729:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
  730: PerlSetVar     $key      $value
  731: END
  732:     }
  733:     close(OUT);
  734: </perlscript>
  735: </file>
  736: <file>
  737: <target dist='default'>loncom/hosts.tab</target>
  738: <perlscript mode='fg'>
  739: unless (-l "<TARGET />") {
  740:   my $hostname=`hostname`;chomp($hostname);
  741:   $date=`date -I`; chomp($date);
  742:   $lonHostID=$perlvar{'lonHostID'};
  743:   $lonHostID=~s/\W//g;
  744:   $lineexistflag=0;
  745:   $hostidexistflag=0;
  746:   $line2insert=&lt;&lt;END;
  747: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
  748: END
  749:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
  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);
  755:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
  756:       die('file generation error');
  757:       print(OUT $domaininsert);
  758:     close(OUT);
  759:   }
  760:   if ($flag==1) {
  761:     `rm -f ../hosts.tab`;
  762:     open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
  763:     while(&lt;IN&gt;) {
  764:       if (/^$line2insert$/) {
  765:         $lineexistflag=1;
  766:       }
  767:       if (/^$lonHostID\:/) {
  768:         $hostidexistflag=1;
  769:       }
  770:     }
  771:     close(IN);
  772:     if ($hostidexistflag and !$lineexistflag) {
  773:       print &lt;&lt;END;
  774: WARNING: $lonHostID already exists inside
  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
  778: with your new values.
  779: END
  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");
  783:          print(OUT $line2insert);
  784:        close(OUT);
  785:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
  786:       # email appropriate message
  787:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  788:     }
  789:     elsif ($hostidexistflag and $lineexistflag) {
  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`;
  796:     }
  797:     elsif (!$hostidexistflag and !$lineexistflag) {
  798:       print &lt;&lt;END;
  799: New entry for $lonCluster.
  800: END
  801:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
  802:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
  803:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
  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`;
  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
  839:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
  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`;
  861:     }
  862:   }
  863: }
  864: </perlscript>
  865: </file>
  866: </files>
  867: </piml>

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