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