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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.66    ! raeburn     3: <!-- $Id: updatequery.piml,v 1.65 2010/07/21 00:32:44 raeburn 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.54      albertel   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.40      albertel   73: 4) RUNNING YOUR OWN CLUSTER - this machine is not in the standard LON-CAPA
                     74:                  clusters and won't be in the future and you want the existing
                     75:                  hosts.tab and domain.tab files to be left alone.
                     76:                  (This choice is unlikely what you want to select.)
1.22      albertel   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;
1.52      albertel  100:     foreach my $file ('hosts.tab','dns_hosts.tab',
                    101:                       'domain.tab','dns_domain.tab') {
                    102:         if (-e '/home/httpd/lonTabs/'.$file) {
                    103: 	    `cp /home/httpd/lonTabs/$file ../existing_$file`;
                    104:         }
                    105:         else {
                    106: 	    print &lt;&lt;END;
                    107: There is no existing /home/httpd/lonTabs/$file
1.22      albertel  108: END
1.52      albertel  109:             die('');
                    110:         }
1.27      albertel  111:     }
1.22      albertel  112:   }
                    113:   elsif ($choice==26) {
                    114:     $lonCluster='rawhide'; $flag=1;
                    115:   }
                    116: }
                    117: }
                    118: </perlscript>
                    119: </file>
                    120: <file>
1.10      harris41  121: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1       harris41  122: <perlscript mode='fg'>
1.4       harris41  123: $|=1;
1.20      albertel  124: my $domainDescription;
1.29      albertel  125: my $domainTabExtras;
1.43      raeburn   126: my $primaryLibServer;
1.60      raeburn   127: my $protocol;
1.65      raeburn   128: my $intdom;
1.43      raeburn   129: my @libservers = ();
1.1       harris41  130: unless (-e "<TARGET />") {
                    131:   print(&lt;&lt;END);
                    132:            WELCOME TO LON-CAPA!
                    133: 
                    134: If you have questions, please visit http://install.lon-capa.org
1.32      raeburn   135: or contact helpdesk\@lon-capa.org.
1.1       harris41  136: 
                    137: ===============================================================================
1.4       harris41  138: The following 4 values are needed to configure LON-CAPA:
                    139: * Machine Role
1.8       harris41  140: * LON-CAPA Domain Name
                    141: * LON-CAPA Machine ID Name, and
1.47      albertel  142: * Server Administration E-mail Address.
1.32      raeburn   143: ===============================================================================
                    144: 
                    145: In addition, a Support E-mail Address can also be included. If
                    146: an address is included then one of the options in the LON-CAPA 
                    147: help menu will be a link to a form that a user will complete to
                    148: request LON-CAPA help.  
                    149: 
1.1       harris41  150: END
1.3       harris41  151: 
1.4       harris41  152: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
                    153: close(OUT);
                    154: 
1.3       harris41  155: # query for Machine Role
                    156:   print(&lt;&lt;END);
                    157: **** Machine Role ****
                    158: Library server (recommended if first-time installation of LON-CAPA):
                    159:    Servers that are repositories of authoritative educational resources.
                    160:    These servers also provide the construction space by which instructors
                    161:    assemble their classroom online material.
                    162: Access server:
                    163:    Servers that load-balance high-traffic delivery of educational resources
                    164:    over the world-wide web.
1.4       harris41  165: 1) Will this be a library server? (recommended if this is your first install)
1.3       harris41  166: 2) Or, will this be an access server?
                    167: END
1.4       harris41  168: my $flag=0;
                    169: my $r='';
                    170: my $lonRole;
                    171: while (!$flag) {
                    172:   print "ENTER A CHOICE OF 1 or 2:\n";
                    173:   my $choice=&lt;&gt;;
                    174:   chomp($choice);
                    175:   if ($choice==1) {
                    176:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    177:     print(OUT 'lonRole'."\t".'library'."\n");
                    178:     close(OUT);
                    179:     $lonRole='library';
                    180:     $r='l';
                    181:     $flag=1;
                    182:   }
                    183:   elsif ($choice==2) {
                    184:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    185:     print(OUT 'lonRole'."\t".'access'."\n");
                    186:     close(OUT);
                    187:     $lonRole='access';
                    188:     $r='a';
                    189:     $flag=2;
                    190:   }
                    191:   else {
                    192: 
                    193:   }
                    194: }
1.3       harris41  195: 
                    196: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.36      albertel  197: my $hostname=`hostname -f`; chomp($hostname);
1.4       harris41  198: my $ipdomain='';
                    199: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
                    200:   $ipdomain=$1;
                    201: }
1.1       harris41  202: 
                    203:   print(&lt;&lt;END);
                    204: 
