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

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

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