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

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: 
1.53    ! albertel    3: <!-- $Id: updatequery.piml,v 1.52 2007/04/03 22:13:40 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;
1.52      albertel  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
1.22      albertel  108: END
1.52      albertel  109:             die('');
                    110:         }
1.27      albertel  111:     }
1.22      albertel  112:   }
                    113:   elsif ($choice==26) {
                    114:     $lonCluster='rawhide'; $flag=1;
                    115:   }
                    116: }
                    117: }
                    118: </perlscript>
                    119: </file>
                    120: <file>
1.10      harris41  121: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1       harris41  122: <perlscript mode='fg'>
1.4       harris41  123: $|=1;
1.20      albertel  124: my $domainDescription;
1.29      albertel  125: my $domainTabExtras;
1.43      raeburn   126: my $primaryLibServer;
                    127: my @libservers = ();
1.1       harris41  128: unless (-e "<TARGET />") {
                    129:   print(&lt;&lt;END);
                    130:            WELCOME TO LON-CAPA!
                    131: 
                    132: If you have questions, please visit http://install.lon-capa.org
1.32      raeburn   133: or contact helpdesk\@lon-capa.org.
1.1       harris41  134: 
                    135: ===============================================================================
1.4       harris41  136: The following 4 values are needed to configure LON-CAPA:
                    137: * Machine Role
1.8       harris41  138: * LON-CAPA Domain Name
                    139: * LON-CAPA Machine ID Name, and
1.47      albertel  140: * Server Administration E-mail Address.
1.32      raeburn   141: ===============================================================================
                    142: 
                    143: In addition, a Support E-mail Address can also be included. If
                    144: an address is included then one of the options in the LON-CAPA 
                    145: help menu will be a link to a form that a user will complete to
                    146: request LON-CAPA help.  
                    147: 
1.1       harris41  148: END
1.3       harris41  149: 
1.4       harris41  150: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
                    151: close(OUT);
                    152: 
1.3       harris41  153: # query for Machine Role
                    154:   print(&lt;&lt;END);
                    155: **** Machine Role ****
                    156: Library server (recommended if first-time installation of LON-CAPA):
                    157:    Servers that are repositories of authoritative educational resources.
                    158:    These servers also provide the construction space by which instructors
                    159:    assemble their classroom online material.
                    160: Access server:
                    161:    Servers that load-balance high-traffic delivery of educational resources
                    162:    over the world-wide web.
1.4       harris41  163: 1) Will this be a library server? (recommended if this is your first install)
1.3       harris41  164: 2) Or, will this be an access server?
                    165: END
1.4       harris41  166: my $flag=0;
                    167: my $r='';
                    168: my $lonRole;
                    169: while (!$flag) {
                    170:   print "ENTER A CHOICE OF 1 or 2:\n";
                    171:   my $choice=&lt;&gt;;
                    172:   chomp($choice);
                    173:   if ($choice==1) {
                    174:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    175:     print(OUT 'lonRole'."\t".'library'."\n");
                    176:     close(OUT);
                    177:     $lonRole='library';
                    178:     $r='l';
                    179:     $flag=1;
                    180:   }
                    181:   elsif ($choice==2) {
                    182:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    183:     print(OUT 'lonRole'."\t".'access'."\n");
                    184:     close(OUT);
                    185:     $lonRole='access';
                    186:     $r='a';
                    187:     $flag=2;
                    188:   }
                    189:   else {
                    190: 
                    191:   }
                    192: }
1.3       harris41  193: 
                    194: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.36      albertel  195: my $hostname=`hostname -f`; chomp($hostname);
1.4       harris41  196: my $ipdomain='';
                    197: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
                    198:   $ipdomain=$1;
                    199: }
1.1       harris41  200: 
                    201:   print(&lt;&lt;END);
                    202: 
