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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.65    ! raeburn     3: <!-- $Id: updatequery.piml,v 1.64 2010/01/01 04:29:01 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;) {
                    697:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:(https?)/) {
                    698:                     $protocol = $1;
                    699:                     last;
                    700:                 }
                    701:             }
                    702:         }
                    703:     }
                    704: 
                    705:     if (!$protocol) {
                    706:         $protocol = 'http';
                    707:     }
                    708: 
1.65    ! raeburn   709:     if (!$intdom) {
        !           710:         foreach my $file (@hosts_files) {
        !           711:             open(IN,'&lt;'.$file);
        !           712:             while(my $line = &lt;IN&gt;) {
        !           713:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:https?:([^:]+)/) {
        !           714:                     $intdom = $1;
        !           715:                     last;
        !           716:                 }
        !           717:             }
        !           718:         }
        !           719:     }
        !           720: 
1.55      albertel  721:     while(!$primaryLibServ && (@hosts_file || @domain_files)) {
                    722: 	my $file = shift(@domain_files);
                    723:         open(IN,'&lt;'.$file);
                    724:         while(my $line = &lt;IN&gt;) {
                    725:             if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
                    726: 		$primaryLibServer=(split(/:/,$line))[8];
1.43      raeburn   727:                 chomp($primaryLibServer);
                    728:             }
                    729:         }
                    730:         close(IN);
1.55      albertel  731: 	last if ($primaryLibServer);
                    732: 	$file = shift(@hosts_files);
                    733: 	open(IN,'&lt;'.$file);
                    734: 	while(my $line = &lt;IN&gt;) {
                    735: 	    if ($line =~ /^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                    736: 		push(@libservers,$1);
                    737: 	    }
                    738: 	}
1.58      albertel  739: 	# make list unique
                    740: 	@libservers = keys(%{{ map { $_ => 1 } (@libservers) }});
1.55      albertel  741: 	close(IN);
                    742: 	if (@libservers == 1) {
                    743: 	    $primaryLibServer = $libservers[0];
                    744: 	}
1.43      raeburn   745:     }
1.23      albertel  746:    
1.6       harris41  747: # implement editing logic below, interactively
1.65    ! raeburn   748: # update loncapa.conf until 14 is entered
1.6       harris41  749: 
                    750: $flag=0;
1.17      harris41  751: 
1.6       harris41  752: while (!$flag) {
1.1       harris41  753:   print(&lt;&lt;END);
                    754: 
                    755: ===============================================================================
                    756: This is now the current configuration of your machine.
1.31      albertel  757:  1) Domain Name: $perlvar{'lonDefDomain'}
                    758:  2) Domain Description: $domainDescription
                    759:  3) Machine Name: $perlvar{'lonHostID'}
1.43      raeburn   760:  4) ID of primary library server for domain: $primaryLibServer
1.47      albertel  761:  5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.43      raeburn   762:  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.60      raeburn   763:  7) Web Server Protocol (http or https): $protocol 
1.65    ! raeburn   764:  8) Internet Domain Name: $intdom 
        !           765:  9) Role: $perlvar{'lonRole'}
        !           766: 10) Cache Expiration Time: $perlvar{'lonExpire'}
        !           767: 11) Server Load: $perlvar{'lonLoadLim'}
        !           768: 12) User Load: $perlvar{'lonUserLoadLim'}
        !           769: 13) Allow only secure connections: $securestatus 
        !           770: 14) Everything is correct up above
1.6       harris41  771: END
1.38      www       772: 
1.54      albertel  773: my @error;
1.38      www       774: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
1.51      albertel  775:    if (length($v)>35) { $error.="\nName $v too long"; }		
1.38      www       776:    if (length($v)<2) { $error.="\nName $v too short"; }
1.39      albertel  777:    if ($v=~/capa/i) {
                    778: 	if ($v!~/^oucapa\d+$/ && 
                    779: 	    ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
1.54      albertel  780: 		 push(@error,"Name $v contains 'capa'");
1.39      albertel  781: 	}
                    782:    }
