Annotation of doc/loncapafiles/updatequery.piml, revision 1.29
1.2 harris41 1: <!-- updatequery.piml -->
1.1 harris41 2:
1.29 ! albertel 3: <!-- $Id: updatequery.piml,v 1.28 2003/08/29 18:54:52 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(<<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(<<END);
58:
59: ===============================================================================
1.27 albertel 60: What hosts.tab and domain.tab would you like to have installed?
1.22 albertel 61: (hosts.tab is a listing of all other internet machines
62: that a server system considers to be valid server systems
1.27 albertel 63: on the LON-CAPA network
64: domain.tab is a description of the internal LON-CAPA domains)
1.22 albertel 65:
66: 1) PRODUCTION - you want to deliver courses today or sometime very soon
67: on this machine
68: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
69: not be connected to other LON-CAPA machines for now
70: 3) DEVELOPMENT - you want to play with or explore LON-CAPA
1.27 albertel 71: 4) PRESERVE the existing hosts.tab and domain.tab
72: (/home/httpd/lonTabs/hosts.tab and
73: /home/httpd/lonTabs/domain.tab)
1.22 albertel 74:
75: END
76: # Option number 26 will install rawhide_hosts.tab, but
77: # the typical user does not want to be part of an intensive
78: # machine test cluster.
79:
80: # get input
81: # if valid then process, otherwise loop
82: $flag=0;
83: while (!$flag) {
84: print "ENTER 1, 2, 3, or 4:\n";
85: my $choice=<>;
86: chomp($choice);
87: if ($choice==1) {
88: $lonCluster='production'; $flag=1;
89: }
90: elsif ($choice==2) {
91: $lonCluster='standalone'; $flag=1;
92: }
93: elsif ($choice==3) {
94: $lonCluster='development'; $flag=1;
95: }
96: elsif ($choice==4) {
97: $lonCluster='existing'; $flag=1;
98: if (-e '/home/httpd/lonTabs/hosts.tab') {
99: `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
100: }
101: else {
102: print <<END;
103: There is no existing /home/httpd/lonTabs/hosts.tab
104: END
105: die('');
106: }
1.27 albertel 107: if (-e '/home/httpd/lonTabs/domain.tab') {
108: `cp /home/httpd/lonTabs/domain.tab ../existing_domain.tab`;
109: }
110: else {
111: print <<END;
112: There is no existing /home/httpd/lonTabs/domain.tab
113: END
114: die('');
115: }
1.22 albertel 116: }
117: elsif ($choice==26) {
118: $lonCluster='rawhide'; $flag=1;
119: }
120: }
121: }
122: </perlscript>
123: </file>
124: <file>
1.10 harris41 125: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1 harris41 126: <perlscript mode='fg'>
1.4 harris41 127: $|=1;
1.20 albertel 128: my $domainDescription;
1.29 ! albertel 129: my $domainTabExtras;
1.1 harris41 130: unless (-e "<TARGET />") {
131: print(<<END);
132: WELCOME TO LON-CAPA!
133:
134: If you have questions, please visit http://install.lon-capa.org
1.5 harris41 135: or contact sharrison\@mail.lon-capa.org.
1.1 harris41 136:
137: ===============================================================================
1.4 harris41 138: The following 4 values are needed to configure LON-CAPA:
139: * Machine Role
1.8 harris41 140: * LON-CAPA Domain Name
141: * LON-CAPA Machine ID Name, and
1.1 harris41 142: * System Administration E-mail Address.
143: END
1.3 harris41 144:
1.4 harris41 145: open(OUT,'>/tmp/loncapa_updatequery.out');
146: close(OUT);
147:
1.3 harris41 148: # query for Machine Role
149: print(<<END);
150: **** Machine Role ****
151: Library server (recommended if first-time installation of LON-CAPA):
152: Servers that are repositories of authoritative educational resources.
153: These servers also provide the construction space by which instructors
154: assemble their classroom online material.
155: Access server:
156: Servers that load-balance high-traffic delivery of educational resources
157: over the world-wide web.
1.4 harris41 158: 1) Will this be a library server? (recommended if this is your first install)
1.3 harris41 159: 2) Or, will this be an access server?
160: END
1.4 harris41 161: my $flag=0;
162: my $r='';
163: my $lonRole;
164: while (!$flag) {
165: print "ENTER A CHOICE OF 1 or 2:\n";
166: my $choice=<>;
167: chomp($choice);
168: if ($choice==1) {
169: open(OUT,'>>/tmp/loncapa_updatequery.out');
170: print(OUT 'lonRole'."\t".'library'."\n");
171: close(OUT);
172: $lonRole='library';
173: $r='l';
174: $flag=1;
175: }
176: elsif ($choice==2) {
177: open(OUT,'>>/tmp/loncapa_updatequery.out');
178: print(OUT 'lonRole'."\t".'access'."\n");
179: close(OUT);
180: $lonRole='access';
181: $r='a';
182: $flag=2;
183: }
184: else {
185:
186: }
187: }
1.3 harris41 188:
189: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.4 harris41 190: my $hostname=`hostname`; chomp($hostname);
191: my $ipdomain='';
192: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
193: $ipdomain=$1;
194: }
1.1 harris41 195:
196: print(<<END);
197:
1.8 harris41 198: **** Domain ****
199: [this does NOT need to correspond to internet address domains,
200: examples might be "msu" or "bionet" or "vermontcc"]
1.1 harris41 201: END
1.8 harris41 202:
203: # get domain name
1.1 harris41 204: # accept if valid, if not valid, tell user and repeat
1.4 harris41 205: $flag=0;
1.8 harris41 206: my $lonDefDomain;
1.4 harris41 207: while (!$flag) {
208: if ($ipdomain) {
209: print(<<END);
1.8 harris41 210: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4 harris41 211: END
212: }
213: else {
214: print(<<END);
1.8 harris41 215: ENTER LONCAPA DOMAIN:
1.4 harris41 216: END
217: }
218: my $choice=<>;
219: chomp($choice);
1.18 harris41 220: my $bad_domain_flag=0;
221: my @bad_domain_names=('raw','userfiles','priv','adm','uploaded');
222: foreach my $bad (@bad_domain_names) {
223: $bad_domain_flag=1 if $choice eq $bad;
224: }
1.8 harris41 225: if ($ipdomain and $choice=~/^\s*$/) {
226: $choice=$ipdomain;
1.4 harris41 227: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 228: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 229: close(OUT);
1.8 harris41 230: $lonDefDomain=$choice;
1.4 harris41 231: $flag=1;
232: }
233: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
234: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 235: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 236: close(OUT);
1.8 harris41 237: $lonDefDomain=$choice;
238: $r='l';
1.4 harris41 239: $flag=1;
1.18 harris41 240: }
241: elsif ($bad_domain_flag) {
242: print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
243: print "Please try something different than '$choice'\n";
1.4 harris41 244: }
245: else {
246: print "Invalid input (only alphanumeric characters supported).\n";
247: }
248: }
1.1 harris41 249:
1.20 albertel 250:
251: # get domain description
252: # accept if valid, if not valid, tell user and repeat
253: $flag=0;
254:
255: while (!$flag) {
256: print(<<END);
257:
258: **** Domain Description ****
259: String describing the domain, to be shown to users.
260: [Example, msu is Michigan State University]
261: ENTER DOMAIN DESCRIPTION:
262: END
263:
264: my $choice=<>;
265: chomp($choice);
266: if ($choice!~/:/) {
267: open(OUT,'>>/tmp/loncapa_updatequery.out');
268: print(OUT 'domainDescription'."\t".$choice."\n");
269: close(OUT);
270: $domainDescription=$choice;
271: $flag=1;
272: }
273: else {
274: print "Invalid input (no ':' allowed).\n";
275: }
276: }
277:
1.8 harris41 278: my $lonHostID;
279: if ($lonDefDomain) {
280: $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
281: # against the hosts.tab
282: }
283:
1.1 harris41 284: print(<<END);
285:
1.8 harris41 286: **** Machine ID Name ****
287: [this does NOT need to correspond to internet address names;
288: this name MUST be unique to the whole LON-CAPA network;
289: we recommend that you use a name based off of your institution;
290: good examples: "msul1" or "bionetl1";
291: bad examples: "loncapabox" or "studentsinside"]
1.1 harris41 292: END
1.8 harris41 293: # get machine name
1.1 harris41 294: # accept if valid, if not valid, tell user and repeat
1.4 harris41 295: $flag=0;
296: while (!$flag) {
297: if ($ipdomain) {
298: print(<<END);
1.8 harris41 299: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4 harris41 300: END
301: }
302: else {
303: print(<<END);
1.8 harris41 304: ENTER LONCAPA MACHINE ID:
1.4 harris41 305: END
306: }
307: my $choice=<>;
308: chomp($choice);
1.8 harris41 309: if ($lonHostID and $choice=~/^\s*$/) {
310: $choice=$lonHostID;
1.4 harris41 311: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 312: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 313: close(OUT);
1.8 harris41 314: $lonHostID=$choice;
1.4 harris41 315: $flag=1;
316: }
317: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
318: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 319: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 320: close(OUT);
1.8 harris41 321: $lonHostID=$choice;
1.4 harris41 322: $flag=1;
323: }
324: else {
325: print "Invalid input (only alphanumeric characters supported).\n";
326: }
327: }
1.1 harris41 328:
1.4 harris41 329: # get e-mail address
330: # accept if valid, if not valid, tell user and repeat
331: $flag=0;
1.9 harris41 332: my $lonAdmEMail;
1.4 harris41 333: while (!$flag) {
1.1 harris41 334: print(<<END);
335:
336: **** System Administrator's E-mail ****
337: E-mail address of the person who will manage this machine
1.4 harris41 338: [should be in the form somebody\@somewhere]
1.1 harris41 339: ENTER E-MAIL ADDRESS:
340: END
341:
1.4 harris41 342: my $choice=<>;
343: chomp($choice);
344: if ($choice=~/\@/) {
345: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.9 harris41 346: print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4 harris41 347: close(OUT);
1.9 harris41 348: $lonAdmEMail=$choice;
1.4 harris41 349: $flag=1;
350: }
351: else {
352: print "Invalid input (this needs to look like an e-mail address!).\n";
353: }
354: }
355:
1.1 harris41 356: # update loncapa.conf
1.7 harris41 357: my $confdir='/etc/httpd/conf/';
358: #my $confdir='';
1.5 harris41 359: my $filename='loncapa.conf';
360: my %perlvar;
361: if (-e "$confdir$filename") {
362: open(CONFIG,'<'.$confdir.$filename) or die("Can't read $confdir$filename");
363: while (my $configline=<CONFIG>) {
364: if ($configline =~ /^[^\#]*PerlSetVar/) {
365: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
366: chomp($varvalue);
1.12 harris41 367: $perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5 harris41 368: }
369: }
370: close(CONFIG);
371: }
372: $perlvar{'lonHostID'}=$lonHostID;
373: $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9 harris41 374: $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.5 harris41 375: $perlvar{'lonRole'}=$lonRole;
1.16 harris41 376: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5 harris41 377: $perlvar{'lonLoadLim'}='2.00';
378: }
1.25 albertel 379: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
380: $perlvar{'lonUserLoadLim'}='0';
381: }
1.16 harris41 382: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5 harris41 383: $perlvar{'lonExpire'}='86400';
384: }
1.16 harris41 385: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5 harris41 386: my $lonReceipt='';
1.11 harris41 387: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5 harris41 388: my @alnum=(0..9,a..z);
389: foreach my $i (1..20) {
390: $lonReceipt.=$alnum[int(rand(36))];
391: }
392: $perlvar{'lonReceipt'}=$lonReceipt;
393: }
394: open(OUT,">$confdir$filename") or
395: die("Cannot output to $confdir$filename\n");
396: foreach my $key (keys %perlvar) {
397: my $value=$perlvar{$key};
398: print(OUT <<END);
399: PerlSetVar $key $value
400: END
401: }
402: close(OUT);
1.1 harris41 403: }
404: </perlscript>
405: </file>
406: <file>
1.5 harris41 407: <target dist='default'>/</target>
1.1 harris41 408: <perlscript mode='fg'>
409: # read values from loncapa.conf
1.7 harris41 410: my $confdir='/etc/httpd/conf/';
1.5 harris41 411: my $filename='loncapa.conf';
412: my %perlvar;
413: if (-e "$confdir$filename") {
414: open(CONFIG,'<'.$confdir.$filename) or
415: die("Can't read $confdir$filename");
416: while (my $configline=<CONFIG>) {
417: if ($configline =~ /^[^\#]*PerlSetVar/) {
418: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
419: chomp($varvalue);
420: $perlvar{$varname}=$varvalue;
421: }
422: }
423: close(CONFIG);
424: }
1.16 harris41 425: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
426: $perlvar{'lonLoadLim'}='2.00';
427: }
1.25 albertel 428: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
429: $perlvar{'lonUserLoadLim'}='0';
430: }
1.16 harris41 431: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
432: $perlvar{'lonExpire'}='86400';
433: }
434: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
435: my $lonReceipt='';
436: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
437: my @alnum=(0..9,a..z);
438: foreach my $i (1..20) {
439: $lonReceipt.=$alnum[int(rand(36))];
440: }
441: $perlvar{'lonReceipt'}=$lonReceipt;
442: }
1.7 harris41 443: my %perlvarstatic;
444: if (-e "${confdir}loncapa_apache.conf") {
445: open(CONFIG,'<'.$confdir.'loncapa_apache.conf') or
446: die("Can't read ${confdir}loncapa_apache.conf");
447: while (my $configline=<CONFIG>) {
448: if ($configline =~ /^[^\#]*PerlSetVar/) {
449: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
450: chomp($varvalue);
451: $perlvarstatic{$varname}=$varvalue;
452: }
453: }
454: close(CONFIG);
455: }
1.23 albertel 456: if (!$domainDescription && $lonCluster ne 'existing') {
1.27 albertel 457: open(IN,'<../'.$lonCluster.'_domain.tab');
1.22 albertel 458: while(<IN>) {
1.27 albertel 459: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 ! albertel 460: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.22 albertel 461: chomp($domainDescription);
1.29 ! albertel 462: chomp($domainTabExtras);
1.22 albertel 463: last;
464: }
465: }
1.23 albertel 466: close(IN);
1.22 albertel 467: }
1.23 albertel 468: if (!$domainDescription) {
1.27 albertel 469: open(IN,'</home/httpd/lonTabs/domain.tab');
1.23 albertel 470: while(<IN>) {
1.27 albertel 471: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 ! albertel 472: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.23 albertel 473: chomp($domainDescription);
1.29 ! albertel 474: chomp($domainTabExtras);
1.23 albertel 475: last;
476: }
477: }
478: close(IN);
479: }
480:
1.6 harris41 481: # implement editing logic below, interactively
1.22 albertel 482: # update loncapa.conf until 8 is entered
1.6 harris41 483:
484: $flag=0;
1.17 harris41 485:
1.6 harris41 486: while (!$flag) {
1.1 harris41 487: print(<<END);
488:
489: ===============================================================================
490: This is now the current configuration of your machine.
1.8 harris41 491: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 492: 2) Domain Description: $domainDescription
493: 3) Machine Name: $perlvar{'lonHostID'}
494: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
495: 5) Role: $perlvar{'lonRole'}
496: 6) Cache Expiration Time: $perlvar{'lonExpire'}
497: 7) Server Load: $perlvar{'lonLoadLim'}
1.25 albertel 498: 8) User Load: $perlvar{'lonUserLoadLim'}
499: 9) Everything is correct up above
1.6 harris41 500: END
1.17 harris41 501: my $hbug=-1;
502: my $dbug=-1;
503: {
504: my $v=$perlvar{'lonHostID'};
505: $hbug=0;
506: $hbug=1 if $v=~/\W/;
507: $hbug=1 if $v=~/\_/;
508: }
509: {
510: my $v=$1;
511: $dbug=0;
512: $dbug=1 if $v=~/\W/;
513: $dbug=1 if $v=~/\_/;
514: }
515:
516: if ($hbug) {
517: print "**** ERROR **** ".
518: "Invalid lonHostID (should only be letters and/or digits)\n";
519: }
520: if ($dbug) {
521: print "**** ERROR **** ".
522: "Invalid lonDefDomain (should only be letters and/or digits)\n";
523: }
524:
1.6 harris41 525: print(<<END);
1.25 albertel 526: ENTER A CHOICE OF 1-8 TO CHANGE, otherwise ENTER 9:
1.1 harris41 527: END
1.5 harris41 528: my $choice=<>;
529: chomp($choice);
1.6 harris41 530: if ($choice==1) {
531: print(<<END);
1.16 harris41 532: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 533: ENTER NEW VALUE (this is an internal value used to identify a group of
534: LON-CAPA machines, it must be alphanumerical, we suggest
535: using a part of your actual DNS domain. For example, for
536: the machine loncapa.msu.edu, we set the Domain to msu):
1.6 harris41 537: END
538: my $choice2=<>;
539: chomp($choice2);
1.8 harris41 540: $perlvar{'lonDefDomain'}=$choice2;
1.6 harris41 541: }
542: elsif ($choice==2) {
543: print(<<END);
1.20 albertel 544: 2) Domain Description: $domainDescription
545: ENTER NEW VALUE (this should be a string that describes your domain, spaces
546: and punctuation are fine except for ':'):
547: END
548: my $choice2=<>;
549: chomp($choice2);
550: $domainDescription=$choice2;
551: }
552: elsif ($choice==3) {
553: print(<<END);
554: 3) Machine Name: $perlvar{'lonHostID'}
555: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
556: it cannot contain any of '_' '-' '.' or ':'. We suggest that
557: if you are in the domain 'example' and are the first library
558: server you enter 'examplel1') :
1.6 harris41 559: END
560: my $choice2=<>;
561: chomp($choice2);
1.8 harris41 562: $perlvar{'lonHostID'}=$choice2;
1.6 harris41 563: }
1.20 albertel 564: elsif ($choice==4) {
1.6 harris41 565: print(<<END);
1.20 albertel 566: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6 harris41 567: ENTER NEW VALUE:
568: END
569: my $choice2=<>;
570: chomp($choice2);
1.9 harris41 571: $perlvar{'lonAdmEMail'}=$choice2;
1.6 harris41 572: }
1.20 albertel 573: elsif ($choice==5) {
1.6 harris41 574: print(<<END);
1.20 albertel 575: 5) Role: $perlvar{'lonRole'}
576: ENTER NEW VALUE (this should be either 'access' or 'library'
577: if in doubt select 'library'):
1.6 harris41 578: END
579: my $choice2=<>;
580: chomp($choice2);
581: $perlvar{'lonRole'}=$choice2;
582: }
1.20 albertel 583: elsif ($choice==6) {
1.6 harris41 584: print(<<END);
1.20 albertel 585: 6) Cache Expiration Time: $perlvar{'lonExpire'}
586: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6 harris41 587: END
588: my $choice2=<>;
589: chomp($choice2);
590: $perlvar{'lonExpire'}=$choice2;
591: }
1.20 albertel 592: elsif ($choice==7) {
1.6 harris41 593: print(<<END);
1.20 albertel 594: 7) Server Load: $perlvar{'lonLoadLim'}
1.6 harris41 595: ENTER NEW VALUE:
596: END
597: my $choice2=<>;
598: chomp($choice2);
599: $perlvar{'lonLoadLim'}=$choice2;
600: }
1.20 albertel 601: elsif ($choice==8) {
1.25 albertel 602: print(<<END);
603: 8) User Load: $perlvar{'lonUserLoadLim'}
604: Numer of users that can login before machine is 'overloaded'
1.26 albertel 605: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25 albertel 606: END
607: my $choice2=<>;
608: chomp($choice2);
609: $perlvar{'lonUserLoadLim'}=$choice2;
610: }
611: elsif ($choice==9) {
1.6 harris41 612: $flag=1;
613: }
614: else {
1.1 harris41 615:
1.6 harris41 616: }
617: }
1.7 harris41 618: open(OUT,">$confdir$filename") or
619: die("Cannot output to $confdir$filename\n");
620: foreach my $key (keys %perlvar) {
621: my $value=$perlvar{$key};
1.8 harris41 622: print(OUT <<END) unless $perlvarstatic{$key};
1.7 harris41 623: PerlSetVar $key $value
624: END
625: }
626: close(OUT);
1.1 harris41 627: </perlscript>
628: </file>
629: <file>
630: <target dist='default'>loncom/hosts.tab</target>
631: <perlscript mode='fg'>
632: unless (-l "<TARGET />") {
1.22 albertel 633: my $hostname=`hostname`;chomp($hostname);
634: my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
635: $hostaddress=~s/\s//;
1.15 harris41 636: $date=`date -I`; chomp($date);
637: $lonHostID=$perlvar{'lonHostID'};
638: $lonHostID=~s/\W//g;
639: $lineexistflag=0;
640: $hostidexistflag=0;
1.22 albertel 641: $line2insert=<<END;
1.27 albertel 642: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
1.15 harris41 643: END
1.29 ! albertel 644: $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
1.23 albertel 645: if ($lonCluster eq 'standalone') {
646: open(OUT,'>../'.$lonCluster.'_hosts.tab') or
647: die('file generation error');
648: print(OUT $line2insert);
649: close(OUT);
1.27 albertel 650: open(OUT,'>../'.$lonCluster.'_domain.tab') or
651: die('file generation error');
652: print(OUT $domaininsert);
653: close(OUT);
1.23 albertel 654: }
1.15 harris41 655: if ($flag==1) {
1.6 harris41 656: `rm -f ../hosts.tab`;
1.15 harris41 657: open(IN,'<../'.$lonCluster.'_hosts.tab');
1.13 harris41 658: while(<IN>) {
659: if (/^$line2insert$/) {
660: $lineexistflag=1;
661: }
1.15 harris41 662: if (/^$lonHostID\:/) {
1.13 harris41 663: $hostidexistflag=1;
664: }
665: }
666: close(IN);
667: if ($hostidexistflag and !$lineexistflag) {
668: print <<END;
669: WARNING: $lonHostID already exists inside
1.15 harris41 670: loncapa/loncom/${lonCluster}_hosts.tab. The entry inside
671: ${lonCluster}_hosts.tab does not match your settings.
672: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13 harris41 673: with your new values.
674: END
1.15 harris41 675: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
676: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
677: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14 harris41 678: print(OUT $line2insert);
1.13 harris41 679: close(OUT);
1.15 harris41 680: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13 harris41 681: # email appropriate message
1.28 albertel 682: system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
1.19 harris41 683: `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
1.13 harris41 684: }
685: elsif ($hostidexistflag and $lineexistflag) {
1.15 harris41 686: print <<END;
687: Entry exists in ${lonCluster}_hosts.tab.
688: END
689: `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
690: # email appropriate message
691: `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13 harris41 692: }
1.15 harris41 693: elsif (!$hostidexistflag and !$lineexistflag) {
694: print <<END;
695: New entry for $lonCluster.
1.6 harris41 696: END
1.15 harris41 697: `cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1.21 albertel 698: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
699: die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15 harris41 700: print(OUT $line2insert);
701: close(OUT);
702: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
703: # email appropriate message
704: `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27 albertel 705: }
706: }
707: $lineexistflag=0;
708: if ($flag==1) {
709: `rm -f ../domain.tab`;
710: open(IN,'<../'.$lonCluster.'_domain.tab');
711: while(<IN>) {
712: if (/^$domaininsert$/) {
713: $lineexistflag=1;
714: }
715: if (/^$perlvar{'lonDefDomain'}\:/) {
716: $domainexistflag=1;
717: }
718: }
719: close(IN);
720: if ($domainexistflag and !$lineexistflag) {
721: print <<END;
722: WARNING: $perlvar{'lonDefDomain'} already exists inside
723: loncapa/loncom/${lonCluster}_domain.tab. The entry inside
724: ${lonCluster}_domain.tab does not match your settings.
725: The entry inside ${lonCluster}_domain.tab is being replaced
726: with your new values.
727: END
728: `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
729: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
730: die("cannot open loncom/${lonCluster}_domain.tab for output\n");
731: print(OUT $domaininsert);
732: close(OUT);
733: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
734: # email appropriate message
1.28 albertel 735: system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
1.27 albertel 736: `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
737: }
738: elsif ($domainexistflag and $lineexistflag) {
739: print <<END;
740: Entry exists in ${lonCluster}_domain.tab.
741: END
742: `ln -s ${lonCluster}_domain.tab ../domain.tab`;
743: # email appropriate message
744: `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
745: }
746: elsif (!$domainexistflag and !$lineexistflag) {
747: print <<END;
748: New entry for $lonCluster.
749: END
750: `cat ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
751: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
752: die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
753: print(OUT $domaininsert);
754: close(OUT);
755: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
756: # email appropriate message
757: `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6 harris41 758: }
759: }
1.1 harris41 760: }
761: </perlscript>
762: </file>
763: </files>
764: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>