File:  [LON-CAPA] / doc / loncapafiles / updatequery.piml
Revision 1.67: download - view: text, annotated - select for diffs
Sat Jan 1 21:49:56 2011 UTC (13 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Support for suse11.3

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

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