1.41      albertel  783:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    784: 	'editupload') {
1.54      albertel  785:       push(@error,"\nName $v reserved.") if $v eq $bad;
1.38      www       786:    }
1.54      albertel  787:    if ($v=~/[^\w\-.]/) { push(@error,"Name $v contains special characters"); }
1.38      www       788: }
1.53      albertel  789: if ($domainDescription =~ /^\s*$/) {
1.54      albertel  790:    push(@error,"Domain Description is blank.");
1.53      albertel  791: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
1.54      albertel  792:    push(@error,"Domain Description contains special characters.");
1.38      www       793: } 
                    794: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
1.54      albertel  795:    unless ($v=~/^[\d+\.]+$/) { push(@error,"Number expected instead of $v"); }
1.38      www       796: }
                    797: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
1.54      albertel  798:    push(@error,"Invalid Role");
1.17      harris41  799: }
1.43      raeburn   800: 
1.60      raeburn   801: unless (($protocol eq 'http') || ($protocol eq 'https')) {
                    802:    push(@error,"Invalid Protocol (must be http or https");
                    803: }
                    804: 
1.65    ! raeburn   805: if (!defined($intdom)) { 
        !           806:    push(@error,"No internet domain name designated. Enter something like ustate.edu"); 
        !           807: } elsif ($intdom !~ /^[^.]+\.\w{2,6}$/) {
        !           808:    push(@error,"Invalid Internet domain name (must be at least two levels separated by .  - e.g., ustate.edu");
        !           809: }
        !           810: 
1.43      raeburn   811: if (!defined($primaryLibServer)) {
                    812:    if (@libservers > 0) {
1.54      albertel  813:        push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers)));
1.43      raeburn   814:    } else {
1.54      albertel  815:        push(@error,"No library servers in this domain (including current server)");
1.43      raeburn   816:    }
                    817: } else {
1.54      albertel  818:    if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID:  $primaryLibServer too long"); }
                    819:    if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID:  $primaryLibServer too short"); }
1.43      raeburn   820:    if ($primaryLibServer =~/capa/i) {
                    821:         if ($primaryLibServer!~/^oucapa\d+$/ &&
                    822:             ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
1.54      albertel  823:                  push(@error,"Primary library server ID $primaryLibServer contains 'capa'")
1.43      raeburn   824:         }
                    825:    }
                    826:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    827:         'editupload') {
1.54      albertel  828:       push(@error,"Primary library server ID $primaryLibServer reserved.") if $primaryLibServer eq $bad;
1.43      raeburn   829:    }
1.54      albertel  830:    if ($primaryLibServer=~/[^\w\-.]/) { push(@error,"Primary library server ID $primaryLibServer contains special characters"); }
1.43      raeburn   831: }
                    832: 
                    833: 
1.54      albertel  834: if (@error) { print "\n*** ERRORS: \n\t".join("\n\t",@error)."\n"; }
1.6       harris41  835:   print(&lt;&lt;END);
1.65    ! raeburn   836: ENTER A CHOICE OF 1-13 TO CHANGE, otherwise ENTER 14:
1.1       harris41  837: END
1.5       harris41  838: my $choice=&lt;&gt;;
                    839: chomp($choice);
1.6       harris41  840:   if ($choice==1) {
                    841:   print(&lt;&lt;END);
1.16      harris41  842: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  843: ENTER NEW VALUE (this is an internal value used to identify a group of
                    844:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    845:                  using a part of your actual DNS domain. For example, for
                    846:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  847: END
                    848:     my $choice2=&lt;&gt;;
                    849:     chomp($choice2);
1.8       harris41  850:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  851:   }
                    852:   elsif ($choice==2) {
                    853:   print(&lt;&lt;END);
1.20      albertel  854: 2) Domain Description: $domainDescription
                    855: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    856:                  and punctuation are fine except for ':'):
                    857: END
                    858:     my $choice2=&lt;&gt;;
                    859:     chomp($choice2);
                    860:     $domainDescription=$choice2;
                    861:   }
                    862:   elsif ($choice==3) {
                    863:   print(&lt;&lt;END);
                    864: 3) Machine Name: $perlvar{'lonHostID'}
                    865: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    866:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    867:                  if you are in the domain 'example' and are the first library
                    868:                  server you enter 'examplel1') :
1.6       harris41  869: END
                    870:     my $choice2=&lt;&gt;;
                    871:     chomp($choice2);