1.8       harris41  205: **** Domain ****
1.45      www       206: [This does NOT need to correspond to internet address domains.
                    207:  Please make this name short AND descriptive of your organization.
                    208:  Domain names are close to impossible to change later!!!
                    209:  Good examples might be "msu" or "bionet" or "vermontcc".
                    210:  Bad examples are "physics" (too general)
1.37      www       211:    or "michiganstateuniversity" (too long)
                    212:    or "msuedu" (internet domain, just make it "msu")
1.45      www       213:    or "msuphysics" (only if there is a good reason to limit to department
                    214:                     - we don't know of one)
1.37      www       215:    or "mydomain" (what is that?)
1.45      www       216:  Avoid multiple domains at the same institution, even if it means that you 
                    217:  have to actually work together with your colleagues. You can still run
                    218:  multiple library servers within the same domain.
                    219:  If this domain is eventually going to be part of the main production
                    220:  cluster, you MUST contact the LON-CAPA group at MSU (loncapa@loncapa.org)
                    221:  to have a domain name assigned, and then use it exactly as given. This is
                    222:  also true for test installs that might eventually turn into production setups.
                    223:  Stop now if you didn't do so.]
1.1       harris41  224: END
1.8       harris41  225: 
                    226: # get domain name
1.1       harris41  227: # accept if valid, if not valid, tell user and repeat
1.4       harris41  228: $flag=0;
1.8       harris41  229: my $lonDefDomain;
1.4       harris41  230: while (!$flag) {
                    231: if ($ipdomain) {
                    232: print(&lt;&lt;END);
1.8       harris41  233: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4       harris41  234: END
                    235: }
                    236: else {
                    237:   print(&lt;&lt;END);
1.8       harris41  238: ENTER LONCAPA DOMAIN:
1.4       harris41  239: END
                    240: }
                    241:   my $choice=&lt;&gt;;
                    242:   chomp($choice);
1.18      harris41  243:   my $bad_domain_flag=0;
1.41      albertel  244:   my @bad_domain_names=('res','raw','userfiles','priv','adm','uploaded',
                    245: 	'editupload');
1.18      harris41  246:   foreach my $bad (@bad_domain_names) {
                    247:     $bad_domain_flag=1 if $choice eq $bad;
                    248:   }
1.37      www       249:   if ($choice=~/capa/i) {
                    250:      $bad_domain_flag=1;
                    251:   }
1.8       harris41  252:   if ($ipdomain and $choice=~/^\s*$/) {
                    253:     $choice=$ipdomain;
1.4       harris41  254:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  255:     print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4       harris41  256:     close(OUT);
1.8       harris41  257:     $lonDefDomain=$choice;
1.4       harris41  258:     $flag=1;
1.51      albertel  259:   } elsif (length($choice)>35) {
1.37      www       260:     print "Name too long\n";
                    261:   } elsif (length($choice)<2) {
                    262:     print "Name too short\n";
1.38      www       263:   } elsif ($bad_domain_flag) {
                    264:     print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
                    265:     print "Please try something different than '$choice'\n";
1.51      albertel  266:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
1.4       harris41  267:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  268:     print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4       harris41  269:     close(OUT);
1.8       harris41  270:     $lonDefDomain=$choice;
                    271:     $r='l';
1.4       harris41  272:     $flag=1;
1.37      www       273:   } else {
1.51      albertel  274:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.4       harris41  275:   }
                    276: }
1.1       harris41  277: 
1.20      albertel  278: 
                    279: # get domain description
                    280: # accept if valid, if not valid, tell user and repeat
                    281: $flag=0;
                    282: 
                    283: while (!$flag) {
                    284:   print(&lt;&lt;END);
                    285: 
                    286: **** Domain Description ****
                    287: String describing the domain, to be shown to users.
                    288: [Example, msu is Michigan State University]
                    289: ENTER DOMAIN DESCRIPTION:
                    290: END
                    291: 
                    292:   my $choice=&lt;&gt;;
                    293:   chomp($choice);
                    294:   if ($choice!~/:/) {
                    295:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    296:     print(OUT 'domainDescription'."\t".$choice."\n");
                    297:     close(OUT);
                    298:     $domainDescription=$choice;
                    299:     $flag=1;
                    300:   }
                    301:   else {
                    302:     print "Invalid input (no ':' allowed).\n";
                    303:   }
                    304: }
                    305: 
1.8       harris41  306: my $lonHostID;
                    307: if ($lonDefDomain) {
                    308:   $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
                    309:                                               # against the hosts.tab
                    310: }
                    311: 
1.1       harris41  312:   print(&lt;&lt;END);
                    313: 
1.8       harris41  314: **** Machine ID Name ****
1.45      www       315: [This does NOT need to correspond to internet address names;
1.8       harris41  316:  this name MUST be unique to the whole LON-CAPA network;
1.45      www       317:  we recommend that you use a name based off of your institution.
                    318:  Good examples: "msul1" or "bioneta2".
                    319:  Bad examples: "loncapabox" or "studentsinside".
1.37      www       320:  Note that machine names are very hard to change later.]
1.1       harris41  321: END
1.8       harris41  322: # get machine name
1.1       harris41  323: # accept if valid, if not valid, tell user and repeat
1.4       harris41  324: $flag=0;
                    325: while (!$flag) {
                    326: if ($ipdomain) {
                    327: print(&lt;&lt;END);
1.8       harris41  328: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4       harris41  329: END
                    330: }
                    331: else {
                    332:   print(&lt;&lt;END);
1.8       harris41  333: ENTER LONCAPA MACHINE ID:
1.4       harris41  334: END
                    335: }
                    336:   my $choice=&lt;&gt;;
                    337:   chomp($choice);
1.37      www       338:   if ($choice=~/capa/i) {
                    339:     print "Invalid input (names containing 'capa' are reserved).\n";
                    340:   } elsif ($lonHostID and $choice=~/^\s*$/) {
1.8       harris41  341:     $choice=$lonHostID;
1.4       harris41  342:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  343:     print(OUT 'lonHostID'."\t".$choice."\n");
1.4       harris41  344:     close(OUT);
1.8       harris41  345:     $lonHostID=$choice;
1.4       harris41  346:     $flag=1;
1.51      albertel  347:   } elsif (length($choice)>45) {
1.37      www       348:     print "Name too long\n";
                    349:   } elsif (length($choice)<4) {
                    350:     print "Name too short\n";
1.51      albertel  351:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
1.4       harris41  352:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.8       harris41  353:     print(OUT 'lonHostID'."\t".$choice."\n");
1.4       harris41  354:     close(OUT);
1.8       harris41  355:     $lonHostID=$choice;
1.4       harris41  356:     $flag=1;
1.37      www       357:   } else {
1.51      albertel  358:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.4       harris41  359:   }
                    360: }
1.1       harris41  361: 
1.43      raeburn   362: # get primary library server in domain
                    363: if ($lonRole eq 'library') {
                    364:     if (!grep/^\Q$lonHostID\E$/,@libservers) {
                    365:         push(@libservers,$lonHostID);
                    366:     } 
                    367:     if (@libservers == 1) {
                    368:         $primaryLibServer = $libservers[0];
                    369:     }
                    370: }
                    371: while (!$flag) {
                    372:   print(&lt;&lt;END);
                    373: **** Domain's Primary Library Server ID ****
                    374: This should be the LON-CAPA machine ID of a library server in your 
                    375: domain.  If you only have a single library server in your domain, then
                    376: the Primary Library server ID will be the machine ID of that server. 
                    377: This server will be where domain data which are not associated with any
                    378: specific home library server will be stored (e.g., e-mail broadcast by
                    379: administrators to users in the domain).
                    380: END
                    381:     if (defined($primaryLibServer)) {
                    382:         print(&lt;&lt;END);
                    383: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:
                    384: END
                    385:     } elsif (@libservers > 0) {
                    386:         print(&lt;&lt;END);
                    387: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]]
                    388: END
                    389:     } else {
                    390:         print (&lt;&lt;END);
                    391: No library servers could be identified for this domain.  If you have already installed LON-CAPA on a different server (designated as a library server) in this domain, please enter the LONCAPA MACHINE ID of that server.  If not, you will need to install a LON-CAPA library server.  Enter the MACHINE ID of the server you plan to designate as a library server.
                    392: END
                    393:     }
                    394: 
                    395:     my $choice=&lt;&gt;;
                    396:     chomp($choice);
                    397:     if ($primaryLibServer and $choice=~/^\s*$/) {
                    398:         $choice=$primaryLibServer;
                    399:         open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    400:         print(OUT 'primaryLibServer'."\t".$choice."\n");
                    401:         close(OUT);
                    402:         $flag=1;
1.51      albertel  403:     } elsif (length($choice)>35) {
1.43      raeburn   404:         print "Name too long\n";
                    405:     } elsif (length($choice)<4) {
                    406:         print "Name too short\n";
1.51      albertel  407:     } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
1.43      raeburn   408:         open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    409:         print(OUT 'primaryLibServer'."\t".$choice."\n");
                    410:         close(OUT);
                    411:         $primaryLibServer=$choice;
                    412:         $flag=1;
                    413:     } else {
1.51      albertel  414:         print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.43      raeburn   415:     }
                    416: }
                    417: 
                    418: 
