1: <!-- updatequery.piml -->
2:
3: <!-- $Id: updatequery.piml,v 1.83 2016/07/29 17:26:44 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: use strict;
37: print(<<END);
38:
39:
40: *********************************************
41: *********************************************
42: **** ****
43: **** LON-CAPA SYSTEM INFORMATION REQUEST ****
44: **** ****
45: **** Please respond to the choices below ****
46: **** ****
47: *********************************************
48: *********************************************
49:
50: END
51: #sleep(3);
52: </perlscript>
53: </file>
54: <file>
55: <target dist='default'>loncom/hosts.tab</target>
56: <perlscript mode='fg'>
57: my $lonCluster;
58: unless (-l "<TARGET />") {
59: print(<<END);
60:
61: ===============================================================================
62: Which cluster option would you like to have installed?
63: IMPORTANT: to take advantage of the cluster options 1) and 3),
64: you must contact loncapa\@loncapa.org.
65:
66: 1) PRODUCTION - you want to eventually connect this machine to the
67: LON-CAPA content sharing network. This setting is for
68: schools, colleges, and universities, that currently
69: are running - or in the future will run - courses.
70: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
71: not be connected to other LON-CAPA machines for now.
72: 3) DEVELOPMENT - you want to do software (not content!) development with
73: this workstation and eventually link it with the
74: workstations of other LON-CAPA software developers.
75: 4) RUNNING YOUR OWN CLUSTER - this machine is not in the standard LON-CAPA
76: clusters and won't be in the future and you want the existing
77: hosts.tab and domain.tab files to be left alone.
78: (This choice is unlikely what you want to select.)
79: END
80: # Option number 26 will install rawhide_hosts.tab, but
81: # the typical user does not want to be part of an intensive
82: # machine test cluster.
83:
84: # get input
85: # if valid then process, otherwise loop
86: my $flag=0;
87: while (!$flag) {
88: print "ENTER 1, 2, 3, or 4:\n";
89: my $choice=<>;
90: chomp($choice);
91: if ($choice==1) {
92: $lonCluster='production'; $flag=1;
93: }
94: elsif ($choice==2) {
95: $lonCluster='standalone'; $flag=1;
96: }
97: elsif ($choice==3) {
98: $lonCluster='development'; $flag=1;
99: }
100: elsif ($choice==4) {
101: $lonCluster='existing'; $flag=1;
102: foreach my $file ('hosts.tab','dns_hosts.tab',
103: 'domain.tab','dns_domain.tab') {
104: if (-e '/home/httpd/lonTabs/'.$file) {
105: `cp /home/httpd/lonTabs/$file ../existing_$file`;
106: }
107: else {
108: print <<END;
109: There is no existing /home/httpd/lonTabs/$file
110: END
111: die('');
112: }
113: }
114: }
115: elsif ($choice==26) {
116: $lonCluster='rawhide'; $flag=1;
117: }
118: }
119: }
120: </perlscript>
121: </file>
122: <file>
123: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
124: <perlscript mode='fg'>
125: $|=1;
126: my $domainDescription;
127: my $domainTabExtras;
128: my $primaryLibServer;
129: my $protocol;
130: my $intdom;
131: my @libservers = ();
132: unless (-e "<TARGET />") {
133: print(<<END);
134: WELCOME TO LON-CAPA!
135:
136: If you have questions, please visit http://install.loncapa.org
137: or contact helpdesk\@loncapa.org.
138:
139: ===============================================================================
140: The following 7 values are needed to configure LON-CAPA:
141: * Machine Role
142: * LON-CAPA Domain Name
143: * LON-CAPA Machine ID Name
144: * Server Administration E-mail Address
145: * LON-CAPA Domain's Primary Library Server Machine ID
146: * Web Server Protocol
147: * Internet Domain Name of Your Institution
148: ===============================================================================
149:
150: In addition, a Support E-mail Address can also be included. If
151: an address is included then one of the options in the LON-CAPA
152: help menu will be a link to a form that a user will complete to
153: request LON-CAPA help.
154:
155: END
156:
157: open(OUT,'>/tmp/loncapa_updatequery.out');
158: close(OUT);
159:
160: # query for Machine Role
161: print(<<END);
162: **** Machine Role ****
163: Library server (recommended if first-time installation of LON-CAPA):
164: Servers that are repositories of authoritative educational resources.
165: These servers also provide the authoring spaces in which content
166: creators (e.g., faculty instructors) create their learning content.
167: Access server:
168: Servers that load-balance high-traffic delivery of educational resources
169: over the world-wide web.
170: 1) Will this be a library server? (recommended if this is your first install)
171: 2) Or, will this be an access server?
172: END
173: my $flag=0;
174: my $r='';
175: my $lonRole;
176: while (!$flag) {
177: print "ENTER A CHOICE OF 1 or 2:\n";
178: my $choice=<>;
179: chomp($choice);
180: if ($choice==1) {
181: open(OUT,'>>/tmp/loncapa_updatequery.out');
182: print(OUT 'lonRole'."\t".'library'."\n");
183: close(OUT);
184: $lonRole='library';
185: $r='l';
186: $flag=1;
187: }
188: elsif ($choice==2) {
189: open(OUT,'>>/tmp/loncapa_updatequery.out');
190: print(OUT 'lonRole'."\t".'access'."\n");
191: close(OUT);
192: $lonRole='access';
193: $r='a';
194: $flag=2;
195: }
196: else {
197:
198: }
199: }
200:
201: # need to recommend a machine ID name (ipdomain.l.somenumber)
202: my $hostname=`hostname -f`; chomp($hostname);
203: my $ipdomain='';
204: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
205: $ipdomain=$1;
206: }
207:
208: print(<<END);
209:
210: **** Domain ****
211: [This does NOT need to correspond to an internet address domain.
212: Please make this name short AND descriptive of your organization.
213: Domain names are close to impossible to change later!!!
214: Good examples might be "msu" or "bionet" or "vermontcc".
215: Bad examples are "physics" (too general)
216: or "michiganstateuniversity" (too long)
217: or "msuedu" (just make it "msu", or else make it msu.edu)
218: or "msuphysics" (only if there is a good reason to limit to department
219: - we don't know of one)
220: or "mydomain" (what is that?)
221: Avoid multiple domains at the same institution, even if it means that you
222: have to actually work together with your colleagues. You can still run
223: multiple library servers within the same domain.
224: If this domain is eventually going to be part of the main production
225: cluster, you MUST contact the LON-CAPA group at MSU (loncapa\@loncapa.org)
226: to have a domain name assigned, and then use it exactly as given. This is
227: also true for test installs that might eventually turn into production setups.
228: The short domain name needs to be unique, if your aim is to join a cluster
229: containing existing domains. Stop now if you have not yet contacted the
230: MSU LON-CAPA group.]
231: END
232:
233: # get domain name
234: # accept if valid, if not valid, tell user and repeat
235: $flag=0;
236: my $lonDefDomain;
237: while (!$flag) {
238: if ($ipdomain) {
239: print(<<END);
240: ENTER LONCAPA DOMAIN [$ipdomain]:
241: END
242: }
243: else {
244: print(<<END);
245: ENTER LONCAPA DOMAIN:
246: END
247: }
248: my $choice=<>;
249: chomp($choice);
250: my $bad_domain_flag=0;
251: my @bad_domain_names=('res','raw','userfiles','priv','adm','uploaded',
252: 'editupload');
253: foreach my $bad (@bad_domain_names) {
254: $bad_domain_flag=1 if $choice eq $bad;
255: }
256: if ($choice=~/capa/i) {
257: $bad_domain_flag=1;
258: }
259: if ($ipdomain and $choice=~/^\s*$/) {
260: $choice=$ipdomain;
261: open(OUT,'>>/tmp/loncapa_updatequery.out');
262: print(OUT 'lonDefDomain'."\t".$choice."\n");
263: close(OUT);
264: $lonDefDomain=$choice;
265: $flag=1;
266: } elsif (length($choice)>35) {
267: print "Name too long\n";
268: } elsif (length($choice)<2) {
269: print "Name too short\n";
270: } elsif ($bad_domain_flag) {
271: print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
272: print "Please try something different than '$choice'\n";
273: } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
274: open(OUT,'>>/tmp/loncapa_updatequery.out');
275: print(OUT 'lonDefDomain'."\t".$choice."\n");
276: close(OUT);
277: $lonDefDomain=$choice;
278: $r='l';
279: $flag=1;
280: } else {
281: print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
282: }
283: }
284:
285:
286: # get domain description
287: # accept if valid, if not valid, tell user and repeat
288: $flag=0;
289:
290: while (!$flag) {
291: print(<<END);
292:
293: **** Domain Description ****
294: String describing the domain, to be shown to users.
295: [Example, msu is Michigan State University]
296: ENTER DOMAIN DESCRIPTION:
297: END
298:
299: my $choice=<>;
300: chomp($choice);
301: if ($choice!~/:/) {
302: open(OUT,'>>/tmp/loncapa_updatequery.out');
303: print(OUT 'domainDescription'."\t".$choice."\n");
304: close(OUT);
305: $domainDescription=$choice;
306: $flag=1;
307: }
308: else {
309: print "Invalid input (no ':' allowed).\n";
310: }
311: }
312:
313: my $lonHostID;
314: if ($lonDefDomain) {
315: $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
316: # against the hosts.tab
317: }
318:
319: print(<<END);
320:
321: **** Machine ID Name ****
322: [This does NOT need to correspond to internet address names;
323: this name MUST be unique to the whole LON-CAPA network;
324: we recommend that you use a name based off of your institution.
325: Good examples: "msul1" or "bioneta2".
326: Bad examples: "loncapabox" or "studentsinside".
327: Note that machine names are very hard to change later.]
328: END
329: # get machine name
330: # accept if valid, if not valid, tell user and repeat
331: $flag=0;
332: while (!$flag) {
333: if ($ipdomain) {
334: print(<<END);
335: ENTER LONCAPA MACHINE ID [$lonHostID]:
336: END
337: }
338: else {
339: print(<<END);
340: ENTER LONCAPA MACHINE ID:
341: END
342: }
343: my $choice=<>;
344: chomp($choice);
345: if ($choice=~/capa/i) {
346: print "Invalid input (names containing 'capa' are reserved).\n";
347: } elsif ($lonHostID and $choice=~/^\s*$/) {
348: $choice=$lonHostID;
349: open(OUT,'>>/tmp/loncapa_updatequery.out');
350: print(OUT 'lonHostID'."\t".$choice."\n");
351: close(OUT);
352: $lonHostID=$choice;
353: $flag=1;
354: } elsif (length($choice)>45) {
355: print "Name too long\n";
356: } elsif (length($choice)<4) {
357: print "Name too short\n";
358: } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
359: open(OUT,'>>/tmp/loncapa_updatequery.out');
360: print(OUT 'lonHostID'."\t".$choice."\n");
361: close(OUT);
362: $lonHostID=$choice;
363: $flag=1;
364: } else {
365: print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
366: }
367: }
368:
369: # get primary library server in domain
370: if ($lonRole eq 'library') {
371: if (!grep/^\Q$lonHostID\E$/,@libservers) {
372: push(@libservers,$lonHostID);
373: }
374: if (@libservers == 1) {
375: $primaryLibServer = $libservers[0];
376: }
377: }
378:
379: $flag=0;
380: while (!$flag) {
381: print(<<END);
382: **** Domain's Primary Library Server ID ****
383: This should be the LON-CAPA machine ID of a library server in your
384: domain. If you only have a single library server in your domain, then
385: the Primary Library server ID will be the machine ID of that server.
386: This server will be where domain data which are not associated with any
387: specific home library server will be stored (e.g., configurations that
388: apply to all nodes in the domain).
389: END
390: if (defined($primaryLibServer)) {
391: print(<<END);
392: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$primaryLibServer]:
393: END
394: } elsif (@libservers > 0) {
395: print(<<END);
396: ENTER DOMAIN'S PRIMARY LIBRARY SERVER ID [$libservers[0]]
397: END
398: } else {
399: print (<<END);
400: 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.
401: END
402: }
403:
404: my $choice=<>;
405: chomp($choice);
406: if ($primaryLibServer and $choice=~/^\s*$/) {
407: $choice=$primaryLibServer;
408: open(OUT,'>>/tmp/loncapa_updatequery.out');
409: print(OUT 'primaryLibServer'."\t".$choice."\n");
410: close(OUT);
411: $flag=1;
412: } elsif (length($choice)>35) {
413: print "Name too long\n";
414: } elsif (length($choice)<4) {
415: print "Name too short\n";
416: } elsif ($choice!~/\_/ and $choice=~/^[\w\-.]+$/) {
417: open(OUT,'>>/tmp/loncapa_updatequery.out');
418: print(OUT 'primaryLibServer'."\t".$choice."\n");
419: close(OUT);
420: $primaryLibServer=$choice;
421: $flag=1;
422: } else {
423: print "Invalid input (only alphanumeric characters, '-', and '.' supported).\n";
424: }
425: }
426:
427:
428: # get admin e-mail address
429: # accept if valid, if not valid, tell user and repeat
430: $flag=0;
431: my $lonAdmEMail;
432: while (!$flag) {
433: print(<<END);
434:
435: **** Server Administrators E-mail ****
436: E-mail address of the person who will manage this machine
437: [should be in the form somebody\@somewhere]
438: ENTER ADMIN E-MAIL ADDRESS:
439: END
440:
441: my $choice=<>;
442: chomp($choice);
443: if ($choice=~/\@/) {
444: open(OUT,'>>/tmp/loncapa_updatequery.out');
445: print(OUT 'lonAdmEMail'."\t".$choice."\n");
446: close(OUT);
447: $lonAdmEMail=$choice;
448: $flag=1;
449: }
450: else {
451: print "Invalid input (this needs to look like an e-mail address!).\n";
452: }
453: }
454:
455:
456: # get support e-mail address
457: # accept if valid, if not valid, tell user and repeat
458: $flag=0;
459: my $lonSupportEMail;
460: while (!$flag) {
461: print(<<END);
462:
463: **** Support E-mail ****
464: E-mail address of the person who will receive
465: help requests from LON-CAPA users who access
466: the system via this server. If the address is left blank,
467: then a help support form will not be displayed
468: as part of the help menu.
469: [should be in the form somebody\@somewhere]
470: ENTER SUPPORT E-MAIL ADDRESS:
471: END
472:
473: my $choice=<>;
474: chomp($choice);
475: $choice =~ s/\s//g;
476: if ( ($choice=~/\@/) || $choice eq '') {
477: open(OUT,'>>/tmp/loncapa_updatequery.out');
478: print(OUT 'lonSupportEMail'."\t".$choice."\n");
479: close(OUT);
480: $lonSupportEMail=$choice;
481: $flag=1;
482: }
483: else {
484: print "Invalid input (this either needs to be blank, or look like an e-mail address!).\n";
485: }
486: }
487:
488: # get protocol
489: # accept if valid, if not valid, tell user and repeat
490: $flag=0;
491: while (!$flag) {
492: print(<<END);
493:
494: **** Web Server Protocol ****
495: If you plan to run the Apache server with SSL enabled,
496: the protocol should be: https; otherwise it should be http.
497: ENTER WEB SERVER PROTOCOL [http]:
498: END
499:
500: my $choice=<>;
501: chomp($choice);
502: if ($choice =~ /^https?$/) {
503: open(OUT,'>>/tmp/loncapa_updatequery.out');
504: print(OUT 'protocol'."\t".$choice."\n");
505: close(OUT);
506: $protocol=$choice;
507: $flag=1;
508: } elsif ($choice eq '') {
509: open(OUT,'>>/tmp/loncapa_updatequery.out');
510: print(OUT 'protocol'."\t".'http'."\n");
511: close(OUT);
512: $protocol = 'http';
513: $flag = 1;
514: } else {
515: print "Invalid input (only http or https allowed).\n";
516: }
517: }
518:
519: # get internet domain
520: # accept if valid, if not valid, tell user and repeat
521: $flag=0;
522: while (!$flag) {
523: print(<<END);
524:
525: **** Internet Domain Name of Your Institution ****
526:
527: The internet domain name used for servers at your institution
528: should be provided. This will be similar to: ustate.edu or
529: topcollege.ac.uk or myhostingcompany.com, i.e., the part of
530: a server hostname which indicates to which organization the
531: server belongs.
532:
533: ENTER INTERNET DOMAIN NAME:
534: END
535:
536: my $choice=<>;
537: chomp($choice);
538: if ($choice =~/[^.]+\.[^.]+/) {
539: open(OUT,'>>/tmp/loncapa_updatequery.out');
540: print(OUT 'internet domain'."\t".$choice."\n");
541: close(OUT);
542: $intdom=$choice;
543: $flag=1;
544: }
545: else {
546: print "Invalid input (must be at least two levels separated by . - e.g., ustate.edu).\n";
547: }
548: }
549:
550:
551: # update loncapa.conf
552: my $confdir = '/etc/httpd/conf/';
553: if ('<DIST />' eq 'sles10' || '<DIST />' eq 'sles11' || '<DIST />' eq 'sles12' || '<DIST />' eq 'suse10.1' || '<DIST />' eq 'suse10.2' || '<DIST />' eq 'suse10.3' || '<DIST />' eq 'suse11.1' || '<DIST />' eq 'suse11.2' || '<DIST />' eq 'suse11.3' || '<DIST />' eq 'suse11.4' || '<DIST />' eq 'suse12.1' || '<DIST />' eq 'suse12.2' || '<DIST />' eq 'suse12.3' || '<DIST />' eq 'suse13.1' || '<DIST />' eq 'suse13.2' || '<DIST />' eq 'debian5' || '<DIST />' eq 'debian6' || '<DIST />' eq 'ubuntu6' || '<DIST />' eq 'ubuntu8' || '<DIST />' eq 'ubuntu10' || '<DIST />' eq 'ubuntu12' || '<DIST />' eq 'ubuntu14' || '<DIST />' eq 'ubuntu16') {
554: $confdir = '/etc/apache2/';
555: }
556: my $filename='loncapa.conf';
557: my %perlvar;
558: if (-e "$confdir$filename") {
559: open(CONFIG,'<'.$confdir.$filename) or die("Can't read $confdir$filename");
560: while (my $configline=<CONFIG>) {
561: if ($configline =~ /^[^\#]*PerlSetVar/) {
562: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
563: chomp($varvalue);
564: $perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
565: }
566: }
567: close(CONFIG);
568: }
569: $perlvar{'lonHostID'}=$lonHostID;
570: $perlvar{'lonDefDomain'}=$lonDefDomain;
571: $perlvar{'lonAdmEMail'}=$lonAdmEMail;
572: $perlvar{'lonSupportEMail'}=$lonSupportEMail;
573: $perlvar{'lonRole'}=$lonRole;
574: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
575: $perlvar{'lonLoadLim'}='2.00';
576: }
577: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
578: $perlvar{'lonUserLoadLim'}='0';
579: }
580: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
581: $perlvar{'lonExpire'}='86400';
582: }
583: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
584: my $lonReceipt='';
585: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
586: my @alnum=(0..9,"a".."z");
587: foreach my $i (1..20) {
588: $lonReceipt.=$alnum[int(rand(36))];
589: }
590: $perlvar{'lonReceipt'}=$lonReceipt;
591: }
592: open(OUT,">$confdir$filename") or
593: die("Cannot output to $confdir$filename\n");
594: foreach my $key (keys %perlvar) {
595: my $value=$perlvar{$key};
596: my $line = "PerlSetVar $key $value";
597: if ($value eq '') {
598: $line = '#'.$line;
599: }
600: print(OUT <<END);
601: $line
602: END
603: }
604: close(OUT);
605: }
606: </perlscript>
607: </file>
608: <file>
609: <target dist='default'>/etc/httpd/conf/</target>
610: <target dist='sles10 sles11 sles12 suse10.1 suse10.2 suse10.3 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2 debian5 debian6 ubuntu6 ubuntu8 ubuntu10 ubuntu12 ubuntu14 ubuntu16'>/etc/apache2/</target>
611: <perlscript mode='fg'>
612: sub securesetting {
613: my (%perlvar)=@_;
614: my $securestatus='unknown';
615: my $securenum='';
616: if ( $perlvar{'loncAllowInsecure'}&& $perlvar{'londAllowInsecure'}) {
617: $securestatus='no'; $securenum='4';
618: } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
619: $securestatus='lond'; $securenum='3';
620: } elsif (!$perlvar{'loncAllowInsecure'}&& $perlvar{'londAllowInsecure'}) {
621: $securestatus='lonc'; $securenum='2';
622: } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
623: $securestatus='yes (lond and lonc)'; $securenum='1';
624: }
625: return ($securestatus,$securenum);
626: }
627: # read values from loncapa.conf
628: my $confdir = "<TARGET />";
629: my $filename='loncapa.conf';
630: my %perlvar;
631: my ($securestatus,$securenum);
632: if (-e "$confdir$filename") {
633: open(CONFIG,'<'.$confdir.$filename) or
634: die("Can't read $confdir$filename");
635: while (my $configline=<CONFIG>) {
636: if ($configline =~ /^[^\#]*PerlSetVar/) {
637: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
638: chomp($varvalue);
639: $perlvar{$varname}=$varvalue;
640: }
641: }
642: close(CONFIG);
643: }
644: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
645: $perlvar{'lonLoadLim'}='2.00';
646: }
647: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
648: $perlvar{'lonUserLoadLim'}='0';
649: }
650: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
651: $perlvar{'lonExpire'}='86400';
652: }
653: unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
654: $perlvar{'londAllowInsecure'}='1';
655: }
656: unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
657: $perlvar{'loncAllowInsecure'}='1';
658: }
659: ($securestatus,$securenum)=&securesetting(%perlvar);
660: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
661: my $lonReceipt='';
662: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
663: my @alnum=(0..9,"a".."z");
664: foreach my $i (1..20) {
665: $lonReceipt.=$alnum[int(rand(36))];
666: }
667: $perlvar{'lonReceipt'}=$lonReceipt;
668: }
669: my %perlvarstatic;
670: if (-e "${confdir}loncapa_apache.conf") {
671: open(CONFIG,'<'.$confdir.'loncapa_apache.conf') or
672: die("Can't read ${confdir}loncapa_apache.conf");
673: while (my $configline=<CONFIG>) {
674: if ($configline =~ /^[^\#]*PerlSetVar/) {
675: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
676: chomp($varvalue);
677: $perlvarstatic{$varname}=$varvalue;
678: }
679: }
680: close(CONFIG);
681: }
682:
683: my (@hosts_files, @domain_files);
684: if ( $lonCluster ne 'existing') {
685: push(@domain_files,'../'.$lonCluster.'_domain.tab',
686: '../'.$lonCluster.'_dns_domain.tab');
687: push(@hosts_files,'../'.$lonCluster.'_hosts.tab',
688: '../'.$lonCluster.'_dns_hosts.tab');
689: }
690: push(@domain_files,'/home/httpd/lonTabs/domain.tab',
691: '/home/httpd/lonTabs/dns_domain.tab');
692: push(@hosts_files,'/home/httpd/lonTabs/hosts.tab',
693: '/home/httpd/lonTabs/dns_hosts.tab');
694:
695: if (!$domainDescription) {
696: foreach my $file (@domain_files) {
697: open(IN,'<'.$file);
698: while(my $line = <IN>) {
699: if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
700: (undef,$domainDescription,$domainTabExtras)=split(/:/,$line,3);
701: chomp($domainDescription);
702: chomp($domainTabExtras);
703: # the remaining field (primary lib server) is handled later
704: $domainTabExtras = join(':',(split(/:/,$domainTabExtras))[0..5]);
705: last;
706: }
707: }
708: close(IN);
709: last if ($domainDescription);
710: }
711: }
712:
713: if (!$protocol) {
714: foreach my $file (@hosts_files) {
715: open(IN,'<'.$file);
716: while(my $line = <IN>) {
717: if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:(https?)/) {
718: $protocol = $1;
719: chomp($protocol);
720: last;
721: }
722: }
723: }
724: }
725:
726: if (!$protocol) {
727: $protocol = 'http';
728: }
729:
730: if (!$intdom) {
731: foreach my $file (@hosts_files) {
732: open(IN,'<'.$file);
733: while(my $line = <IN>) {
734: if ($line =~ /^\Q$perlvar{'lonHostID'}\E:\Q$perlvar{'lonDefDomain'}\E\:(?:access|library)\:[^:]+\:https?\:([^:]+)/) {
735: $intdom = $1;
736: chomp($intdom);
737: last;
738: }
739: }
740: }
741: }
742:
743: while(!$primaryLibServer && (@hosts_files || @domain_files)) {
744: my $file = shift(@domain_files);
745: open(IN,'<'.$file);
746: while(my $line = <IN>) {
747: if ($line =~ /^\Q$perlvar{'lonDefDomain'}\E\:/) {
748: $primaryLibServer=(split(/:/,$line))[8];
749: chomp($primaryLibServer);
750: }
751: }
752: close(IN);
753: last if ($primaryLibServer);
754: $file = shift(@hosts_files);
755: open(IN,'<'.$file);
756: while(my $line = <IN>) {
757: if ($line =~ /^([^\:]+)\:\Q$perlvar{'lonDefDomain'}\E\:library\:/) {
758: push(@libservers,$1);
759: }
760: }
761: # make list unique
762: @libservers = keys(%{{ map { $_ => 1 } (@libservers) }});
763: close(IN);
764: if (@libservers == 1) {
765: $primaryLibServer = $libservers[0];
766: }
767: }
768:
769: # implement editing logic below, interactively
770: # update loncapa.conf until 14 is entered
771:
772: my $flag=0;
773:
774: while (!$flag) {
775: print(<<END);
776:
777: ===============================================================================
778: This is now the current configuration of your machine.
779: 1) Domain Name: $perlvar{'lonDefDomain'}
780: 2) Domain Description: $domainDescription
781: 3) Machine Name: $perlvar{'lonHostID'}
782: 4) ID of primary library server for domain: $primaryLibServer
783: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
784: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
785: 7) Web Server Protocol (http or https): $protocol
786: 8) Internet Domain Name: $intdom
787: 9) Role: $perlvar{'lonRole'}
788: 10) Cache Expiration Time: $perlvar{'lonExpire'}
789: 11) Server Load: $perlvar{'lonLoadLim'}
790: 12) User Load: $perlvar{'lonUserLoadLim'}
791: 13) Allow only secure connections: $securestatus
792: 14) Everything is correct up above
793: END
794:
795: my @error;
796: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
797: if (length($v)>35) { push(@error,"Name $v too long"); }
798: if (length($v)<2) { push(@error,"Name $v too short"); }
799: if ($v=~/capa/i) {
800: if ($v!~/^oucapa\d+$/ &&
801: ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
802: push(@error,"Name $v contains 'capa'");
803: }
804: }
805: foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
806: 'editupload') {
807: push(@error,"\nName $v reserved.") if $v eq $bad;
808: }
809: if ($v=~/[^\w\-.]/) { push(@error,"Name $v contains special characters"); }
810: }
811: if ($domainDescription =~ /^\s*$/) {
812: push(@error,"Domain Description is blank.");
813: } elsif ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
814: push(@error,"Domain Description contains special characters.");
815: }
816: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
817: unless ($v=~/^[\d+\.]+$/) { push(@error,"Number expected instead of $v"); }
818: }
819: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
820: push(@error,"Invalid Role");
821: }
822:
823: unless (($protocol eq 'http') || ($protocol eq 'https')) {
824: push(@error,"Invalid Protocol (must be http or https");
825: }
826:
827: if (!defined($intdom)) {
828: push(@error,"No internet domain name designated. Enter something like ustate.edu");
829: } elsif ($intdom !~ /[^.]+\.\w{2,6}$/) {
830: push(@error,"Invalid Internet domain name (must be at least two levels separated by . - e.g., ustate.edu");
831: }
832:
833: if (!defined($primaryLibServer)) {
834: if (@libservers > 0) {
835: push(@error,"No primary library server ID designated. Choose from: ".join(',',sort(@libservers)));
836: } else {
837: push(@error,"No library servers in this domain (including current server)");
838: }
839: } else {
840: if (length($primaryLibServer)>35) { push(@error,"Primary Library Server ID: $primaryLibServer too long"); }
841: if (length($primaryLibServer)<2) { push(@error,"Primary Library Server ID: $primaryLibServer too short"); }
842: if ($primaryLibServer =~/capa/i) {
843: if ($primaryLibServer!~/^oucapa\d+$/ &&
844: ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
845: push(@error,"Primary library server ID $primaryLibServer contains 'capa'")
846: }
847: }
848: foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
849: 'editupload') {
850: push(@error,"Primary library server ID $primaryLibServer reserved.") if $primaryLibServer eq $bad;
851: }
852: if ($primaryLibServer=~/[^\w\-.]/) { push(@error,"Primary library server ID $primaryLibServer contains special characters"); }
853: }
854:
855:
856: if (@error) { print "\n*** ERRORS: \n\t".join("\n\t",@error)."\n"; }
857: print(<<END);
858: ENTER A CHOICE OF 1-13 TO CHANGE, otherwise ENTER 14:
859: END
860: my $choice=<>;
861: chomp($choice);
862: if ($choice==1) {
863: print(<<END);
864: 1) Domain Name: $perlvar{'lonDefDomain'}
865: ENTER NEW VALUE (this is an internal value used to identify a group of
866: LON-CAPA machines, it must be alphanumerical, we suggest
867: using a part of your actual DNS domain. For example, for
868: the machine loncapa.msu.edu, we set the Domain to msu):
869: END
870: my $choice2=<>;
871: chomp($choice2);
872: $perlvar{'lonDefDomain'}=$choice2;
873: }
874: elsif ($choice==2) {
875: print(<<END);
876: 2) Domain Description: $domainDescription
877: ENTER NEW VALUE (this should be a string that describes your domain, spaces
878: and punctuation are fine except for ':'):
879: END
880: my $choice2=<>;
881: chomp($choice2);
882: $domainDescription=$choice2;
883: }
884: elsif ($choice==3) {
885: print(<<END);
886: 3) Machine Name: $perlvar{'lonHostID'}
887: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
888: it cannot contain any of '_' '-' '.' or ':'. We suggest that
889: if you are in the domain 'example' and are the first library
890: server you enter 'examplel1') :
891: END
892: my $choice2=<>;
893: chomp($choice2);
894: $perlvar{'lonHostID'}=$choice2;
895: }
896: elsif ($choice==4) {
897: print(<<END);
898: 4) ID of primary library server for domain: $primaryLibServer
899: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
900: your domain; it cannot contain any of '_' '-' '.' or ':'.
901: This server will be where domain data which are not
902: associated with any specific home library server
903: will be stored (e.g., e-mail broadcast by Domain Coordinators
904: to users in the domain).
905: END
906: my $choice2=<>;
907: chomp($choice2);
908: $primaryLibServer=$choice2;
909: }
910: elsif ($choice==5) {
911: print(<<END);
912: 5) Server Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
913: ENTER NEW VALUE:
914: END
915: my $choice2=<>;
916: chomp($choice2);
917: $perlvar{'lonAdmEMail'}=$choice2;
918: }
919: elsif ($choice==6) {
920: print(<<END);
921: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
922: ENTER NEW VALUE:
923: END
924: my $choice2=<>;
925: chomp($choice2);
926: $perlvar{'lonSupportEMail'}=$choice2;
927: }
928: elsif ($choice==7) {
929: print(<<END);
930: 7) Server Protocol (http or https):
931: ENTER NEW VALUE: (this should be either 'http' or 'https'
932: if in doubt set to 'http'):
933: END
934: my $choice2=<>;
935: chomp($choice2);
936: $protocol=$choice2;
937: }
938: elsif ($choice==8) {
939: print(<<END);
940: 8) Internet Domain Name of Institution
941: ENTER NEW VALUE:
942:
943: END
944: my $choice2=<>;
945: chomp($choice2);
946: $intdom=$choice2;
947: }
948: elsif ($choice==9) {
949: print(<<END);
950: 9) Role: $perlvar{'lonRole'}
951: ENTER NEW VALUE (this should be either 'access' or 'library'
952: if in doubt select 'library'):
953: END
954: my $choice2=<>;
955: chomp($choice2);
956: $perlvar{'lonRole'}=$choice2;
957: }
958: elsif ($choice==10) {
959: print(<<END);
960: 10) Cache Expiration Time: $perlvar{'lonExpire'}
961: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
962: END
963: my $choice2=<>;
964: chomp($choice2);
965: $perlvar{'lonExpire'}=$choice2;
966: }
967: elsif ($choice==11) {
968: print(<<END);
969: 11) Server Load: $perlvar{'lonLoadLim'}
970: ENTER NEW VALUE:
971: END
972: my $choice2=<>;
973: chomp($choice2);
974: $perlvar{'lonLoadLim'}=$choice2;
975: }
976: elsif ($choice==12) {
977: print(<<END);
978: 12) User Load: $perlvar{'lonUserLoadLim'}
979: Numer of users that can login before machine is 'overloaded'
980: ENTER NEW VALUE (integer value, 0 means there is no limit):
981: END
982: my $choice2=<>;
983: chomp($choice2);
984: $perlvar{'lonUserLoadLim'}=$choice2;
985: }
986: elsif ($choice==13) {
987: print(<<END);
988: 13) Allow only secure connections: $securestatus
989: The Lon-CAPA communication daemons lonc and lond can be configured to
990: allow only secure connections by default.
991:
992: POSSIBLE CHOICES:
993: 1) allow only secure connections and don't connect to machines that
994: can not be connected to securely
995: 2) allow only secure connections but allow this machine to connect to
996: machines that don't support secure connections
997: 3) allow insecure connections to this machine but only allow connections
998: to machines that support secure connections
999: 4) allow insecure connections
1000: ENTER NEW VALUE (currently $securenum):
1001: END
1002: my $choice2=<>;
1003: chomp($choice2);
1004: if ($choice2 eq '1') {
1005: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
1006: } elsif ($choice2 eq '2') {
1007: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
1008: } elsif ($choice2 eq '3') {
1009: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
1010: } elsif ($choice2 eq '4') {
1011: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
1012: }
1013: ($securestatus,$securenum)=&securesetting(%perlvar);
1014: }
1015: elsif (($choice==14) && (!@error)) {
1016: $flag=1;
1017: }
1018: else {
1019: print "Invalid input.\n";
1020: }
1021: }
1022: open(OUT,">$confdir$filename") or
1023: die("Cannot output to $confdir$filename\n");
1024: foreach my $key (keys %perlvar) {
1025: my $value=$perlvar{$key};
1026: my $line = "PerlSetVar $key $value";
1027: if ($value eq '') {
1028: $line = '#'.$line;
1029: }
1030: print(OUT <<END) unless $perlvarstatic{$key};
1031: $line
1032: END
1033: }
1034: close(OUT);
1035: </perlscript>
1036: </file>
1037: <file>
1038: <target dist='default'>loncom/hosts.tab</target>
1039: <perlscript mode='fg'>
1040: unless (-l "<TARGET />") {
1041: my $hostname=`hostname -f`;chomp($hostname);
1042: my $date=`date -I`; chomp($date);
1043: my $lonHostID=$perlvar{'lonHostID'};
1044: $lonHostID=~s/[^\w\-.]//g;
1045: my $lineexistflag=0;
1046: my $hostidexistflag=0;
1047: my $line2insert=<<END;
1048: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$protocol:$intdom
1049: END
1050: if (!$domainTabExtras) {
1051: $domainTabExtras=':::::';
1052: }
1053: my $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
1054: if ($lonCluster eq 'standalone') {
1055: open(OUT,'>../'.$lonCluster.'_hosts.tab') or
1056: die('file generation error');
1057: print(OUT $line2insert);
1058: print OUT ("^$hostname:$protocol\n");
1059: close(OUT);
1060: open(OUT,'>../'.$lonCluster.'_dns_hosts.tab') or
1061: die('file generation error');
1062: print(OUT $line2insert);
1063: close(OUT);
1064: open(OUT,'>../'.$lonCluster.'_domain.tab') or
1065: die('file generation error');
1066: print(OUT $domaininsert);
1067: close(OUT);
1068: open(OUT,'>../'.$lonCluster.'_dns_domain.tab') or
1069: die('file generation error');
1070: print(OUT $domaininsert);
1071: close(OUT);
1072: }
1073: if ($flag==1) {
1074: `rm -f ../hosts.tab`;
1075: `rm -f ../dns_hosts.tab`;
1076: `ln -s ${lonCluster}_dns_hosts.tab ../dns_hosts.tab`;
1077: open(IN,'<../'.$lonCluster.'_dns_hosts.tab');
1078: while(my $line = <IN>) {
1079: if ($line =~ /^\Q$line2insert\E$/) {
1080: $lineexistflag=1;
1081: }
1082: if ($line =~ /^\Q$lonHostID\E\:/) {
1083: $hostidexistflag=1;
1084: }
1085: }
1086: close(IN);
1087: if ($hostidexistflag and !$lineexistflag) {
1088: print <<END;
1089: WARNING: $lonHostID already exists inside
1090: loncapa/loncom/${lonCluster}_dns_hosts.tab. The entry inside
1091: ${lonCluster}_dns_hosts.tab does not match your settings.
1092: An entry inside ${lonCluster}_hosts.tab will be made
1093: with your new values.
1094: END
1095: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1096: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
1097: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1098: print(OUT $line2insert);
1099: close(OUT);
1100: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1101: # email appropriate message
1102: `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1103: }
1104: elsif ($hostidexistflag and $lineexistflag) {
1105: print <<END;
1106: Entry exists in ${lonCluster}_dns_hosts.tab. Making duplicate entry in ${lonCluster}_hosts.tab
1107: END
1108: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1109: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
1110: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1111: print(OUT $line2insert);
1112: close(OUT);
1113: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1114: # email appropriate message
1115: `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1116: }
1117: elsif (!$hostidexistflag and !$lineexistflag) {
1118: print <<END;
1119: New entry for $lonCluster.
1120: END
1121: `cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1122: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
1123: die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1124: print(OUT $line2insert);
1125: close(OUT);
1126: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1127: # email appropriate message
1128: `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$protocol:$intdom:$date" installrecord\@mail.lon-capa.org`;
1129: }
1130: }
1131: $lineexistflag=0;
1132: my $domainexistflag=0;
1133: if ($flag==1) {
1134: `rm -f ../domain.tab`;
1135: `rm -f ../dns_domain.tab`;
1136: `ln -s ${lonCluster}_dns_domain.tab ../dns_domain.tab`;
1137: open(IN,'<../'.$lonCluster.'_dns_domain.tab');
1138: while(my $line = <IN>) {
1139: if ($line =~/^\Q$domaininsert\E$/) {
1140: $lineexistflag=1;
1141: }
1142: if ($line =~/^\Q$perlvar{'lonDefDomain'}\E\:/) {
1143: $domainexistflag=1;
1144: }
1145: }
1146: close(IN);
1147: if ($domainexistflag and !$lineexistflag) {
1148: print <<END;
1149: WARNING: $perlvar{'lonDefDomain'} already exists inside
1150: loncapa/loncom/${lonCluster}_dns_domain.tab. The entry inside
1151: ${lonCluster}_dns_domain.tab does not match your settings.
1152: An entry will be made in inside ${lonCluster}_domain.tab
1153: with your new values.
1154: END
1155: `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
1156: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
1157: die("cannot open loncom/${lonCluster}_domain.tab for output\n");
1158: print(OUT $domaininsert);
1159: close(OUT);
1160: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1161: # email appropriate message
1162: `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1163: }
1164: elsif ($domainexistflag and $lineexistflag) {
1165: `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
1166: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
1167: die("cannot open loncom/${lonCluster}_domain.tab for output\n");
1168: print(OUT $domaininsert);
1169: close(OUT);
1170: print <<END;
1171: Entry exists in ${lonCluster}_dns_domain.tab. Making duplicate entry in ${lonCluster}_domain.tab
1172: END
1173: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1174: # email appropriate message
1175: `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1176: }
1177: elsif (!$domainexistflag and !$lineexistflag) {
1178: print <<END;
1179: New entry for $lonCluster.
1180: END
1181: `cat ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
1182: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
1183: die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
1184: print(OUT $domaininsert);
1185: close(OUT);
1186: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1187: # email appropriate message
1188: `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1189: }
1190: }
1191: }
1192: </perlscript>
1193: </file>
1194: </files>
1195: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>