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