1.8       harris41  872:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  873:   }
1.20      albertel  874:   elsif ($choice==4) {
1.6       harris41  875:   print(&lt;&lt;END);
1.43      raeburn   876: 4) ID of primary library server for domain: $primaryLibServer
                    877: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
                    878:                  your domain; it cannot contain any of '_' '-' '.' or ':'. 
                    879:                  This server will be where domain data which are not 
                    880:                  associated with any specific home library server
                    881:                  will be stored (e.g., e-mail broadcast by Domain Coordinators
                    882:                  to users in the domain).
                    883: END
                    884:     my $choice2=&lt;&gt;;
                    885:     chomp($choice2);
                    886:     $primaryLibServer=$choice2;
                    887:   }
                    888:   elsif ($choice==5) {
                    889:   print(&lt;&lt;END);
1.47      albertel  890: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  891: ENTER NEW VALUE:
                    892: END
                    893:     my $choice2=&lt;&gt;;
                    894:     chomp($choice2);
1.9       harris41  895:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  896:   }
1.43      raeburn   897:   elsif ($choice==6) {
1.6       harris41  898:   print(&lt;&lt;END);
1.43      raeburn   899: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.32      raeburn   900: ENTER NEW VALUE:
                    901: END
                    902:     my $choice2=&lt;&gt;;
                    903:     chomp($choice2);
                    904:     $perlvar{'lonSupportEMail'}=$choice2;
                    905:   }
1.43      raeburn   906:   elsif ($choice==7) {
1.32      raeburn   907:   print(&lt;&lt;END);
1.60      raeburn   908: 7) Server Protocol (http or https): 
                    909: ENTER NEW VALUE: (this should be either 'http' or 'https'
                    910:                  if in doubt set to 'http'):
                    911: END
                    912:     my $choice2=&lt;&gt;;
                    913:     chomp($choice2);
                    914:     $protocol=$choice2;
                    915:   }
                    916:   elsif ($choice==8) {
                    917:   print(&lt;&lt;END);
1.65    ! raeburn   918: 8) Internet Domain Name of Institution
        !           919: ENTER NEW VALUE: 
        !           920: 
        !           921: END
        !           922:     my $choice2=&lt;&gt;;
        !           923:     chomp($choice2);
        !           924:     $intdom=$choice2;
        !           925:   }
        !           926:   elsif ($choice==9) {
        !           927:   print(&lt;&lt;END);
        !           928: 9) Role: $perlvar{'lonRole'}
1.20      albertel  929: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    930:                  if in doubt select 'library'):
1.6       harris41  931: END
                    932:     my $choice2=&lt;&gt;;
                    933:     chomp($choice2);
                    934:     $perlvar{'lonRole'}=$choice2;
                    935:   }
1.65    ! raeburn   936:   elsif ($choice==10) {
1.6       harris41  937:   print(&lt;&lt;END);
1.65    ! raeburn   938: 10) Cache Expiration Time: $perlvar{'lonExpire'}
1.20      albertel  939: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  940: END
                    941:     my $choice2=&lt;&gt;;
                    942:     chomp($choice2);
                    943:     $perlvar{'lonExpire'}=$choice2;
                    944:   }
1.65    ! raeburn   945:   elsif ($choice==11) {
1.6       harris41  946:   print(&lt;&lt;END);
1.65    ! raeburn   947: 11) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  948: ENTER NEW VALUE:
                    949: END
                    950:     my $choice2=&lt;&gt;;
                    951:     chomp($choice2);
                    952:     $perlvar{'lonLoadLim'}=$choice2;
                    953:   }
1.65    ! raeburn   954:   elsif ($choice==12) {
1.25      albertel  955:   print(&lt;&lt;END);
1.65    ! raeburn   956: 12) User Load: $perlvar{'lonUserLoadLim'}
1.25      albertel  957: Numer of users that can login before machine is 'overloaded'
1.26      albertel  958: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25      albertel  959: END
                    960:     my $choice2=&lt;&gt;;
                    961:     chomp($choice2);
                    962:     $perlvar{'lonUserLoadLim'}=$choice2;
                    963:   }