1.32      raeburn   419: # get admin e-mail address
1.4       harris41  420: # accept if valid, if not valid, tell user and repeat
                    421: $flag=0;
1.9       harris41  422: my $lonAdmEMail;
1.4       harris41  423: while (!$flag) {
1.1       harris41  424:   print(&lt;&lt;END);
                    425: 
1.55      albertel  426: **** Server Administrators E-mail ****
1.1       harris41  427: E-mail address of the person who will manage this machine
1.4       harris41  428: [should be in the form somebody\@somewhere]
1.32      raeburn   429: ENTER ADMIN E-MAIL ADDRESS:
1.1       harris41  430: END
                    431: 
1.4       harris41  432:   my $choice=&lt;&gt;;
                    433:   chomp($choice);
                    434:   if ($choice=~/\@/) {
                    435:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
1.9       harris41  436:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4       harris41  437:     close(OUT);
1.9       harris41  438:     $lonAdmEMail=$choice;
1.4       harris41  439:     $flag=1;
                    440:   }
                    441:   else {
                    442:     print "Invalid input (this needs to look like an e-mail address!).\n";
                    443:   }
                    444: }
                    445: 
1.32      raeburn   446: 
                    447: # get support e-mail address
                    448: # accept if valid, if not valid, tell user and repeat
                    449: $flag=0;
                    450: my $lonSupportEMail;
                    451: while (!$flag) {
                    452:   print(&lt;&lt;END);
                    453: 
                    454: **** Support E-mail ****
                    455: E-mail address of the person who will receive 
                    456: help requests from LON-CAPA users who access 
                    457: the system via this server. If the address is left blank,
                    458: then a help support form will not be displayed 
                    459: as part of the help menu.
                    460: [should be in the form somebody\@somewhere]
                    461: ENTER SUPPORT E-MAIL ADDRESS:
                    462: END
                    463: 
                    464:   my $choice=&lt;&gt;;
                    465:   chomp($choice);
                    466:   $choice =~ s/\s//g;
1.33      albertel  467:   if ( ($choice=~/\@/) || $choice eq '') {
1.32      raeburn   468:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    469:     print(OUT 'lonSupportEMail'."\t".$choice."\n");
                    470:     close(OUT);
                    471:     $lonSupportEMail=$choice;
                    472:     $flag=1;
                    473:   }
                    474:   else {
                    475:     print "Invalid input (this either needs to be blank, or look like an e-mail address!).\n";
                    476:   }
                    477: }
                    478: 
1.60      raeburn   479: while (!$flag) {
                    480:   print(&lt;&lt;END);
                    481: 
                    482: ****  Web Server Protocol ****
                    483: If you plan to run the Apache server with SSL enabled, 
                    484: the protocol should be: https; otherwise it should be http.
                    485: ENTER WEB SERVER PROTOCOL:
                    486: END
                    487: 
                    488:   my $choice=&lt;&gt;;
                    489:   chomp($choice);
1.65      raeburn   490:   if ($choice =~ /^https?$/) {
1.60      raeburn   491:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    492:     print(OUT 'protocol'."\t".$choice."\n");
                    493:     close(OUT);
                    494:     $protocol=$choice;
                    495:     $flag=1;
                    496:   }
                    497:   else {
                    498:     print "Invalid input (only http or https allowed).\n";
                    499:   }
                    500: }
