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

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

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