File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.68: download - view: text, annotated - select for diffs
Thu Jan 13 17:49:23 2011 UTC (13 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_10_0_RC2, HEAD
- Update list of required fields.
- Reset $flag to zero before steps to request primary library, protocol
  and internet domain, so those phases are displayed.
- Default protocol is http

    1: <!-- updatequery.piml -->
    2: 
    3: <!-- $Id: updatequery.piml,v 1.68 2011/01/13 17:49:23 raeburn Exp $ -->
    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>
   33: <target dist='default'>/</target>
   34: <perlscript mode='fg'>
   35: $|=1;
   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
   50: #sleep(3);
   51: </perlscript>
   52: </file>
   53: <file>
   54: <target dist='default'>loncom/hosts.tab</target>
   55: <perlscript mode='fg'>
   56: unless (-l "<TARGET />") {
   57:   print(&lt;&lt;END);
   58: 
   59: ===============================================================================
   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
   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
   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.
   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.)
   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;
  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
  108: END
  109:             die('');
  110:         }
  111:     }
  112:   }
  113:   elsif ($choice==26) {
  114:     $lonCluster='rawhide'; $flag=1;
  115:   }
  116: }
  117: }
  118: </perlscript>
  119: </file>
  120: <file>
  121: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
  122: <perlscript mode='fg'>
  123: $|=1;
  124: my $domainDescription;
  125: my $domainTabExtras;
  126: my $primaryLibServer;
  127: my $protocol;
  128: my $intdom;
  129: my @libservers = ();
  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
  135: or contact helpdesk\@lon-capa.org.
  136: 
  137: ===============================================================================
  138: The following 4 values are needed to configure LON-CAPA:
  139: * Machine Role
  140: * LON-CAPA Domain Name
  141: * LON-CAPA Machine ID Name, and
  142: * Server Administration E-mail Address.
  143: * LON-CAPA Domain's Primary Library Server Machine ID
  144: * Web Server Protocol
  145: * Internet Domain Name of Your Institution
  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: 
  153: END
  154: 
  155: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
  156: close(OUT);
  157: 
  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.
  168: 1) Will this be a library server? (recommended if this is your first install)
  169: 2) Or, will this be an access server?
  170: END
  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: }
  198: 
  199: # need to recommend a machine ID name (ipdomain.l.somenumber)
  200: my $hostname=`hostname -f`; chomp($hostname);
  201: my $ipdomain='';
  202: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
  203:   $ipdomain=$1;
  204: }
  205: 
  206:   print(&lt;&lt;END);
  207: 
  208: **** Domain ****
  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)
  214:    or "michiganstateuniversity" (too long)
  215:    or "msuedu" (internet domain, just make it "msu")
  216:    or "msuphysics" (only if there is a good reason to limit to department
  217:                     - we don't know of one)
  218:    or "mydomain" (what is that?)
  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.]
  227: END
  228: 
  229: # get domain name
  230: # accept if valid, if not valid, tell user and repeat
  231: $flag=0;
  232: my $lonDefDomain;
  233: while (!$flag) {
  234: if ($ipdomain) {
  235: print(&lt;&lt;END);
  236: ENTER LONCAPA DOMAIN [$ipdomain]:
  237: END
  238: }
  239: else {
  240:   print(&lt;&lt;END);
  241: ENTER LONCAPA DOMAIN:
  242: END
  243: }
  244:   my $choice=&lt;&gt;;
  245:   chomp($choice);
  246:   my $bad_domain_flag=0;
  247:   my @bad_domain_names=('res','raw','userfiles','priv','adm','uploaded',
  248: 	'editupload');
  249:   foreach my $bad (@bad_domain_names) {
  250:     $bad_domain_flag=1 if $choice eq $bad;
  251:   }
  252:   if ($choice=~/capa/i) {
  253:      $bad_domain_flag=1;
  254:   }
  255:   if ($ipdomain and $choice=~/^\s*$/) {
  256:     $choice=$ipdomain;
  257:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  258:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  259:     close(OUT);
  260:     $lonDefDomain=$choice;
  261:     $flag=1;
  262:   } elsif (length($choice)>35) {
  263:     print "Name too long\n";
  264:   } elsif (length($choice)<2) {
  265:     print "Name too short\n";
  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";
  269:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  270:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  271:     print(OUT 'lonDefDomain'."\t".$choice."\n");
  272:     close(OUT);
  273:     $lonDefDomain=$choice;
  274:     $r='l';
  275:     $flag=1;
  276:   } else {
  277:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  278:   }
  279: }
  280: 
  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: 
  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: 
  315:   print(&lt;&lt;END);
  316: 
  317: **** Machine ID Name ****
  318: [This does NOT need to correspond to internet address names;
  319:  this name MUST be unique to the whole LON-CAPA network;
  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".
  323:  Note that machine names are very hard to change later.]
  324: END
  325: # get machine name
  326: # accept if valid, if not valid, tell user and repeat
  327: $flag=0;
  328: while (!$flag) {
  329: if ($ipdomain) {
  330: print(&lt;&lt;END);
  331: ENTER LONCAPA MACHINE ID [$lonHostID]:
  332: END
  333: }
  334: else {
  335:   print(&lt;&lt;END);
  336: ENTER LONCAPA MACHINE ID:
  337: END
  338: }
  339:   my $choice=&lt;&gt;;
  340:   chomp($choice);
  341:   if ($choice=~/capa/i) {
  342:     print "Invalid input (names containing 'capa' are reserved).\n";
  343:   } elsif ($lonHostID and $choice=~/^\s*$/) {
  344:     $choice=$lonHostID;
  345:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  346:     print(OUT 'lonHostID'."\t".$choice."\n");
  347:     close(OUT);
  348:     $lonHostID=$choice;
  349:     $flag=1;
  350:   } elsif (length($choice)>45) {
  351:     print "Name too long\n";
  352:   } elsif (length($choice)<4) {
  353:     print "Name too short\n";
  354:   } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  355:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  356:     print(OUT 'lonHostID'."\t".$choice."\n");
  357:     close(OUT);
  358:     $lonHostID=$choice;
  359:     $flag=1;
  360:   } else {
  361:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  362:   }
  363: }
  364: 
  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: }
  374: 
  375: $flag=0;
  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;
  408:     } elsif (length($choice)>35) {
  409:         print "Name too long\n";
  410:     } elsif (length($choice)<4) {
  411:         print "Name too short\n";
  412:     } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
  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 {
  419:         print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
  420:     }
  421: }
  422: 
  423: 
  424: # get admin e-mail address
  425: # accept if valid, if not valid, tell user and repeat
  426: $flag=0;
  427: my $lonAdmEMail;
  428: while (!$flag) {
  429:   print(&lt;&lt;END);
  430: 
  431: **** Server Administrators E-mail ****
  432: E-mail address of the person who will manage this machine
  433: [should be in the form somebody\@somewhere]
  434: ENTER ADMIN E-MAIL ADDRESS:
  435: END
  436: 
  437:   my $choice=&lt;&gt;;
  438:   chomp($choice);
  439:   if ($choice=~/\@/) {
  440:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
  441:     print(OUT 'lonAdmEMail'."\t".$choice."\n");
  442:     close(OUT);
  443:     $lonAdmEMail=$choice;
  444:     $flag=1;
  445:   }
  446:   else {
  447:     print "Invalid input (this needs to look like an e-mail address!).\n";
  448:   }
  449: }
  450: 
  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;
  472:   if ( ($choice=~/\@/) || $choice eq '') {
  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: 
  484: # get protocol
  485: # accept if valid, if not valid, tell user and repeat
  486: $flag=0;
  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.
  493: ENTER WEB SERVER PROTOCOL [http]:
  494: END
  495: 
  496:   my $choice=&lt;&gt;;
  497:   chomp($choice);
  498:   if ($choice =~ /^https?$/) {
  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;
  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 {
  511:     print "Invalid input (only http or https allowed).\n";
  512:   }
  513: }
  514: 
  515: # get internet domain
  516: # accept if valid, if not valid, tell user and repeat
  517: $flag=0;
  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');
  536:     print(OUT 'internet domain'."\t".$choice."\n");
  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: 
  547: # update loncapa.conf
  548: my $confdir = '/etc/httpd/conf/';
  549: if ('<DIST />' eq 'sles10' || '<DIST />' eq 'sles11' || '<DIST />' eq 'suse10.1' || '<DIST />' eq 'suse10.2' || '<DIST />' eq 'suse10.3' || '<DIST />' eq 'suse11.1' || '<DIST />' eq 'suse11.2' || '<DIST />' eq 'suse11.3' || '<DIST />' eq 'debian5' || '<DIST />' eq 'ubuntu6' || '<DIST />' eq 'ubuntu8') {
  550:      $confdir = '/etc/apache2/';
  551: }   
  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);
  560: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
  561: 	    }
  562: 	}
  563: 	close(CONFIG);
  564:     }
  565:     $perlvar{'lonHostID'}=$lonHostID;
  566:     $perlvar{'lonDefDomain'}=$lonDefDomain;
  567:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
  568:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
  569:     $perlvar{'lonRole'}=$lonRole;
  570:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  571:        $perlvar{'lonLoadLim'}='2.00';
  572:     }
  573:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  574:        $perlvar{'lonUserLoadLim'}='0';
  575:     }
  576:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  577:        $perlvar{'lonExpire'}='86400';
  578:     }
  579:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
  580:        my $lonReceipt='';
  581:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
  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};
  592:       my $line = "PerlSetVar     $key      $value"; 
  593:       if ($value eq '') {
  594:           $line = '#'.$line;
  595:       }
  596:       print(OUT &lt;&lt;END);
  597: $line
  598: END
  599:     }
  600:     close(OUT);
  601: }
  602: </perlscript>
  603: </file>
  604: <file>
  605: <target dist='default'>/etc/httpd/conf/</target>
  606: <target dist='sles10 sles11 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 debian5 ubuntu6 ubuntu8'>/etc/apache2/</target>
  607: <perlscript mode='fg'>
  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: }
  623: # read values from loncapa.conf
  624: my $confdir = "<TARGET />";
  625: my $filename='loncapa.conf';
  626: my %perlvar;
  627: my ($securestatus,$securenum);
  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:     }
  640:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
  641:        $perlvar{'lonLoadLim'}='2.00';
  642:     }
  643:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
  644:        $perlvar{'lonUserLoadLim'}='0';
  645:     }
  646:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
  647:        $perlvar{'lonExpire'}='86400';
  648:     }
  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);
  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:     }
  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:     }
  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: 
  691:     if (!$domainDescription) {
  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);
  699: 		    # the remaining field (primary lib server) is handled later
  700: 		    $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
  701: 		    last;
  702: 		}
  703: 	    }
  704: 	    close(IN);
  705: 	    last if ($domainDescription);
  706: 	}
  707:     }
  708: 
  709:     if (!$protocol) {
  710:         foreach my $file (@hosts_files) {
  711:             open(IN,'&lt;'.$file);
  712:             while(my $line = &lt;IN&gt;) {
  713:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:(https?)/) {
  714:                     $protocol = $1;
  715:                     chomp($protocol);
  716:                     last;
  717:                 }
  718:             }
  719:         }
  720:     }
  721: 
  722:     if (!$protocol) {
  723:         $protocol = 'http';
  724:     }
  725: 
  726:     if (!$intdom) {
  727:         foreach my $file (@hosts_files) {
  728:             open(IN,'&lt;'.$file);
  729:             while(my $line = &lt;IN&gt;) {
  730:                 if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:https?\:([^:]+)/) {
  731:                     $intdom = $1;
  732:                     chomp($intdom);
  733:                     last;
  734:                 }
  735:             }
  736:         }
  737:     }
  738: 
  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];
  745:                 chomp($primaryLibServer);
  746:             }
  747:         }
  748:         close(IN);
  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: 	}
  757: 	# make list unique
  758: 	@libservers = keys(%{{ map { $_ => 1 } (@libservers) }});
  759: 	close(IN);
  760: 	if (@libservers == 1) {
  761: 	    $primaryLibServer = $libservers[0];
  762: 	}
  763:     }
  764:    
  765: # implement editing logic below, interactively
  766: # update loncapa.conf until 14 is entered
  767: 
  768: $flag=0;
  769: 
  770: while (!$flag) {
  771:   print(&lt;&lt;END);
  772: 
  773: ===============================================================================
  774: This is now the current configuration of your machine.
  775:  1) Domain Name: $perlvar{'lonDefDomain'}
  776:  2) Domain Description: $domainDescription
  777:  3) Machine Name: $perlvar{'lonHostID'}
  778:  4) ID of primary library server for domain: $primaryLibServer
  779:  5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  780:  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
  781:  7) Web Server Protocol (http or https): $protocol 
  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
  789: END
  790: 
  791: my @error;
  792: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
  793:    if (length($v)>35) { $error.="\nName $v too long"; }		
  794:    if (length($v)<2) { $error.="\nName $v too short"; }
  795:    if ($v=~/capa/i) {
  796: 	if ($v!~/^oucapa\d+$/ && 
  797: 	    ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
  798: 		 push(@error,"Name $v contains 'capa'");
  799: 	}
  800:    }
  801:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
  802: 	'editupload') {
  803:       push(@error,"\nName $v reserved.") if $v eq $bad;
  804:    }
  805:    if ($v=~/[^\w\-.]/) { push(@error,"Name $v contains special characters"); }
  806: }
  807: if ($domainDescription =~ /^\s*$/) {
  808:    push(@error,"Domain Description is blank.");
  809: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
  810:    push(@error,"Domain Description contains special characters.");
  811: } 
  812: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
  813:    unless ($v=~/^[\d+\.]+$/) { push(@error,"Number expected instead of $v"); }
  814: }
  815: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
  816:    push(@error,"Invalid Role");
  817: }
  818: 
  819: unless (($protocol eq 'http') || ($protocol eq 'https')) {
  820:    push(@error,"Invalid Protocol (must be http or https");
  821: }
  822: 
  823: if (!defined($intdom)) { 
  824:    push(@error,"No internet domain name designated. Enter something like ustate.edu"); 
  825: } elsif ($intdom !~ /^[^.]+\.\w{2,6}$/) {
  826:    push(@error,"Invalid Internet domain name (must be at least two levels separated by .  - e.g., ustate.edu");
  827: }
  828: 
  829: if (!defined($primaryLibServer)) {
  830:    if (@libservers > 0) {
  831:        push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers)));
  832:    } else {
  833:        push(@error,"No library servers in this domain (including current server)");
  834:    }
  835: } else {
  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"); }
  838:    if ($primaryLibServer =~/capa/i) {
  839:         if ($primaryLibServer!~/^oucapa\d+$/ &&
  840:             ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
  841:                  push(@error,"Primary library server ID $primaryLibServer contains 'capa'")
  842:         }
  843:    }
  844:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
  845:         'editupload') {
  846:       push(@error,"Primary library server ID $primaryLibServer reserved.") if $primaryLibServer eq $bad;
  847:    }
  848:    if ($primaryLibServer=~/[^\w\-.]/) { push(@error,"Primary library server ID $primaryLibServer contains special characters"); }
  849: }
  850: 
  851: 
  852: if (@error) { print "\n*** ERRORS: \n\t".join("\n\t",@error)."\n"; }
  853:   print(&lt;&lt;END);
  854: ENTER A CHOICE OF 1-13 TO CHANGE, otherwise ENTER 14:
  855: END
  856: my $choice=&lt;&gt;;
  857: chomp($choice);
  858:   if ($choice==1) {
  859:   print(&lt;&lt;END);
  860: 1) Domain Name: $perlvar{'lonDefDomain'}
  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):
  865: END
  866:     my $choice2=&lt;&gt;;
  867:     chomp($choice2);
  868:     $perlvar{'lonDefDomain'}=$choice2;
  869:   }
  870:   elsif ($choice==2) {
  871:   print(&lt;&lt;END);
  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') :
  887: END
  888:     my $choice2=&lt;&gt;;
  889:     chomp($choice2);
  890:     $perlvar{'lonHostID'}=$choice2;
  891:   }
  892:   elsif ($choice==4) {
  893:   print(&lt;&lt;END);
  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);
  908: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
  909: ENTER NEW VALUE:
  910: END
  911:     my $choice2=&lt;&gt;;
  912:     chomp($choice2);
  913:     $perlvar{'lonAdmEMail'}=$choice2;
  914:   }
  915:   elsif ($choice==6) {
  916:   print(&lt;&lt;END);
  917: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
  918: ENTER NEW VALUE:
  919: END
  920:     my $choice2=&lt;&gt;;
  921:     chomp($choice2);
  922:     $perlvar{'lonSupportEMail'}=$choice2;
  923:   }
  924:   elsif ($choice==7) {
  925:   print(&lt;&lt;END);
  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);
  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'}
  947: ENTER NEW VALUE (this should be either 'access' or 'library' 
  948:                  if in doubt select 'library'):
  949: END
  950:     my $choice2=&lt;&gt;;
  951:     chomp($choice2);
  952:     $perlvar{'lonRole'}=$choice2;
  953:   }
  954:   elsif ($choice==10) {
  955:   print(&lt;&lt;END);
  956: 10) Cache Expiration Time: $perlvar{'lonExpire'}
  957: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
  958: END
  959:     my $choice2=&lt;&gt;;
  960:     chomp($choice2);
  961:     $perlvar{'lonExpire'}=$choice2;
  962:   }
  963:   elsif ($choice==11) {
  964:   print(&lt;&lt;END);
  965: 11) Server Load: $perlvar{'lonLoadLim'}
  966: ENTER NEW VALUE:
  967: END
  968:     my $choice2=&lt;&gt;;
  969:     chomp($choice2);
  970:     $perlvar{'lonLoadLim'}=$choice2;
  971:   }
  972:   elsif ($choice==12) {
  973:   print(&lt;&lt;END);
  974: 12) User Load: $perlvar{'lonUserLoadLim'}
  975: Numer of users that can login before machine is 'overloaded'
  976: ENTER NEW VALUE (integer value, 0 means there is no limit):
  977: END
  978:     my $choice2=&lt;&gt;;
  979:     chomp($choice2);
  980:     $perlvar{'lonUserLoadLim'}=$choice2;
  981:   }
  982:   elsif ($choice==13) {
  983:   print(&lt;&lt;END);
  984: 13) Allow only secure connections: $securestatus 
  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:   }
 1011:   elsif (($choice==14) && (!$error)) {
 1012:     $flag=1;
 1013:   }
 1014:   else {
 1015:     print "Invalid input.\n";
 1016:   }
 1017: }
 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};
 1022:       my $line = "PerlSetVar     $key      $value";
 1023:       if ($value eq '') {
 1024:           $line = '#'.$line;
 1025:       }
 1026:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
 1027: $line
 1028: END
 1029:     }
 1030:     close(OUT);
 1031: </perlscript>
 1032: </file>
 1033: <file>
 1034: <target dist='default'>loncom/hosts.tab</target>
 1035: <perlscript mode='fg'>
 1036: unless (-l "<TARGET />") {
 1037:   my $hostname=`hostname -f`;chomp($hostname);
 1038:   $date=`date -I`; chomp($date);
 1039:   $lonHostID=$perlvar{'lonHostID'};
 1040:   $lonHostID=~s/[^\w\-.]//g;
 1041:   $lineexistflag=0;
 1042:   $hostidexistflag=0;
 1043:   $line2insert=&lt;&lt;END;
 1044: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$protocol:$intdom
 1045: END
 1046:   if (!$domainTabExtras) {
 1047: 	$domainTabExtras=':::::';
 1048:   }
 1049:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
 1050:   if ($lonCluster eq 'standalone') {
 1051:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
 1052:       die('file generation error');
 1053:       print(OUT $line2insert);
 1054:       print OUT ("^$hostname:$protocol\n");
 1055:     close(OUT);
 1056:     open(OUT,'&gt;../'.$lonCluster.'_dns_hosts.tab') or
 1057:       die('file generation error');
 1058:       print(OUT $line2insert);
 1059:     close(OUT);
 1060:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
 1061:       die('file generation error');
 1062:       print(OUT $domaininsert);
 1063:     close(OUT);
 1064:     open(OUT,'&gt;../'.$lonCluster.'_dns_domain.tab') or
 1065:       die('file generation error');
 1066:       print(OUT $domaininsert);
 1067:     close(OUT);
 1068:   }
 1069:   if ($flag==1) {
 1070:     `rm -f ../hosts.tab`;
 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$/) {
 1076:         $lineexistflag=1;
 1077:       }
 1078:       if ($line =~ /^\Q$lonHostID\E\:/) {
 1079:         $hostidexistflag=1;
 1080:       }
 1081:     }
 1082:     close(IN);
 1083:     if ($hostidexistflag and !$lineexistflag) {
 1084:       print &lt;&lt;END;
 1085: WARNING: $lonHostID already exists inside
 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
 1089: with your new values.
 1090: END
 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");
 1094:          print(OUT $line2insert);
 1095:        close(OUT);
 1096:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
 1097:       # email appropriate message
 1098:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1099:     }
 1100:     elsif ($hostidexistflag and $lineexistflag) {
 1101:       print &lt;&lt;END;
 1102: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
 1103: END
 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`;
 1110:       # email appropriate message
 1111:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1112:     }
 1113:     elsif (!$hostidexistflag and !$lineexistflag) {
 1114:       print &lt;&lt;END;
 1115: New entry for $lonCluster.
 1116: END
 1117:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
 1118:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
 1119:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
 1120:          print(OUT $line2insert);
 1121:        close(OUT);
 1122:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
 1123:       # email appropriate message
 1124:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
 1125:     }
 1126:   }
 1127:   $lineexistflag=0;
 1128:   if ($flag==1) {
 1129:     `rm -f ../domain.tab`;
 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$/) {
 1135:         $lineexistflag=1;
 1136:       }
 1137:       if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
 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
 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
 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
 1157:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
 1158:     }
 1159:     elsif ($domainexistflag and $lineexistflag) {
 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);
 1165:       print &lt;&lt;END;
 1166: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
 1167: END
 1168:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
 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`;
 1184:     }
 1185:   }
 1186: }
 1187: </perlscript>
 1188: </file>
 1189: </files>
 1190: </piml>

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