1.32      raeburn   501: 
1.65      raeburn   502: while (!$flag) {
                    503:   print(&lt;&lt;END);
                    504: 
                    505: ****  Internet Domain Name of Your Institution ****
                    506: 
                    507: The internet domain name used for servers at your institution 
                    508: should be provided.  This will be similar to: ustate.edu or
                    509: topcollege.ac.uk or my.hostingcompany.com, i.e., the part of
                    510: a server hostname which indicates to which organization the 
                    511: server belongs.
                    512: 
                    513: ENTER INTERNET DOMAIN NAME:
                    514: END
                    515: 
                    516:   my $choice=&lt;&gt;;
                    517:   chomp($choice);
                    518:   if ($choice =~/[^.]+\.[^.]+/) {
                    519:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    520:     print(OUT 'internet domain'."\t".$intdom."\n");
                    521:     close(OUT);
                    522:     $intdom=$choice;
                    523:     $flag=1;
                    524:   }
                    525:   else {
                    526:     print "Invalid input (must be at least two levels separated by .  - e.g., ustate.edu).\n";
                    527:   }
                    528: }
                    529: 
                    530: 
1.1       harris41  531: # update loncapa.conf
1.49      raeburn   532: my $confdir = '/etc/httpd/conf/';
1.64      raeburn   533: if ('<DIST />' eq 'sles10' || '<DIST />' eq 'sles11' || '<DIST />' eq 'suse10.1' || '<DIST />' eq 'suse10.2' || '<DIST />' eq 'suse10.3' || '<DIST />' eq 'suse11.1' || '<DIST />' eq 'suse11.2' || '<DIST />' eq 'debian5' || '<DIST />' eq 'ubuntu6' || '<DIST />' eq 'ubuntu8') {
1.49      raeburn   534:      $confdir = '/etc/apache2/';
                    535: }   
1.5       harris41  536: my $filename='loncapa.conf';
                    537: my %perlvar;
                    538:     if (-e "$confdir$filename") {
                    539: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
                    540: 	while (my $configline=&lt;CONFIG&gt;) {
                    541: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    542: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    543: 		chomp($varvalue);
1.12      harris41  544: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5       harris41  545: 	    }
                    546: 	}
                    547: 	close(CONFIG);
                    548:     }
                    549:     $perlvar{'lonHostID'}=$lonHostID;
                    550:     $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9       harris41  551:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.32      raeburn   552:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
1.5       harris41  553:     $perlvar{'lonRole'}=$lonRole;
1.16      harris41  554:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5       harris41  555:        $perlvar{'lonLoadLim'}='2.00';
                    556:     }
1.25      albertel  557:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    558:        $perlvar{'lonUserLoadLim'}='0';
                    559:     }
1.16      harris41  560:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5       harris41  561:        $perlvar{'lonExpire'}='86400';
                    562:     }
1.16      harris41  563:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5       harris41  564:        my $lonReceipt='';
1.11      harris41  565:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5       harris41  566:        my @alnum=(0..9,a..z);
                    567:        foreach my $i (1..20) {
                    568: 	 $lonReceipt.=$alnum[int(rand(36))];
                    569:        }
                    570:        $perlvar{'lonReceipt'}=$lonReceipt;
                    571:     }
                    572:     open(OUT,"&gt;$confdir$filename") or
                    573:       die("Cannot output to $confdir$filename\n");
                    574:     foreach my $key (keys %perlvar) {
                    575:       my $value=$perlvar{$key};
1.49      raeburn   576:       my $line = "PerlSetVar     $key      $value"; 
                    577:       if ($value eq '') {
                    578:           $line = '#'.$line;
                    579:       }
1.5       harris41  580:       print(OUT &lt;&lt;END);
1.49      raeburn   581: $line
1.5       harris41  582: END
                    583:     }
                    584:     close(OUT);
1.1       harris41  585: }
                    586: </perlscript>
                    587: </file>
                    588: <file>
1.49      raeburn   589: <target dist='default'>/etc/httpd/conf/</target>
1.64      raeburn   590: <target dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 debian5 ubuntu6 ubuntu8'>/etc/apache2/</target>
1.1       harris41  591: <perlscript mode='fg'>
1.31      albertel  592: sub securesetting {
                    593:     my (%perlvar)=@_;
                    594:     my $securestatus='unknown';
                    595:     my $securenum='';
                    596:     if      ( $perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    597: 	$securestatus='no';                  $securenum='4';
                    598:     } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    599: 	$securestatus='lond';                $securenum='3';
                    600:     } elsif (!$perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    601: 	$securestatus='lonc';                $securenum='2';
                    602:     } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    603: 	$securestatus='yes (lond and lonc)'; $securenum='1';
                    604:     }
                    605:     return ($securestatus,$securenum);
                    606: }
1.1       harris41  607: # read values from loncapa.conf
1.49      raeburn   608: my $confdir = "<TARGET />";
1.5       harris41  609: my $filename='loncapa.conf';
                    610: my %perlvar;
1.31      albertel  611: my ($securestatus,$securenum);
1.5       harris41  612:     if (-e "$confdir$filename") {
                    613: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    614:           die("Can't read $confdir$filename");
                    615: 	while (my $configline=&lt;CONFIG&gt;) {
                    616: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    617: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    618: 		chomp($varvalue);
                    619: 		$perlvar{$varname}=$varvalue;
                    620: 	    }
                    621: 	}
                    622: 	close(CONFIG);
                    623:     }
1.16      harris41  624:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
                    625:        $perlvar{'lonLoadLim'}='2.00';
                    626:     }
1.25      albertel  627:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    628:        $perlvar{'lonUserLoadLim'}='0';
                    629:     }
1.16      harris41  630:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
                    631:        $perlvar{'lonExpire'}='86400';
                    632:     }
1.31      albertel  633:     unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
                    634:        $perlvar{'londAllowInsecure'}='1';
                    635:     }
                    636:     unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
                    637:        $perlvar{'loncAllowInsecure'}='1';
                    638:     }
                    639:     ($securestatus,$securenum)=&securesetting(%perlvar);
1.16      harris41  640:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
                    641:        my $lonReceipt='';
                    642:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
                    643:        my @alnum=(0..9,a..z);
                    644:        foreach my $i (1..20) {
                    645: 	 $lonReceipt.=$alnum[int(rand(36))];
                    646:        }
                    647:        $perlvar{'lonReceipt'}=$lonReceipt;
                    648:     }
