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

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

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