1.8       harris41  203: **** Domain ****
1.45      www       204: [This does NOT need to correspond to internet address domains.
                    205:  Please make this name short AND descriptive of your organization.
                    206:  Domain names are close to impossible to change later!!!
                    207:  Good examples might be "msu" or "bionet" or "vermontcc".
                    208:  Bad examples are "physics" (too general)
1.37      www       209:    or "michiganstateuniversity" (too long)
                    210:    or "msuedu" (internet domain, just make it "msu")
1.45      www       211:    or "msuphysics" (only if there is a good reason to limit to department
                    212:                     - we don't know of one)
1.37      www       213:    or "mydomain" (what is that?)
1.45      www       214:  Avoid multiple domains at the same institution, even if it means that you 
                    215:  have to actually work together with your colleagues. You can still run
                    216:  multiple library servers within the same domain.
                    217:  If this domain is eventually going to be part of the main production
                    218:  cluster, you MUST contact the LON-CAPA group at MSU (loncapa@loncapa.org)
                    219:  to have a domain name assigned, and then use it exactly as given. This is
                    220:  also true for test installs that might eventually turn into production setups.
                    221:  Stop now if you didn't do so.]
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.51      albertel  257:   } elsif (length($choice)>35) {
1.37      www       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.51      albertel  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.51      albertel  272:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.4       harris41  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 ****
1.45      www       313: [This does NOT need to correspond to internet address names;
1.8       harris41  314:  this name MUST be unique to the whole LON-CAPA network;
1.45      www       315:  we recommend that you use a name based off of your institution.
                    316:  Good examples: "msul1" or "bioneta2".
                    317:  Bad examples: "loncapabox" or "studentsinside".
1.37      www       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.51      albertel  345:   } elsif (length($choice)>45) {
1.37      www       346:     print "Name too long\n";
                    347:   } elsif (length($choice)<4) {
                    348:     print "Name too short\n";
1.51      albertel  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.51      albertel  356:     print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.4       harris41  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;
1.51      albertel  401:     } elsif (length($choice)>35) {
1.43      raeburn   402:         print "Name too long\n";
                    403:     } elsif (length($choice)<4) {
                    404:         print "Name too short\n";
1.51      albertel  405:     } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
1.43      raeburn   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 {
1.51      albertel  412:         print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
1.43      raeburn   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: 
1.47      albertel  424: **** Server Administrator's E-mail ****
1.1       harris41  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.49      raeburn   479: my $confdir = '/etc/httpd/conf/';
1.50      raeburn   480: if ('<DIST />' eq 'sles10' || '<DIST />' eq 'suse10.1') {
1.49      raeburn   481:      $confdir = '/etc/apache2/';
                    482: }   
1.5       harris41  483: my $filename='loncapa.conf';
                    484: my %perlvar;
                    485:     if (-e "$confdir$filename") {
                    486: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
                    487: 	while (my $configline=&lt;CONFIG&gt;) {
                    488: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    489: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    490: 		chomp($varvalue);
1.12      harris41  491: 		$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5       harris41  492: 	    }
                    493: 	}
                    494: 	close(CONFIG);
                    495:     }
                    496:     $perlvar{'lonHostID'}=$lonHostID;
                    497:     $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9       harris41  498:     $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.32      raeburn   499:     $perlvar{'lonSupportEMail'}=$lonSupportEMail;
1.5       harris41  500:     $perlvar{'lonRole'}=$lonRole;
1.16      harris41  501:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5       harris41  502:        $perlvar{'lonLoadLim'}='2.00';
                    503:     }
1.25      albertel  504:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    505:        $perlvar{'lonUserLoadLim'}='0';
                    506:     }
1.16      harris41  507:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5       harris41  508:        $perlvar{'lonExpire'}='86400';
                    509:     }
1.16      harris41  510:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5       harris41  511:        my $lonReceipt='';
1.11      harris41  512:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5       harris41  513:        my @alnum=(0..9,a..z);
                    514:        foreach my $i (1..20) {
                    515: 	 $lonReceipt.=$alnum[int(rand(36))];
                    516:        }
                    517:        $perlvar{'lonReceipt'}=$lonReceipt;
                    518:     }
                    519:     open(OUT,"&gt;$confdir$filename") or
                    520:       die("Cannot output to $confdir$filename\n");
                    521:     foreach my $key (keys %perlvar) {
                    522:       my $value=$perlvar{$key};
1.49      raeburn   523:       my $line = "PerlSetVar     $key      $value"; 
                    524:       if ($value eq '') {
                    525:           $line = '#'.$line;
                    526:       }
1.5       harris41  527:       print(OUT &lt;&lt;END);
1.49      raeburn   528: $line
1.5       harris41  529: END
                    530:     }
                    531:     close(OUT);
