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