1.7       harris41  649: my %perlvarstatic;
                    650:     if (-e "${confdir}loncapa_apache.conf") {
                    651: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
                    652:           die("Can't read ${confdir}loncapa_apache.conf");
                    653: 	while (my $configline=&lt;CONFIG&gt;) {
                    654: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    655: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    656: 		chomp($varvalue);
                    657: 		$perlvarstatic{$varname}=$varvalue;
                    658: 	    }
                    659: 	}
                    660: 	close(CONFIG);
                    661:     }
1.55      albertel  662: 
                    663:     my (@hosts_files, @domain_files);
                    664:     if ( $lonCluster ne 'existing') {
                    665: 	push(@domain_files,'../'.$lonCluster.'_domain.tab',
                    666: 	     '../'.$lonCluster.'_dns_domain.tab');
                    667: 	push(@hosts_files,'../'.$lonCluster.'_hosts.tab',
                    668: 	     '../'.$lonCluster.'_dns_hosts.tab');
                    669:     }
                    670:     push(@domain_files,'/home/httpd/lonTabs/domain.tab',
                    671:          '/home/httpd/lonTabs/dns_domain.tab');
                    672:     push(@hosts_files,'/home/httpd/lonTabs/hosts.tab',
                    673:          '/home/httpd/lonTabs/dns_hosts.tab');
                    674: 
1.23      albertel  675:     if (!$domainDescription) {
1.55      albertel  676: 	foreach my $file (@domain_files) {
                    677: 	    open(IN,'&lt;'.$file);
                    678: 	    while(my $line = &lt;IN&gt;) {
                    679: 		if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
                    680: 		    (undef,$domainDescription,$domainTabExtras)=split(/:/,$line,3);
                    681: 		    chomp($domainDescription);
                    682: 		    chomp($domainTabExtras);
1.60      raeburn   683: 		    # the remaining field (primary lib server) is handled later
1.55      albertel  684: 		    $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
                    685: 		    last;
                    686: 		}
                    687: 	    }
                    688: 	    close(IN);
                    689: 	    last if ($domainDescription);
                    690: 	}
1.23      albertel  691:     }
1.55      albertel  692: 
1.60      raeburn   693:     if (!$protocol) {
                    694:         foreach my $file (@hosts_files) {
                    695:             open(IN,'&lt;'.$file);
                    696:             while(my $line = &lt;IN&gt;) {
1.66    ! raeburn   697:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:(https?)/) {
1.60      raeburn   698:                     $protocol = $1;
1.66    ! raeburn   699:                     chomp($protocol);
1.60      raeburn   700:                     last;
                    701:                 }
                    702:             }
                    703:         }
                    704:     }
                    705: 
                    706:     if (!$protocol) {
                    707:         $protocol = 'http';
                    708:     }
                    709: 
1.65      raeburn   710:     if (!$intdom) {
                    711:         foreach my $file (@hosts_files) {
                    712:             open(IN,'&lt;'.$file);
                    713:             while(my $line = &lt;IN&gt;) {
1.66    ! raeburn   714:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:https?\:([^:]+)/) {
1.65      raeburn   715:                     $intdom = $1;
1.66    ! raeburn   716:                     chomp($intdom);
1.65      raeburn   717:                     last;
                    718:                 }
                    719:             }
                    720:         }
                    721:     }
                    722: 
1.55      albertel  723:     while(!$primaryLibServ && (@hosts_file || @domain_files)) {
                    724: 	my $file = shift(@domain_files);
                    725:         open(IN,'&lt;'.$file);
                    726:         while(my $line = &lt;IN&gt;) {
                    727:             if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
                    728: 		$primaryLibServer=(split(/:/,$line))[8];
1.43      raeburn   729:                 chomp($primaryLibServer);
                    730:             }
                    731:         }
                    732:         close(IN);
1.55      albertel  733: 	last if ($primaryLibServer);
                    734: 	$file = shift(@hosts_files);
                    735: 	open(IN,'&lt;'.$file);
                    736: 	while(my $line = &lt;IN&gt;) {
                    737: 	    if ($line =~ /^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                    738: 		push(@libservers,$1);
                    739: 	    }
                    740: 	}
1.58      albertel  741: 	# make list unique
                    742: 	@libservers = keys(%{{ map { $_ => 1 } (@libservers) }});
1.55      albertel  743: 	close(IN);
                    744: 	if (@libservers == 1) {
                    745: 	    $primaryLibServer = $libservers[0];
                    746: 	}
1.43      raeburn   747:     }
1.23      albertel  748:    
1.6       harris41  749: # implement editing logic below, interactively
1.65      raeburn   750: # update loncapa.conf until 14 is entered
1.6       harris41  751: 
                    752: $flag=0;
1.17      harris41  753: 
1.6       harris41  754: while (!$flag) {
1.1       harris41  755:   print(&lt;&lt;END);
                    756: 
                    757: ===============================================================================
                    758: This is now the current configuration of your machine.
1.31      albertel  759:  1) Domain Name: $perlvar{'lonDefDomain'}
                    760:  2) Domain Description: $domainDescription
                    761:  3) Machine Name: $perlvar{'lonHostID'}
1.43      raeburn   762:  4) ID of primary library server for domain: $primaryLibServer
1.47      albertel  763:  5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.43      raeburn   764:  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.60      raeburn   765:  7) Web Server Protocol (http or https): $protocol 
1.65      raeburn   766:  8) Internet Domain Name: $intdom 
                    767:  9) Role: $perlvar{'lonRole'}
                    768: 10) Cache Expiration Time: $perlvar{'lonExpire'}
                    769: 11) Server Load: $perlvar{'lonLoadLim'}
                    770: 12) User Load: $perlvar{'lonUserLoadLim'}
                    771: 13) Allow only secure connections: $securestatus 
                    772: 14) Everything is correct up above