1.1       harris41  532: }
                    533: </perlscript>
                    534: </file>
                    535: <file>
1.49      raeburn   536: <target dist='default'>/etc/httpd/conf/</target>
1.50      raeburn   537: <target dist='sles10 suse10.1'>/etc/apache2/</target>
1.1       harris41  538: <perlscript mode='fg'>
1.31      albertel  539: sub securesetting {
                    540:     my (%perlvar)=@_;
                    541:     my $securestatus='unknown';
                    542:     my $securenum='';
                    543:     if      ( $perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    544: 	$securestatus='no';                  $securenum='4';
                    545:     } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    546: 	$securestatus='lond';                $securenum='3';
                    547:     } elsif (!$perlvar{'loncAllowInsecure'}&&  $perlvar{'londAllowInsecure'}) {
                    548: 	$securestatus='lonc';                $securenum='2';
                    549:     } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
                    550: 	$securestatus='yes (lond and lonc)'; $securenum='1';
                    551:     }
                    552:     return ($securestatus,$securenum);
                    553: }
1.1       harris41  554: # read values from loncapa.conf
1.49      raeburn   555: my $confdir = "<TARGET />";
1.5       harris41  556: my $filename='loncapa.conf';
                    557: my %perlvar;
1.31      albertel  558: my ($securestatus,$securenum);
1.5       harris41  559:     if (-e "$confdir$filename") {
                    560: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    561:           die("Can't read $confdir$filename");
                    562: 	while (my $configline=&lt;CONFIG&gt;) {
                    563: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    564: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    565: 		chomp($varvalue);
                    566: 		$perlvar{$varname}=$varvalue;
                    567: 	    }
                    568: 	}
                    569: 	close(CONFIG);
                    570:     }
1.16      harris41  571:     unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
                    572:        $perlvar{'lonLoadLim'}='2.00';
                    573:     }
1.25      albertel  574:     unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
                    575:        $perlvar{'lonUserLoadLim'}='0';
                    576:     }
1.16      harris41  577:     unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
                    578:        $perlvar{'lonExpire'}='86400';
                    579:     }
1.31      albertel  580:     unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
                    581:        $perlvar{'londAllowInsecure'}='1';
                    582:     }
                    583:     unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
                    584:        $perlvar{'loncAllowInsecure'}='1';
                    585:     }
                    586:     ($securestatus,$securenum)=&securesetting(%perlvar);
1.16      harris41  587:     unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
                    588:        my $lonReceipt='';
                    589:        srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
                    590:        my @alnum=(0..9,a..z);
                    591:        foreach my $i (1..20) {
                    592: 	 $lonReceipt.=$alnum[int(rand(36))];
                    593:        }
                    594:        $perlvar{'lonReceipt'}=$lonReceipt;
                    595:     }
1.7       harris41  596: my %perlvarstatic;
                    597:     if (-e "${confdir}loncapa_apache.conf") {
                    598: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
                    599:           die("Can't read ${confdir}loncapa_apache.conf");
                    600: 	while (my $configline=&lt;CONFIG&gt;) {
                    601: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    602: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    603: 		chomp($varvalue);
                    604: 		$perlvarstatic{$varname}=$varvalue;
                    605: 	    }
                    606: 	}
                    607: 	close(CONFIG);
                    608:     }
