File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.63: download - view: text, annotated - select for diffs
Tue Dec 29 07:04:38 2009 UTC (14 years, 4 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Support for SuSE 11.2.

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

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