1.65    ! raeburn   964:   elsif ($choice==13) {
1.31      albertel  965:   print(&lt;&lt;END);
1.65    ! raeburn   966: 13) Allow only secure connections: $securestatus 
1.31      albertel  967: The Lon-CAPA communication daemons lonc and lond can be configured to
                    968: allow only secure connections by default.
                    969: 
                    970: POSSIBLE CHOICES:
                    971: 1) allow only secure connections and don't connect to machines that
                    972:     can not be connected to securely
                    973: 2) allow only secure connections but allow this machine to connect to 
                    974:     machines that don't support secure connections
                    975: 3) allow insecure connections to this machine but only allow connections
                    976:     to machines that support secure connections
                    977: 4) allow insecure connections
                    978: ENTER NEW VALUE (currenly $securenum):
                    979: END
                    980:     my $choice2=&lt;&gt;;
                    981:     chomp($choice2);
                    982:     if      ($choice2 eq '1') {
                    983: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
                    984:     } elsif ($choice2 eq '2') {
                    985: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
                    986:     } elsif ($choice2 eq '3') {
                    987: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
                    988:     } elsif ($choice2 eq '4') {
                    989: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
                    990:     }
                    991:     ($securestatus,$securenum)=&securesetting(%perlvar);
                    992:   }
1.65    ! raeburn   993:   elsif (($choice==14) && (!$error)) {
1.6       harris41  994:     $flag=1;
                    995:   }
                    996:   else {
1.38      www       997:     print "Invalid input.\n";
1.6       harris41  998:   }
                    999: }
1.7       harris41 1000:     open(OUT,"&gt;$confdir$filename") or
                   1001:       die("Cannot output to $confdir$filename\n");
                   1002:     foreach my $key (keys %perlvar) {
                   1003:       my $value=$perlvar{$key};
1.49      raeburn  1004:       my $line = "PerlSetVar     $key      $value";
                   1005:       if ($value eq '') {
                   1006:           $line = '#'.$line;
                   1007:       }
1.8       harris41 1008:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.49      raeburn  1009: $line
1.7       harris41 1010: END
                   1011:     }
                   1012:     close(OUT);