1.23      albertel  609:     if (!$domainDescription && $lonCluster ne 'existing') {
1.27      albertel  610:        open(IN,'&lt;../'.$lonCluster.'_domain.tab');
1.22      albertel  611:        while(&lt;IN&gt;) {
1.27      albertel  612:           if (/^$perlvar{'lonDefDomain'}\:/) {
1.29      albertel  613: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.22      albertel  614: 	     chomp($domainDescription);
1.29      albertel  615: 	     chomp($domainTabExtras);
1.46      albertel  616: 	     # the remianing field (primary lib server) is handled later
                    617: 	     $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
1.22      albertel  618:              last;
                    619:           }
                    620:        }
1.23      albertel  621:        close(IN);
1.22      albertel  622:     }
1.23      albertel  623:     if (!$domainDescription) {
1.27      albertel  624:        open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
1.23      albertel  625:        while(&lt;IN&gt;) {
1.27      albertel  626:           if (/^$perlvar{'lonDefDomain'}\:/) {
1.29      albertel  627: 	     (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.23      albertel  628: 	     chomp($domainDescription);
1.29      albertel  629: 	     chomp($domainTabExtras);
1.46      albertel  630: 	     # the remianing field (primary lib server) is handled later
1.48      raeburn   631: 	     $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
1.23      albertel  632:              last;
                    633:           }
                    634:        }
                    635:        close(IN);
                    636:     }
1.43      raeburn   637:     if (!$primaryLibServer and $lonCluster ne 'existing') {
                    638:         open(IN,'&lt;../'.$lonCluster.'_domain.tab');
                    639:         while(&lt;IN&gt;) {
                    640:             if (/^$perlvar{'lonDefDomain'}\:/) {
                    641:                 (undef,undef,undef,undef,undef,undef,undef,undef,
                    642:                                               $primaryLibServer)=split(/:/,$_);
                    643:                 chomp($primaryLibServer);
                    644:             }
                    645:         }
                    646:         close(IN);
                    647:         if (!$primaryLibServer) {
                    648:             open(IN,'&lt;../'.$lonCluster.'_hosts.tab');
                    649:             while(&lt;IN&gt;) {
                    650:                 if (/^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                    651:                     push(@libservers,$1);
                    652:                 }
                    653:             }
                    654:             close(IN);
                    655:             if (@libservers == 1) {
                    656:                 $primaryLibServer = $libservers[0];
                    657:             }
                    658:         }
                    659:     }
                    660:     if (!$primaryLibServer) {
                    661:         open(IN,'&lt;/home/httpd/lonTabs/domain.tab');
                    662:         while(&lt;IN&gt;) {
                    663:             if (/^$perlvar{'lonDefDomain'}\:/) {
                    664:                 (undef,undef,undef,undef,undef,undef,undef,undef,
                    665:                                               $primaryLibServer)=split(/:/,$_);
                    666:                 chomp($primaryLibServer);
                    667:             }
                    668:             close(IN);
                    669:         }
                    670:         if (!$primaryLibServer) {
                    671:             open(IN,'&lt;/home/httpd/lonTabs/hosts.tab');
                    672:             while(&lt;IN&gt;) {
                    673:                 if (/^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
                    674:                     push(@libservers,$1);
                    675:                 }
                    676:             }
                    677:             close(IN);
                    678:             if (@libservers == 1) {
                    679:                 $primaryLibServer = $libservers[0];
                    680:             }
                    681:         }
                    682:     }
1.23      albertel  683:    
1.6       harris41  684: # implement editing logic below, interactively
1.46      albertel  685: # update loncapa.conf until 12 is entered
1.6       harris41  686: 
                    687: $flag=0;
1.17      harris41  688: 
1.6       harris41  689: while (!$flag) {
1.1       harris41  690:   print(&lt;&lt;END);
                    691: 
                    692: ===============================================================================
                    693: This is now the current configuration of your machine.
1.31      albertel  694:  1) Domain Name: $perlvar{'lonDefDomain'}
                    695:  2) Domain Description: $domainDescription
                    696:  3) Machine Name: $perlvar{'lonHostID'}
1.43      raeburn   697:  4) ID of primary library server for domain: $primaryLibServer
1.47      albertel  698:  5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.43      raeburn   699:  6) Support E-mail Address: $perlvar{'lonSupportEMail'}
                    700:  7) Role: $perlvar{'lonRole'}
                    701:  8) Cache Expiration Time: $perlvar{'lonExpire'}
                    702:  9) Server Load: $perlvar{'lonLoadLim'}
                    703: 10) User Load: $perlvar{'lonUserLoadLim'}
                    704: 11) Allow only secure connections: $securestatus 
                    705: 12) Everything is correct up above
1.6       harris41  706: END
1.38      www       707: 
                    708: my $error='';
                    709: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
1.51      albertel  710:    if (length($v)>35) { $error.="\nName $v too long"; }		
1.38      www       711:    if (length($v)<2) { $error.="\nName $v too short"; }
1.39      albertel  712:    if ($v=~/capa/i) {
                    713: 	if ($v!~/^oucapa\d+$/ && 
                    714: 	    ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
                    715: 		 $error.="\nName $v contains 'capa'"; 
                    716: 	}
                    717:    }