1.6       harris41  773: END
1.38      www       774: 
1.54      albertel  775: my @error;
1.38      www       776: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
1.51      albertel  777:    if (length($v)>35) { $error.="\nName $v too long"; }		
1.38      www       778:    if (length($v)<2) { $error.="\nName $v too short"; }
1.39      albertel  779:    if ($v=~/capa/i) {
                    780: 	if ($v!~/^oucapa\d+$/ && 
                    781: 	    ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
1.54      albertel  782: 		 push(@error,"Name $v contains 'capa'");
1.39      albertel  783: 	}
                    784:    }
1.41      albertel  785:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    786: 	'editupload') {
1.54      albertel  787:       push(@error,"\nName $v reserved.") if $v eq $bad;
1.38      www       788:    }
1.54      albertel  789:    if ($v=~/[^\w\-.]/) { push(@error,"Name $v contains special characters"); }
1.38      www       790: }
1.53      albertel  791: if ($domainDescription =~ /^\s*$/) {
1.54      albertel  792:    push(@error,"Domain Description is blank.");
1.53      albertel  793: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
1.54      albertel  794:    push(@error,"Domain Description contains special characters.");
1.38      www       795: } 
                    796: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
1.54      albertel  797:    unless ($v=~/^[\d+\.]+$/) { push(@error,"Number expected instead of $v"); }
1.38      www       798: }
                    799: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
1.54      albertel  800:    push(@error,"Invalid Role");
1.17      harris41  801: }
1.43      raeburn   802: 
1.60      raeburn   803: unless (($protocol eq 'http') || ($protocol eq 'https')) {
                    804:    push(@error,"Invalid Protocol (must be http or https");
                    805: }
                    806: 
1.65      raeburn   807: if (!defined($intdom)) { 
                    808:    push(@error,"No internet domain name designated. Enter something like ustate.edu"); 
                    809: } elsif ($intdom !~ /^[^.]+\.\w{2,6}$/) {
                    810:    push(@error,"Invalid Internet domain name (must be at least two levels separated by .  - e.g., ustate.edu");
                    811: }
                    812: 
1.43      raeburn   813: if (!defined($primaryLibServer)) {
                    814:    if (@libservers > 0) {
1.54      albertel  815:        push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers)));
1.43      raeburn   816:    } else {
1.54      albertel  817:        push(@error,"No library servers in this domain (including current server)");
1.43      raeburn   818:    }
                    819: } else {
1.54      albertel  820:    if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID:  $primaryLibServer too long"); }
                    821:    if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID:  $primaryLibServer too short"); }
1.43      raeburn   822:    if ($primaryLibServer =~/capa/i) {
                    823:         if ($primaryLibServer!~/^oucapa\d+$/ &&
                    824:             ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
1.54      albertel  825:                  push(@error,"Primary library server ID $primaryLibServer contains 'capa'")
1.43      raeburn   826:         }
                    827:    }
                    828:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    829:         'editupload') {
1.54      albertel  830:       push(@error,"Primary library server ID $primaryLibServer reserved.") if $primaryLibServer eq $bad;
1.43      raeburn   831:    }
1.54      albertel  832:    if ($primaryLibServer=~/[^\w\-.]/) { push(@error,"Primary library server ID $primaryLibServer contains special characters"); }
1.43      raeburn   833: }
                    834: 
                    835: 
1.54      albertel  836: if (@error) { print "\n*** ERRORS: \n\t".join("\n\t",@error)."\n"; }
1.6       harris41  837:   print(&lt;&lt;END);
1.65      raeburn   838: ENTER A CHOICE OF 1-13 TO CHANGE, otherwise ENTER 14:
1.1       harris41  839: END
1.5       harris41  840: my $choice=&lt;&gt;;
                    841: chomp($choice);
1.6       harris41  842:   if ($choice==1) {
                    843:   print(&lt;&lt;END);
1.16      harris41  844: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  845: ENTER NEW VALUE (this is an internal value used to identify a group of
                    846:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    847:                  using a part of your actual DNS domain. For example, for
                    848:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  849: END
                    850:     my $choice2=&lt;&gt;;
                    851:     chomp($choice2);
1.8       harris41  852:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  853:   }
                    854:   elsif ($choice==2) {
                    855:   print(&lt;&lt;END);
1.20      albertel  856: 2) Domain Description: $domainDescription
                    857: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    858:                  and punctuation are fine except for ':'):
                    859: END
                    860:     my $choice2=&lt;&gt;;
                    861:     chomp($choice2);
                    862:     $domainDescription=$choice2;
                    863:   }
                    864:   elsif ($choice==3) {
                    865:   print(&lt;&lt;END);
                    866: 3) Machine Name: $perlvar{'lonHostID'}
                    867: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    868:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    869:                  if you are in the domain 'example' and are the first library
                    870:                  server you enter 'examplel1') :
1.6       harris41  871: END
                    872:     my $choice2=&lt;&gt;;
                    873:     chomp($choice2);
1.8       harris41  874:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  875:   }
1.20      albertel  876:   elsif ($choice==4) {
1.6       harris41  877:   print(&lt;&lt;END);
1.43      raeburn   878: 4) ID of primary library server for domain: $primaryLibServer
                    879: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
                    880:                  your domain; it cannot contain any of '_' '-' '.' or ':'. 
                    881:                  This server will be where domain data which are not 
                    882:                  associated with any specific home library server
                    883:                  will be stored (e.g., e-mail broadcast by Domain Coordinators
                    884:                  to users in the domain).
                    885: END
                    886:     my $choice2=&lt;&gt;;
                    887:     chomp($choice2);
                    888:     $primaryLibServer=$choice2;
                    889:   }
                    890:   elsif ($choice==5) {
                    891:   print(&lt;&lt;END);
1.47      albertel  892: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  893: ENTER NEW VALUE:
                    894: END
                    895:     my $choice2=&lt;&gt;;
                    896:     chomp($choice2);
1.9       harris41  897:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  898:   }
1.43      raeburn   899:   elsif ($choice==6) {
1.6       harris41  900:   print(&lt;&lt;END);
1.43      raeburn   901: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.32      raeburn   902: ENTER NEW VALUE:
                    903: END
                    904:     my $choice2=&lt;&gt;;
                    905:     chomp($choice2);
                    906:     $perlvar{'lonSupportEMail'}=$choice2;
                    907:   }