1.1       harris41 1013: </perlscript>
                   1014: </file>
                   1015: <file>
                   1016: <target dist='default'>loncom/hosts.tab</target>
                   1017: <perlscript mode='fg'>
                   1018: unless (-l "<TARGET />") {
1.36      albertel 1019:   my $hostname=`hostname -f`;chomp($hostname);
1.15      harris41 1020:   $date=`date -I`; chomp($date);
                   1021:   $lonHostID=$perlvar{'lonHostID'};
1.51      albertel 1022:   $lonHostID=~s/[^\w\-.]//g;
1.15      harris41 1023:   $lineexistflag=0;
                   1024:   $hostidexistflag=0;
1.22      albertel 1025:   $line2insert=&lt;&lt;END;
1.65    ! raeburn  1026: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$protocol:$intdom
1.15      harris41 1027: END
1.57      albertel 1028:   if (!$domainTabExtras) {
                   1029: 	$domainTabExtras=':::::';
                   1030:   }
1.43      raeburn  1031:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
1.23      albertel 1032:   if ($lonCluster eq 'standalone') {
                   1033:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                   1034:       die('file generation error');
                   1035:       print(OUT $line2insert);
1.60      raeburn  1036:       print OUT ("^$hostname:$protocol\n");
1.52      albertel 1037:     close(OUT);
                   1038:     open(OUT,'&gt;../'.$lonCluster.'_dns_hosts.tab') or
                   1039:       die('file generation error');
                   1040:       print(OUT $line2insert);
1.23      albertel 1041:     close(OUT);
1.27      albertel 1042:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
                   1043:       die('file generation error');
                   1044:       print(OUT $domaininsert);
                   1045:     close(OUT);
1.52      albertel 1046:     open(OUT,'&gt;../'.$lonCluster.'_dns_domain.tab') or
                   1047:       die('file generation error');
                   1048:       print(OUT $domaininsert);
                   1049:     close(OUT);
1.23      albertel 1050:   }
1.15      harris41 1051:   if ($flag==1) {
1.6       harris41 1052:     `rm -f ../hosts.tab`;
1.52      albertel 1053:     `rm -f ../dns_hosts.tab`;
                   1054:     `ln -s ${lonCluster}_dns_hosts.tab ../dns_hosts.tab`;
                   1055:     open(IN,'&lt;../'.$lonCluster.'_dns_hosts.tab');
                   1056:     while(my $line = &lt;IN&gt;) {
                   1057:       if ($line =~ /^\Q$line2insert\E$/) {
1.13      harris41 1058:         $lineexistflag=1;
                   1059:       }
1.52      albertel 1060:       if ($line =~ /^\Q$lonHostID\E\:/) {
1.13      harris41 1061:         $hostidexistflag=1;
                   1062:       }
                   1063:     }
                   1064:     close(IN);
                   1065:     if ($hostidexistflag and !$lineexistflag) {
                   1066:       print &lt;&lt;END;
                   1067: WARNING: $lonHostID already exists inside
1.52      albertel 1068: loncapa/loncom/${lonCluster}_dns_hosts.tab.  The entry inside
                   1069: ${lonCluster}_dns_hosts.tab does not match your settings.
                   1070: An entry inside ${lonCluster}_hosts.tab will be made
1.13      harris41 1071: with your new values.
                   1072: END
1.15      harris41 1073:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                   1074:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1075:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41 1076:          print(OUT $line2insert);
1.13      harris41 1077:        close(OUT);
1.15      harris41 1078:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41 1079:       # email appropriate message
1.65    ! raeburn  1080:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41 1081:     }
                   1082:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41 1083:       print &lt;&lt;END;
1.52      albertel 1084: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
1.15      harris41 1085: END
1.52      albertel 1086:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                   1087:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1088:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
                   1089:          print(OUT $line2insert);
                   1090:        close(OUT);
                   1091:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.15      harris41 1092:       # email appropriate message
1.65    ! raeburn  1093:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41 1094:     }
1.15      harris41 1095:     elsif (!$hostidexistflag and !$lineexistflag) {
                   1096:       print &lt;&lt;END;
                   1097: New entry for $lonCluster.
1.6       harris41 1098: END
1.15      harris41 1099:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel 1100:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1101:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41 1102:          print(OUT $line2insert);
                   1103:        close(OUT);
                   1104:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                   1105:       # email appropriate message
1.65    ! raeburn  1106:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1107:     }
                   1108:   }
                   1109:   $lineexistflag=0;
                   1110:   if ($flag==1) {
                   1111:     `rm -f ../domain.tab`;
1.52      albertel 1112:     `rm -f ../dns_domain.tab`;
                   1113:     `ln -s ${lonCluster}_dns_domain.tab ../dns_domain.tab`;
                   1114:     open(IN,'&lt;../'.$lonCluster.'_dns_domain.tab');
                   1115:     while(my $line = &lt;IN&gt;) {
                   1116:       if ($line =~/^\Q$domaininsert\E$/) {
1.27      albertel 1117:         $lineexistflag=1;
                   1118:       }
1.52      albertel 1119:       if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
1.27      albertel 1120:         $domainexistflag=1;
                   1121:       }
                   1122:     }
                   1123:     close(IN);
                   1124:     if ($domainexistflag and !$lineexistflag) {
                   1125:       print &lt;&lt;END;
                   1126: WARNING: $perlvar{'lonDefDomain'} already exists inside
1.52      albertel 1127: loncapa/loncom/${lonCluster}_dns_domain.tab.  The entry inside
                   1128: ${lonCluster}_dns_domain.tab does not match your settings.
                   1129: An entry will be made in inside ${lonCluster}_domain.tab
1.27      albertel 1130: with your new values.
                   1131: END
                   1132:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1133:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1134:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1135:          print(OUT $domaininsert);
                   1136:        close(OUT);
                   1137:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1138:       # email appropriate message
1.34      albertel 1139:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1140:     }
                   1141:     elsif ($domainexistflag and $lineexistflag) {
1.52      albertel 1142:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1143:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1144:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1145:          print(OUT $domaininsert);
                   1146:        close(OUT);
1.27      albertel 1147:       print &lt;&lt;END;
1.52      albertel 1148: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
1.27      albertel 1149: END
1.52      albertel 1150:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1.27      albertel 1151:       # email appropriate message
                   1152:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
                   1153:     }
                   1154:     elsif (!$domainexistflag and !$lineexistflag) {
                   1155:       print &lt;&lt;END;
                   1156: New entry for $lonCluster.
                   1157: END
                   1158:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1159:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1160:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
                   1161:          print(OUT $domaininsert);
                   1162:        close(OUT);
                   1163:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1164:       # email appropriate message
                   1165:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41 1166:     }
                   1167:   }
1.1       harris41 1168: }
                   1169: </perlscript>
                   1170: </file>
                   1171: </files>
                   1172: </piml>

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