1.41      albertel  718:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    719: 	'editupload') {
1.38      www       720:       $error.="\nName $v reserved." if $v eq $bad;
                    721:    }
1.51      albertel  722:    if ($v=~/[^\w\-.]/) { $error.="\nName $v contains special characters"; }
1.38      www       723: }
1.53    ! albertel  724: if ($domainDescription =~ /^\s*$/) {
        !           725:    $error.="\nDomain Description is blank.";
        !           726: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
        !           727:    $error.="\nDomain Description contains special characters.";
1.38      www       728: } 
                    729: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
                    730:    unless ($v=~/^[\d+\.]+$/) { $error.="\nNumber expected instead of $v"; }
                    731: }
                    732: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
                    733:    $error.="\nInvalid Role";
1.17      harris41  734: }
1.43      raeburn   735: 
                    736: if (!defined($primaryLibServer)) {
                    737:    if (@libservers > 0) {
                    738:        $error .= "No primary library server ID designated. Choose from: ".join(',',sort(@libservers));
                    739:    } else {
                    740:        $error .= "No library servers in this domain (including current server)";
                    741:    }
                    742: } else {
1.51      albertel  743:    if (length($primaryLibServer)>35) { $error.="\nPrimary Library Server ID:  $primaryLibServer too long"; }
1.43      raeburn   744:    if (length($primaryLibServer)<2) { $error.="\nPrimary Library Server ID:  $primaryLibServer too short"; }
                    745:    if ($primaryLibServer =~/capa/i) {
                    746:         if ($primaryLibServer!~/^oucapa\d+$/ &&
                    747:             ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
                    748:                  $error.="\nPrimary library server ID $primaryLibServer contains 'capa'";
                    749:         }
                    750:    }
                    751:    foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
                    752:         'editupload') {
                    753:       $error.="\nPrimary library server ID $primaryLibServer reserved." if $primaryLibServer eq $bad;
                    754:    }
1.51      albertel  755:    if ($primaryLibServer=~/[^\w\-.]/) { $error.="\nPrimary library server ID $primaryLibServer contains special characters"; }
1.43      raeburn   756: }
                    757: 
                    758: 
1.38      www       759: if ($error) { print "\n*** ERRORS: $error\n"; }
1.6       harris41  760:   print(&lt;&lt;END);
1.43      raeburn   761: ENTER A CHOICE OF 1-11 TO CHANGE, otherwise ENTER 12:
1.1       harris41  762: END
1.5       harris41  763: my $choice=&lt;&gt;;
                    764: chomp($choice);
1.6       harris41  765:   if ($choice==1) {
                    766:   print(&lt;&lt;END);
1.16      harris41  767: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20      albertel  768: ENTER NEW VALUE (this is an internal value used to identify a group of
                    769:                  LON-CAPA machines, it must be alphanumerical, we suggest
                    770:                  using a part of your actual DNS domain. For example, for
                    771:                  the machine loncapa.msu.edu, we set the Domain to msu):
1.6       harris41  772: END
                    773:     my $choice2=&lt;&gt;;
                    774:     chomp($choice2);
1.8       harris41  775:     $perlvar{'lonDefDomain'}=$choice2;
1.6       harris41  776:   }
                    777:   elsif ($choice==2) {
                    778:   print(&lt;&lt;END);
1.20      albertel  779: 2) Domain Description: $domainDescription
                    780: ENTER NEW VALUE (this should be a string that describes your domain, spaces
                    781:                  and punctuation are fine except for ':'):
                    782: END
                    783:     my $choice2=&lt;&gt;;
                    784:     chomp($choice2);
                    785:     $domainDescription=$choice2;
                    786:   }
                    787:   elsif ($choice==3) {
                    788:   print(&lt;&lt;END);
                    789: 3) Machine Name: $perlvar{'lonHostID'}
                    790: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
                    791:                  it cannot contain any of '_' '-' '.' or ':'. We suggest that
                    792:                  if you are in the domain 'example' and are the first library
                    793:                  server you enter 'examplel1') :
1.6       harris41  794: END
                    795:     my $choice2=&lt;&gt;;
                    796:     chomp($choice2);
