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

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

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