1.43      raeburn   908:   elsif ($choice==7) {
1.32      raeburn   909:   print(&lt;&lt;END);
1.60      raeburn   910: 7) Server Protocol (http or https): 
                    911: ENTER NEW VALUE: (this should be either 'http' or 'https'
                    912:                  if in doubt set to 'http'):
                    913: END
                    914:     my $choice2=&lt;&gt;;
                    915:     chomp($choice2);
                    916:     $protocol=$choice2;
                    917:   }
                    918:   elsif ($choice==8) {
                    919:   print(&lt;&lt;END);
1.65      raeburn   920: 8) Internet Domain Name of Institution
                    921: ENTER NEW VALUE: 
                    922: 
                    923: END
                    924:     my $choice2=&lt;&gt;;
                    925:     chomp($choice2);
                    926:     $intdom=$choice2;
                    927:   }
                    928:   elsif ($choice==9) {
                    929:   print(&lt;&lt;END);
                    930: 9) Role: $perlvar{'lonRole'}
1.20      albertel  931: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    932:                  if in doubt select 'library'):
1.6       harris41  933: END
                    934:     my $choice2=&lt;&gt;;
                    935:     chomp($choice2);
                    936:     $perlvar{'lonRole'}=$choice2;
                    937:   }
1.65      raeburn   938:   elsif ($choice==10) {
1.6       harris41  939:   print(&lt;&lt;END);
1.65      raeburn   940: 10) Cache Expiration Time: $perlvar{'lonExpire'}
1.20      albertel  941: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  942: END
                    943:     my $choice2=&lt;&gt;;
                    944:     chomp($choice2);
                    945:     $perlvar{'lonExpire'}=$choice2;
                    946:   }
1.65      raeburn   947:   elsif ($choice==11) {
1.6       harris41  948:   print(&lt;&lt;END);
1.65      raeburn   949: 11) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  950: ENTER NEW VALUE:
                    951: END
                    952:     my $choice2=&lt;&gt;;
                    953:     chomp($choice2);
                    954:     $perlvar{'lonLoadLim'}=$choice2;
                    955:   }
1.65      raeburn   956:   elsif ($choice==12) {
1.25      albertel  957:   print(&lt;&lt;END);
1.65      raeburn   958: 12) User Load: $perlvar{'lonUserLoadLim'}
1.25      albertel  959: Numer of users that can login before machine is 'overloaded'
1.26      albertel  960: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25      albertel  961: END
                    962:     my $choice2=&lt;&gt;;
                    963:     chomp($choice2);
                    964:     $perlvar{'lonUserLoadLim'}=$choice2;
                    965:   }
1.65      raeburn   966:   elsif ($choice==13) {
1.31      albertel  967:   print(&lt;&lt;END);
1.65      raeburn   968: 13) Allow only secure connections: $securestatus 
1.31      albertel  969: The Lon-CAPA communication daemons lonc and lond can be configured to
                    970: allow only secure connections by default.
                    971: 
                    972: POSSIBLE CHOICES:
                    973: 1) allow only secure connections and don't connect to machines that
                    974:     can not be connected to securely
                    975: 2) allow only secure connections but allow this machine to connect to 
                    976:     machines that don't support secure connections
                    977: 3) allow insecure connections to this machine but only allow connections
                    978:     to machines that support secure connections
                    979: 4) allow insecure connections
                    980: ENTER NEW VALUE (currenly $securenum):
                    981: END
                    982:     my $choice2=&lt;&gt;;
                    983:     chomp($choice2);
                    984:     if      ($choice2 eq '1') {
                    985: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
                    986:     } elsif ($choice2 eq '2') {
                    987: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
                    988:     } elsif ($choice2 eq '3') {
                    989: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
                    990:     } elsif ($choice2 eq '4') {
                    991: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
                    992:     }
                    993:     ($securestatus,$securenum)=&securesetting(%perlvar);
                    994:   }
1.65      raeburn   995:   elsif (($choice==14) && (!$error)) {
1.6       harris41  996:     $flag=1;
                    997:   }
                    998:   else {
1.38      www       999:     print "Invalid input.\n";
1.6       harris41 1000:   }
                   1001: }
1.7       harris41 1002:     open(OUT,"&gt;$confdir$filename") or
                   1003:       die("Cannot output to $confdir$filename\n");
                   1004:     foreach my $key (keys %perlvar) {
                   1005:       my $value=$perlvar{$key};
1.49      raeburn  1006:       my $line = "PerlSetVar     $key      $value";
                   1007:       if ($value eq '') {
                   1008:           $line = '#'.$line;
                   1009:       }
1.8       harris41 1010:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.49      raeburn  1011: $line
1.7       harris41 1012: END
                   1013:     }
                   1014:     close(OUT);