1.8       harris41  797:     $perlvar{'lonHostID'}=$choice2;
1.6       harris41  798:   }
1.20      albertel  799:   elsif ($choice==4) {
1.6       harris41  800:   print(&lt;&lt;END);
1.43      raeburn   801: 4) ID of primary library server for domain: $primaryLibServer
                    802: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
                    803:                  your domain; it cannot contain any of '_' '-' '.' or ':'. 
                    804:                  This server will be where domain data which are not 
                    805:                  associated with any specific home library server
                    806:                  will be stored (e.g., e-mail broadcast by Domain Coordinators
                    807:                  to users in the domain).
                    808: END
                    809:     my $choice2=&lt;&gt;;
                    810:     chomp($choice2);
                    811:     $primaryLibServer=$choice2;
                    812:   }
                    813:   elsif ($choice==5) {
                    814:   print(&lt;&lt;END);
1.47      albertel  815: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6       harris41  816: ENTER NEW VALUE:
                    817: END
                    818:     my $choice2=&lt;&gt;;
                    819:     chomp($choice2);
1.9       harris41  820:     $perlvar{'lonAdmEMail'}=$choice2;
1.6       harris41  821:   }
1.43      raeburn   822:   elsif ($choice==6) {
1.6       harris41  823:   print(&lt;&lt;END);
1.43      raeburn   824: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.32      raeburn   825: ENTER NEW VALUE:
                    826: END
                    827:     my $choice2=&lt;&gt;;
                    828:     chomp($choice2);
                    829:     $perlvar{'lonSupportEMail'}=$choice2;
                    830:   }
1.43      raeburn   831:   elsif ($choice==7) {
1.32      raeburn   832:   print(&lt;&lt;END);
1.43      raeburn   833: 7) Role: $perlvar{'lonRole'}
1.20      albertel  834: ENTER NEW VALUE (this should be either 'access' or 'library' 
                    835:                  if in doubt select 'library'):
1.6       harris41  836: END
                    837:     my $choice2=&lt;&gt;;
                    838:     chomp($choice2);
                    839:     $perlvar{'lonRole'}=$choice2;
                    840:   }
1.43      raeburn   841:   elsif ($choice==8) {
1.6       harris41  842:   print(&lt;&lt;END);
1.43      raeburn   843: 8) Cache Expiration Time: $perlvar{'lonExpire'}
1.20      albertel  844: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6       harris41  845: END
                    846:     my $choice2=&lt;&gt;;
                    847:     chomp($choice2);
                    848:     $perlvar{'lonExpire'}=$choice2;
                    849:   }
1.43      raeburn   850:   elsif ($choice==9) {
1.6       harris41  851:   print(&lt;&lt;END);
1.43      raeburn   852: 9) Server Load: $perlvar{'lonLoadLim'}
1.6       harris41  853: ENTER NEW VALUE:
                    854: END
                    855:     my $choice2=&lt;&gt;;
                    856:     chomp($choice2);
                    857:     $perlvar{'lonLoadLim'}=$choice2;
                    858:   }
1.43      raeburn   859:   elsif ($choice==10) {
1.25      albertel  860:   print(&lt;&lt;END);
1.43      raeburn   861: 10) User Load: $perlvar{'lonUserLoadLim'}
1.25      albertel  862: Numer of users that can login before machine is 'overloaded'
1.26      albertel  863: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25      albertel  864: END
                    865:     my $choice2=&lt;&gt;;
                    866:     chomp($choice2);
                    867:     $perlvar{'lonUserLoadLim'}=$choice2;
                    868:   }
1.43      raeburn   869:   elsif ($choice==11) {
1.31      albertel  870:   print(&lt;&lt;END);
1.43      raeburn   871: 11) Allow only secure connections: $securestatus 
1.31      albertel  872: The Lon-CAPA communication daemons lonc and lond can be configured to
                    873: allow only secure connections by default.
                    874: 
                    875: POSSIBLE CHOICES:
                    876: 1) allow only secure connections and don't connect to machines that
                    877:     can not be connected to securely
                    878: 2) allow only secure connections but allow this machine to connect to 
                    879:     machines that don't support secure connections
                    880: 3) allow insecure connections to this machine but only allow connections
                    881:     to machines that support secure connections
                    882: 4) allow insecure connections
                    883: ENTER NEW VALUE (currenly $securenum):
                    884: END
                    885:     my $choice2=&lt;&gt;;
                    886:     chomp($choice2);
                    887:     if      ($choice2 eq '1') {
                    888: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
                    889:     } elsif ($choice2 eq '2') {
                    890: 	$perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
                    891:     } elsif ($choice2 eq '3') {
                    892: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
                    893:     } elsif ($choice2 eq '4') {
                    894: 	$perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
                    895:     }
                    896:     ($securestatus,$securenum)=&securesetting(%perlvar);
                    897:   }
