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

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

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