1.1       harris41 1015: </perlscript>
                   1016: </file>
                   1017: <file>
                   1018: <target dist='default'>loncom/hosts.tab</target>
                   1019: <perlscript mode='fg'>
                   1020: unless (-l "<TARGET />") {
1.36      albertel 1021:   my $hostname=`hostname -f`;chomp($hostname);
1.15      harris41 1022:   $date=`date -I`; chomp($date);
                   1023:   $lonHostID=$perlvar{'lonHostID'};
1.51      albertel 1024:   $lonHostID=~s/[^\w\-.]//g;
1.15      harris41 1025:   $lineexistflag=0;
                   1026:   $hostidexistflag=0;
1.22      albertel 1027:   $line2insert=&lt;&lt;END;
1.65      raeburn  1028: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$protocol:$intdom
1.15      harris41 1029: END
1.57      albertel 1030:   if (!$domainTabExtras) {
                   1031: 	$domainTabExtras=':::::';
                   1032:   }
1.43      raeburn  1033:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
1.23      albertel 1034:   if ($lonCluster eq 'standalone') {
                   1035:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                   1036:       die('file generation error');
                   1037:       print(OUT $line2insert);
1.60      raeburn  1038:       print OUT ("^$hostname:$protocol\n");
1.52      albertel 1039:     close(OUT);
                   1040:     open(OUT,'&gt;../'.$lonCluster.'_dns_hosts.tab') or
                   1041:       die('file generation error');
                   1042:       print(OUT $line2insert);
1.23      albertel 1043:     close(OUT);
1.27      albertel 1044:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
                   1045:       die('file generation error');
                   1046:       print(OUT $domaininsert);
                   1047:     close(OUT);
1.52      albertel 1048:     open(OUT,'&gt;../'.$lonCluster.'_dns_domain.tab') or
                   1049:       die('file generation error');
                   1050:       print(OUT $domaininsert);
                   1051:     close(OUT);
1.23      albertel 1052:   }
1.15      harris41 1053:   if ($flag==1) {
1.6       harris41 1054:     `rm -f ../hosts.tab`;
1.52      albertel 1055:     `rm -f ../dns_hosts.tab`;
                   1056:     `ln -s ${lonCluster}_dns_hosts.tab ../dns_hosts.tab`;
                   1057:     open(IN,'&lt;../'.$lonCluster.'_dns_hosts.tab');
                   1058:     while(my $line = &lt;IN&gt;) {
                   1059:       if ($line =~ /^\Q$line2insert\E$/) {
1.13      harris41 1060:         $lineexistflag=1;
                   1061:       }
1.52      albertel 1062:       if ($line =~ /^\Q$lonHostID\E\:/) {
1.13      harris41 1063:         $hostidexistflag=1;
                   1064:       }
                   1065:     }
                   1066:     close(IN);
                   1067:     if ($hostidexistflag and !$lineexistflag) {
                   1068:       print &lt;&lt;END;
                   1069: WARNING: $lonHostID already exists inside
1.52      albertel 1070: loncapa/loncom/${lonCluster}_dns_hosts.tab.  The entry inside
                   1071: ${lonCluster}_dns_hosts.tab does not match your settings.
                   1072: An entry inside ${lonCluster}_hosts.tab will be made
1.13      harris41 1073: with your new values.
                   1074: END
1.15      harris41 1075:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                   1076:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1077:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41 1078:          print(OUT $line2insert);
1.13      harris41 1079:        close(OUT);
1.15      harris41 1080:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41 1081:       # email appropriate message
1.65      raeburn  1082:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41 1083:     }
                   1084:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41 1085:       print &lt;&lt;END;
1.52      albertel 1086: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
1.15      harris41 1087: END
1.52      albertel 1088:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                   1089:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1090:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
                   1091:          print(OUT $line2insert);
                   1092:        close(OUT);
                   1093:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.15      harris41 1094:       # email appropriate message
1.65      raeburn  1095:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41 1096:     }
1.15      harris41 1097:     elsif (!$hostidexistflag and !$lineexistflag) {
                   1098:       print &lt;&lt;END;
                   1099: New entry for $lonCluster.
1.6       harris41 1100: END
1.15      harris41 1101:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel 1102:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1103:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41 1104:          print(OUT $line2insert);
                   1105:        close(OUT);
                   1106:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                   1107:       # email appropriate message
1.65      raeburn  1108:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1109:     }
                   1110:   }
                   1111:   $lineexistflag=0;
                   1112:   if ($flag==1) {
                   1113:     `rm -f ../domain.tab`;
1.52      albertel 1114:     `rm -f ../dns_domain.tab`;
                   1115:     `ln -s ${lonCluster}_dns_domain.tab ../dns_domain.tab`;
                   1116:     open(IN,'&lt;../'.$lonCluster.'_dns_domain.tab');
                   1117:     while(my $line = &lt;IN&gt;) {
                   1118:       if ($line =~/^\Q$domaininsert\E$/) {
1.27      albertel 1119:         $lineexistflag=1;
                   1120:       }
1.52      albertel 1121:       if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
1.27      albertel 1122:         $domainexistflag=1;
                   1123:       }
                   1124:     }
                   1125:     close(IN);
                   1126:     if ($domainexistflag and !$lineexistflag) {
                   1127:       print &lt;&lt;END;
                   1128: WARNING: $perlvar{'lonDefDomain'} already exists inside
1.52      albertel 1129: loncapa/loncom/${lonCluster}_dns_domain.tab.  The entry inside
                   1130: ${lonCluster}_dns_domain.tab does not match your settings.
                   1131: An entry will be made in inside ${lonCluster}_domain.tab
1.27      albertel 1132: with your new values.
                   1133: END
                   1134:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1135:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1136:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1137:          print(OUT $domaininsert);
                   1138:        close(OUT);
                   1139:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1140:       # email appropriate message
1.34      albertel 1141:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1142:     }
                   1143:     elsif ($domainexistflag and $lineexistflag) {
1.52      albertel 1144:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1145:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1146:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1147:          print(OUT $domaininsert);
                   1148:        close(OUT);
1.27      albertel 1149:       print &lt;&lt;END;
1.52      albertel 1150: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
1.27      albertel 1151: END
1.52      albertel 1152:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1.27      albertel 1153:       # email appropriate message
                   1154:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
                   1155:     }
                   1156:     elsif (!$domainexistflag and !$lineexistflag) {
                   1157:       print &lt;&lt;END;
                   1158: New entry for $lonCluster.
                   1159: END
                   1160:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1161:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1162:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
                   1163:          print(OUT $domaininsert);
                   1164:        close(OUT);
                   1165:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1166:       # email appropriate message
                   1167:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41 1168:     }
                   1169:   }
1.1       harris41 1170: }
                   1171: </perlscript>
                   1172: </file>
                   1173: </files>
                   1174: </piml>

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