1.43      raeburn   898:   elsif (($choice==12) && (!$error)) {
1.6       harris41  899:     $flag=1;
                    900:   }
                    901:   else {
1.38      www       902:     print "Invalid input.\n";
1.6       harris41  903:   }
                    904: }
1.7       harris41  905:     open(OUT,"&gt;$confdir$filename") or
                    906:       die("Cannot output to $confdir$filename\n");
                    907:     foreach my $key (keys %perlvar) {
                    908:       my $value=$perlvar{$key};
1.49      raeburn   909:       my $line = "PerlSetVar     $key      $value";
                    910:       if ($value eq '') {
                    911:           $line = '#'.$line;
                    912:       }
1.8       harris41  913:       print(OUT &lt;&lt;END) unless $perlvarstatic{$key};
1.49      raeburn   914: $line
1.7       harris41  915: END
                    916:     }
                    917:     close(OUT);
1.1       harris41  918: </perlscript>
                    919: </file>
                    920: <file>
                    921: <target dist='default'>loncom/hosts.tab</target>
                    922: <perlscript mode='fg'>
                    923: unless (-l "<TARGET />") {
1.36      albertel  924:   my $hostname=`hostname -f`;chomp($hostname);
1.15      harris41  925:   $date=`date -I`; chomp($date);
                    926:   $lonHostID=$perlvar{'lonHostID'};
1.51      albertel  927:   $lonHostID=~s/[^\w\-.]//g;
1.15      harris41  928:   $lineexistflag=0;
                    929:   $hostidexistflag=0;
1.22      albertel  930:   $line2insert=&lt;&lt;END;
1.35      albertel  931: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
1.15      harris41  932: END
1.43      raeburn   933:   $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
1.23      albertel  934:   if ($lonCluster eq 'standalone') {
                    935:     open(OUT,'&gt;../'.$lonCluster.'_hosts.tab') or
                    936:       die('file generation error');
                    937:       print(OUT $line2insert);
1.52      albertel  938:       print OUT ("^$hostname\n");
                    939:     close(OUT);
                    940:     open(OUT,'&gt;../'.$lonCluster.'_dns_hosts.tab') or
                    941:       die('file generation error');
                    942:       print(OUT $line2insert);
1.23      albertel  943:     close(OUT);
1.27      albertel  944:     open(OUT,'&gt;../'.$lonCluster.'_domain.tab') or
                    945:       die('file generation error');
                    946:       print(OUT $domaininsert);
                    947:     close(OUT);
1.52      albertel  948:     open(OUT,'&gt;../'.$lonCluster.'_dns_domain.tab') or
                    949:       die('file generation error');
                    950:       print(OUT $domaininsert);
                    951:     close(OUT);
1.23      albertel  952:   }
1.15      harris41  953:   if ($flag==1) {
1.6       harris41  954:     `rm -f ../hosts.tab`;
1.52      albertel  955:     `rm -f ../dns_hosts.tab`;
                    956:     `ln -s ${lonCluster}_dns_hosts.tab ../dns_hosts.tab`;
                    957:     open(IN,'&lt;../'.$lonCluster.'_dns_hosts.tab');
                    958:     while(my $line = &lt;IN&gt;) {
                    959:       if ($line =~ /^\Q$line2insert\E$/) {
1.13      harris41  960:         $lineexistflag=1;
                    961:       }
1.52      albertel  962:       if ($line =~ /^\Q$lonHostID\E\:/) {
1.13      harris41  963:         $hostidexistflag=1;
                    964:       }
                    965:     }
                    966:     close(IN);
                    967:     if ($hostidexistflag and !$lineexistflag) {
                    968:       print &lt;&lt;END;
                    969: WARNING: $lonHostID already exists inside
1.52      albertel  970: loncapa/loncom/${lonCluster}_dns_hosts.tab.  The entry inside
                    971: ${lonCluster}_dns_hosts.tab does not match your settings.
                    972: An entry inside ${lonCluster}_hosts.tab will be made
1.13      harris41  973: with your new values.
                    974: END
1.15      harris41  975:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                    976:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    977:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14      harris41  978:          print(OUT $line2insert);
1.13      harris41  979:        close(OUT);
1.15      harris41  980:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13      harris41  981:       # email appropriate message
1.34      albertel  982:       `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  983:     }
                    984:     elsif ($hostidexistflag and $lineexistflag) {
1.15      harris41  985:       print &lt;&lt;END;
1.52      albertel  986: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
1.15      harris41  987: END
1.52      albertel  988:       `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
                    989:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                    990:          die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
                    991:          print(OUT $line2insert);
                    992:        close(OUT);
                    993:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.15      harris41  994:       # email appropriate message
                    995:       `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13      harris41  996:     }
1.15      harris41  997:     elsif (!$hostidexistflag and !$lineexistflag) {
                    998:       print &lt;&lt;END;
                    999: New entry for $lonCluster.
1.6       harris41 1000: END
1.15      harris41 1001:       `cat ../${lonCluster}_hosts.tab &gt; ../new_${lonCluster}_hosts.tab`;
1.21      albertel 1002:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_hosts.tab') or
                   1003:          die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15      harris41 1004:          print(OUT $line2insert);
                   1005:        close(OUT);
                   1006:       `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
                   1007:       # email appropriate message
                   1008:       `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1009:     }
                   1010:   }
                   1011:   $lineexistflag=0;
                   1012:   if ($flag==1) {
                   1013:     `rm -f ../domain.tab`;
1.52      albertel 1014:     `rm -f ../dns_domain.tab`;
                   1015:     `ln -s ${lonCluster}_dns_domain.tab ../dns_domain.tab`;
                   1016:     open(IN,'&lt;../'.$lonCluster.'_dns_domain.tab');
                   1017:     while(my $line = &lt;IN&gt;) {
                   1018:       if ($line =~/^\Q$domaininsert\E$/) {
1.27      albertel 1019:         $lineexistflag=1;
                   1020:       }
1.52      albertel 1021:       if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
1.27      albertel 1022:         $domainexistflag=1;
                   1023:       }
                   1024:     }
                   1025:     close(IN);
                   1026:     if ($domainexistflag and !$lineexistflag) {
                   1027:       print &lt;&lt;END;
                   1028: WARNING: $perlvar{'lonDefDomain'} already exists inside
1.52      albertel 1029: loncapa/loncom/${lonCluster}_dns_domain.tab.  The entry inside
                   1030: ${lonCluster}_dns_domain.tab does not match your settings.
                   1031: An entry will be made in inside ${lonCluster}_domain.tab
1.27      albertel 1032: with your new values.
                   1033: END
                   1034:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1035:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1036:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1037:          print(OUT $domaininsert);
                   1038:        close(OUT);
                   1039:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1040:       # email appropriate message
1.34      albertel 1041:       `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27      albertel 1042:     }
                   1043:     elsif ($domainexistflag and $lineexistflag) {
1.52      albertel 1044:       `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1045:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1046:          die("cannot open loncom/${lonCluster}_domain.tab for output\n");
                   1047:          print(OUT $domaininsert);
                   1048:        close(OUT);
1.27      albertel 1049:       print &lt;&lt;END;
1.52      albertel 1050: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
1.27      albertel 1051: END
1.52      albertel 1052:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1.27      albertel 1053:       # email appropriate message
                   1054:       `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
                   1055:     }
                   1056:     elsif (!$domainexistflag and !$lineexistflag) {
                   1057:       print &lt;&lt;END;
                   1058: New entry for $lonCluster.
                   1059: END
                   1060:       `cat ../${lonCluster}_domain.tab &gt; ../new_${lonCluster}_domain.tab`;
                   1061:        open(OUT,'&gt;&gt;../new_'.$lonCluster.'_domain.tab') or
                   1062:          die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
                   1063:          print(OUT $domaininsert);
                   1064:        close(OUT);
                   1065:       `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
                   1066:       # email appropriate message
                   1067:       `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6       harris41 1068:     }
                   1069:   }
1.1       harris41 1070: }
                   1071: </perlscript>
                   1072: </file>
                   1073: </files>
                   1074: </piml>

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