Annotation of doc/loncapafiles/updatequery.piml, revision 1.44
1.2 harris41 1: <!-- updatequery.piml -->
1.1 harris41 2:
1.44 ! albertel 3: <!-- $Id: updatequery.piml,v 1.43 2005/12/09 00:53:54 raeburn Exp $ -->
1.1 harris41 4:
5: <!--
6:
7: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8:
9: LON-CAPA is free software; you can redistribute it and/or modify
10: it under the terms of the GNU General Public License as published by
11: the Free Software Foundation; either version 2 of the License, or
12: (at your option) any later version.
13:
14: LON-CAPA is distributed in the hope that it will be useful,
15: but WITHOUT ANY WARRANTY; without even the implied warranty of
16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: GNU General Public License for more details.
18:
19: You should have received a copy of the GNU General Public License
20: along with LON-CAPA; if not, write to the Free Software
21: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22:
23: /home/httpd/html/adm/gpl.txt
24:
25: http://www.lon-capa.org/
26:
27: -->
28:
29: <piml>
30: <targetroot>/</targetroot>
31: <files>
32: <file>
1.4 harris41 33: <target dist='default'>/</target>
1.1 harris41 34: <perlscript mode='fg'>
1.4 harris41 35: $|=1;
1.1 harris41 36: print(<<END);
37:
38:
39: *********************************************
40: *********************************************
41: **** ****
42: **** LON-CAPA SYSTEM INFORMATION REQUEST ****
43: **** ****
44: **** Please respond to the choices below ****
45: **** ****
46: *********************************************
47: *********************************************
48:
49: END
1.4 harris41 50: sleep(3);
1.1 harris41 51: </perlscript>
52: </file>
53: <file>
1.22 albertel 54: <target dist='default'>loncom/hosts.tab</target>
55: <perlscript mode='fg'>
56: unless (-l "<TARGET />") {
57: print(<<END);
58:
59: ===============================================================================
1.30 www 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
1.22 albertel 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
1.30 www 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.
1.40 albertel 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.)
1.22 albertel 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: }
1.27 albertel 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: }
1.22 albertel 118: }
119: elsif ($choice==26) {
120: $lonCluster='rawhide'; $flag=1;
121: }
122: }
123: }
124: </perlscript>
125: </file>
126: <file>
1.10 harris41 127: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1 harris41 128: <perlscript mode='fg'>
1.4 harris41 129: $|=1;
1.20 albertel 130: my $domainDescription;
1.29 albertel 131: my $domainTabExtras;
1.43 raeburn 132: my $primaryLibServer;
133: my @libservers = ();
1.1 harris41 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
1.32 raeburn 139: or contact helpdesk\@lon-capa.org.
1.1 harris41 140:
141: ===============================================================================
1.4 harris41 142: The following 4 values are needed to configure LON-CAPA:
143: * Machine Role
1.8 harris41 144: * LON-CAPA Domain Name
145: * LON-CAPA Machine ID Name, and
1.1 harris41 146: * System Administration E-mail Address.
1.32 raeburn 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:
1.1 harris41 154: END
1.3 harris41 155:
1.4 harris41 156: open(OUT,'>/tmp/loncapa_updatequery.out');
157: close(OUT);
158:
1.3 harris41 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.
1.4 harris41 169: 1) Will this be a library server? (recommended if this is your first install)
1.3 harris41 170: 2) Or, will this be an access server?
171: END
1.4 harris41 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: }
1.3 harris41 199:
200: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.36 albertel 201: my $hostname=`hostname -f`; chomp($hostname);
1.4 harris41 202: my $ipdomain='';
203: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
204: $ipdomain=$1;
205: }
1.1 harris41 206:
207: print(<<END);
208:
1.8 harris41 209: **** Domain ****
210: [this does NOT need to correspond to internet address domains,
1.37 www 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.]
1.1 harris41 222: END
1.8 harris41 223:
224: # get domain name
1.1 harris41 225: # accept if valid, if not valid, tell user and repeat
1.4 harris41 226: $flag=0;
1.8 harris41 227: my $lonDefDomain;
1.4 harris41 228: while (!$flag) {
229: if ($ipdomain) {
230: print(<<END);
1.8 harris41 231: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4 harris41 232: END
233: }
234: else {
235: print(<<END);
1.8 harris41 236: ENTER LONCAPA DOMAIN:
1.4 harris41 237: END
238: }
239: my $choice=<>;
240: chomp($choice);
1.18 harris41 241: my $bad_domain_flag=0;
1.41 albertel 242: my @bad_domain_names=('res','raw','userfiles','priv','adm','uploaded',
243: 'editupload');
1.18 harris41 244: foreach my $bad (@bad_domain_names) {
245: $bad_domain_flag=1 if $choice eq $bad;
246: }
1.37 www 247: if ($choice=~/capa/i) {
248: $bad_domain_flag=1;
249: }
1.8 harris41 250: if ($ipdomain and $choice=~/^\s*$/) {
251: $choice=$ipdomain;
1.4 harris41 252: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 253: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 254: close(OUT);
1.8 harris41 255: $lonDefDomain=$choice;
1.4 harris41 256: $flag=1;
1.37 www 257: } elsif (length($choice)>12) {
258: print "Name too long\n";
259: } elsif (length($choice)<2) {
260: print "Name too short\n";
1.38 www 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";
1.37 www 264: } elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
1.4 harris41 265: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 266: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 267: close(OUT);
1.8 harris41 268: $lonDefDomain=$choice;
269: $r='l';
1.4 harris41 270: $flag=1;
1.37 www 271: } else {
1.4 harris41 272: print "Invalid input (only alphanumeric characters supported).\n";
273: }
274: }
1.1 harris41 275:
1.20 albertel 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:
1.8 harris41 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:
1.1 harris41 310: print(<<END);
311:
1.8 harris41 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;
1.37 www 316: good examples: "msul1" or "bioneta2";
317: bad examples: "loncapabox" or "studentsinside".
318: Note that machine names are very hard to change later.]
1.1 harris41 319: END
1.8 harris41 320: # get machine name
1.1 harris41 321: # accept if valid, if not valid, tell user and repeat
1.4 harris41 322: $flag=0;
323: while (!$flag) {
324: if ($ipdomain) {
325: print(<<END);
1.8 harris41 326: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4 harris41 327: END
328: }
329: else {
330: print(<<END);
1.8 harris41 331: ENTER LONCAPA MACHINE ID:
1.4 harris41 332: END
333: }
334: my $choice=<>;
335: chomp($choice);
1.37 www 336: if ($choice=~/capa/i) {
337: print "Invalid input (names containing 'capa' are reserved).\n";
338: } elsif ($lonHostID and $choice=~/^\s*$/) {
1.8 harris41 339: $choice=$lonHostID;
1.4 harris41 340: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 341: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 342: close(OUT);
1.8 harris41 343: $lonHostID=$choice;
1.4 harris41 344: $flag=1;
1.37 www 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+$/) {
1.4 harris41 350: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 351: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 352: close(OUT);
1.8 harris41 353: $lonHostID=$choice;
1.4 harris41 354: $flag=1;
1.37 www 355: } else {
1.4 harris41 356: print "Invalid input (only alphanumeric characters supported).\n";
357: }
358: }
1.1 harris41 359:
1.43 raeburn 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:
1.32 raeburn 417: # get admin e-mail address
1.4 harris41 418: # accept if valid, if not valid, tell user and repeat
419: $flag=0;
1.9 harris41 420: my $lonAdmEMail;
1.4 harris41 421: while (!$flag) {
1.1 harris41 422: print(<<END);
423:
424: **** System Administrator's E-mail ****
425: E-mail address of the person who will manage this machine
1.4 harris41 426: [should be in the form somebody\@somewhere]
1.32 raeburn 427: ENTER ADMIN E-MAIL ADDRESS:
1.1 harris41 428: END
429:
1.4 harris41 430: my $choice=<>;
431: chomp($choice);
432: if ($choice=~/\@/) {
433: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.9 harris41 434: print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4 harris41 435: close(OUT);
1.9 harris41 436: $lonAdmEMail=$choice;
1.4 harris41 437: $flag=1;
438: }
439: else {
440: print "Invalid input (this needs to look like an e-mail address!).\n";
441: }
442: }
443:
1.32 raeburn 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;
1.33 albertel 465: if ( ($choice=~/\@/) || $choice eq '') {
1.32 raeburn 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:
1.1 harris41 478: # update loncapa.conf
1.7 harris41 479: my $confdir='/etc/httpd/conf/';
480: #my $confdir='';
1.5 harris41 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);
1.12 harris41 489: $perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5 harris41 490: }
491: }
492: close(CONFIG);
493: }
494: $perlvar{'lonHostID'}=$lonHostID;
495: $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9 harris41 496: $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.32 raeburn 497: $perlvar{'lonSupportEMail'}=$lonSupportEMail;
1.5 harris41 498: $perlvar{'lonRole'}=$lonRole;
1.16 harris41 499: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5 harris41 500: $perlvar{'lonLoadLim'}='2.00';
501: }
1.25 albertel 502: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
503: $perlvar{'lonUserLoadLim'}='0';
504: }
1.16 harris41 505: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5 harris41 506: $perlvar{'lonExpire'}='86400';
507: }
1.16 harris41 508: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5 harris41 509: my $lonReceipt='';
1.11 harris41 510: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5 harris41 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);
1.1 harris41 526: }
527: </perlscript>
528: </file>
529: <file>
1.5 harris41 530: <target dist='default'>/</target>
1.1 harris41 531: <perlscript mode='fg'>
1.31 albertel 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: }
1.1 harris41 547: # read values from loncapa.conf
1.7 harris41 548: my $confdir='/etc/httpd/conf/';
1.5 harris41 549: my $filename='loncapa.conf';
550: my %perlvar;
1.31 albertel 551: my ($securestatus,$securenum);
1.5 harris41 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: }
1.16 harris41 564: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
565: $perlvar{'lonLoadLim'}='2.00';
566: }
1.25 albertel 567: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
568: $perlvar{'lonUserLoadLim'}='0';
569: }
1.16 harris41 570: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
571: $perlvar{'lonExpire'}='86400';
572: }
1.31 albertel 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);
1.16 harris41 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: }
1.7 harris41 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: }
1.23 albertel 602: if (!$domainDescription && $lonCluster ne 'existing') {
1.27 albertel 603: open(IN,'<../'.$lonCluster.'_domain.tab');
1.22 albertel 604: while(<IN>) {
1.27 albertel 605: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 albertel 606: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.22 albertel 607: chomp($domainDescription);
1.29 albertel 608: chomp($domainTabExtras);
1.22 albertel 609: last;
610: }
611: }
1.23 albertel 612: close(IN);
1.22 albertel 613: }
1.23 albertel 614: if (!$domainDescription) {
1.27 albertel 615: open(IN,'</home/httpd/lonTabs/domain.tab');
1.23 albertel 616: while(<IN>) {
1.27 albertel 617: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 albertel 618: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.23 albertel 619: chomp($domainDescription);
1.29 albertel 620: chomp($domainTabExtras);
1.23 albertel 621: last;
622: }
623: }
624: close(IN);
625: }
1.43 raeburn 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: }
1.23 albertel 672:
1.6 harris41 673: # implement editing logic below, interactively
1.22 albertel 674: # update loncapa.conf until 8 is entered
1.6 harris41 675:
676: $flag=0;
1.17 harris41 677:
1.6 harris41 678: while (!$flag) {
1.1 harris41 679: print(<<END);
680:
681: ===============================================================================
682: This is now the current configuration of your machine.
1.31 albertel 683: 1) Domain Name: $perlvar{'lonDefDomain'}
684: 2) Domain Description: $domainDescription
685: 3) Machine Name: $perlvar{'lonHostID'}
1.43 raeburn 686: 4) ID of primary library server for domain: $primaryLibServer
687: 5) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
688: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
689: 7) Role: $perlvar{'lonRole'}
690: 8) Cache Expiration Time: $perlvar{'lonExpire'}
691: 9) Server Load: $perlvar{'lonLoadLim'}
692: 10) User Load: $perlvar{'lonUserLoadLim'}
693: 11) Allow only secure connections: $securestatus
694: 12) Everything is correct up above
1.6 harris41 695: END
1.38 www 696:
697: my $error='';
698: foreach my $v ($perlvar{'lonDefDomain'},$perlvar{'lonHostID'}) {
699: if (length($v)>16) { $error.="\nName $v too long"; }
700: if (length($v)<2) { $error.="\nName $v too short"; }
1.39 albertel 701: if ($v=~/capa/i) {
702: if ($v!~/^oucapa\d+$/ &&
703: ($v!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
704: $error.="\nName $v contains 'capa'";
705: }
706: }
1.41 albertel 707: foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
708: 'editupload') {
1.38 www 709: $error.="\nName $v reserved." if $v eq $bad;
710: }
711: if ($v=~/\W/) { $error.="\nName $v contains special characters"; }
712: }
1.42 albertel 713: if ($domainDescription!~/^[\(\)\-\w\s,]+$/) {
1.38 www 714: $error.="\nDomain Description contains special characters";
715: }
716: foreach my $v ($perlvar{'lonExpire'},$perlvar{'lonLoadLim'}) {
717: unless ($v=~/^[\d+\.]+$/) { $error.="\nNumber expected instead of $v"; }
718: }
719: unless (($perlvar{'lonRole'} eq 'library') || ($perlvar{'lonRole'} eq 'access')) {
720: $error.="\nInvalid Role";
1.17 harris41 721: }
1.43 raeburn 722:
723: if (!defined($primaryLibServer)) {
724: if (@libservers > 0) {
725: $error .= "No primary library server ID designated. Choose from: ".join(',',sort(@libservers));
726: } else {
727: $error .= "No library servers in this domain (including current server)";
728: }
729: } else {
730: if (length($primaryLibServer)>16) { $error.="\nPrimary Library Server ID: $primaryLibServer too long"; }
731: if (length($primaryLibServer)<2) { $error.="\nPrimary Library Server ID: $primaryLibServer too short"; }
732: if ($primaryLibServer =~/capa/i) {
733: if ($primaryLibServer!~/^oucapa\d+$/ &&
734: ($primaryLibServer!~/^capa\d+$/ && $perlvar{'lonDefDomain'} eq 'uwsp')) {
735: $error.="\nPrimary library server ID $primaryLibServer contains 'capa'";
736: }
737: }
738: foreach my $bad ('res','raw','userfiles','priv','adm','uploaded',
739: 'editupload') {
740: $error.="\nPrimary library server ID $primaryLibServer reserved." if $primaryLibServer eq $bad;
741: }
742: if ($primaryLibServer=~/\W/) { $error.="\nPrimary library server ID $primaryLibServer contains special characters"; }
743: }
744:
745:
1.38 www 746: if ($error) { print "\n*** ERRORS: $error\n"; }
1.6 harris41 747: print(<<END);
1.43 raeburn 748: ENTER A CHOICE OF 1-11 TO CHANGE, otherwise ENTER 12:
1.1 harris41 749: END
1.5 harris41 750: my $choice=<>;
751: chomp($choice);
1.6 harris41 752: if ($choice==1) {
753: print(<<END);
1.16 harris41 754: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 755: ENTER NEW VALUE (this is an internal value used to identify a group of
756: LON-CAPA machines, it must be alphanumerical, we suggest
757: using a part of your actual DNS domain. For example, for
758: the machine loncapa.msu.edu, we set the Domain to msu):
1.6 harris41 759: END
760: my $choice2=<>;
761: chomp($choice2);
1.8 harris41 762: $perlvar{'lonDefDomain'}=$choice2;
1.6 harris41 763: }
764: elsif ($choice==2) {
765: print(<<END);
1.20 albertel 766: 2) Domain Description: $domainDescription
767: ENTER NEW VALUE (this should be a string that describes your domain, spaces
768: and punctuation are fine except for ':'):
769: END
770: my $choice2=<>;
771: chomp($choice2);
772: $domainDescription=$choice2;
773: }
774: elsif ($choice==3) {
775: print(<<END);
776: 3) Machine Name: $perlvar{'lonHostID'}
777: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
778: it cannot contain any of '_' '-' '.' or ':'. We suggest that
779: if you are in the domain 'example' and are the first library
780: server you enter 'examplel1') :
1.6 harris41 781: END
782: my $choice2=<>;
783: chomp($choice2);
1.8 harris41 784: $perlvar{'lonHostID'}=$choice2;
1.6 harris41 785: }
1.20 albertel 786: elsif ($choice==4) {
1.6 harris41 787: print(<<END);
1.43 raeburn 788: 4) ID of primary library server for domain: $primaryLibServer
789: ENTER NEW VALUE (this will be the LON-CAPA Machine ID of a library server in
790: your domain; it cannot contain any of '_' '-' '.' or ':'.
791: This server will be where domain data which are not
792: associated with any specific home library server
793: will be stored (e.g., e-mail broadcast by Domain Coordinators
794: to users in the domain).
795: END
796: my $choice2=<>;
797: chomp($choice2);
798: $primaryLibServer=$choice2;
799: }
800: elsif ($choice==5) {
801: print(<<END);
802: 5) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6 harris41 803: ENTER NEW VALUE:
804: END
805: my $choice2=<>;
806: chomp($choice2);
1.9 harris41 807: $perlvar{'lonAdmEMail'}=$choice2;
1.6 harris41 808: }
1.43 raeburn 809: elsif ($choice==6) {
1.6 harris41 810: print(<<END);
1.43 raeburn 811: 6) Support E-mail Address: $perlvar{'lonSupportEMail'}
1.32 raeburn 812: ENTER NEW VALUE:
813: END
814: my $choice2=<>;
815: chomp($choice2);
816: $perlvar{'lonSupportEMail'}=$choice2;
817: }
1.43 raeburn 818: elsif ($choice==7) {
1.32 raeburn 819: print(<<END);
1.43 raeburn 820: 7) Role: $perlvar{'lonRole'}
1.20 albertel 821: ENTER NEW VALUE (this should be either 'access' or 'library'
822: if in doubt select 'library'):
1.6 harris41 823: END
824: my $choice2=<>;
825: chomp($choice2);
826: $perlvar{'lonRole'}=$choice2;
827: }
1.43 raeburn 828: elsif ($choice==8) {
1.6 harris41 829: print(<<END);
1.43 raeburn 830: 8) Cache Expiration Time: $perlvar{'lonExpire'}
1.20 albertel 831: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6 harris41 832: END
833: my $choice2=<>;
834: chomp($choice2);
835: $perlvar{'lonExpire'}=$choice2;
836: }
1.43 raeburn 837: elsif ($choice==9) {
1.6 harris41 838: print(<<END);
1.43 raeburn 839: 9) Server Load: $perlvar{'lonLoadLim'}
1.6 harris41 840: ENTER NEW VALUE:
841: END
842: my $choice2=<>;
843: chomp($choice2);
844: $perlvar{'lonLoadLim'}=$choice2;
845: }
1.43 raeburn 846: elsif ($choice==10) {
1.25 albertel 847: print(<<END);
1.43 raeburn 848: 10) User Load: $perlvar{'lonUserLoadLim'}
1.25 albertel 849: Numer of users that can login before machine is 'overloaded'
1.26 albertel 850: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25 albertel 851: END
852: my $choice2=<>;
853: chomp($choice2);
854: $perlvar{'lonUserLoadLim'}=$choice2;
855: }
1.43 raeburn 856: elsif ($choice==11) {
1.31 albertel 857: print(<<END);
1.43 raeburn 858: 11) Allow only secure connections: $securestatus
1.31 albertel 859: The Lon-CAPA communication daemons lonc and lond can be configured to
860: allow only secure connections by default.
861:
862: POSSIBLE CHOICES:
863: 1) allow only secure connections and don't connect to machines that
864: can not be connected to securely
865: 2) allow only secure connections but allow this machine to connect to
866: machines that don't support secure connections
867: 3) allow insecure connections to this machine but only allow connections
868: to machines that support secure connections
869: 4) allow insecure connections
870: ENTER NEW VALUE (currenly $securenum):
871: END
872: my $choice2=<>;
873: chomp($choice2);
874: if ($choice2 eq '1') {
875: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
876: } elsif ($choice2 eq '2') {
877: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
878: } elsif ($choice2 eq '3') {
879: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
880: } elsif ($choice2 eq '4') {
881: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
882: }
883: ($securestatus,$securenum)=&securesetting(%perlvar);
884: }
1.43 raeburn 885: elsif (($choice==12) && (!$error)) {
1.6 harris41 886: $flag=1;
887: }
888: else {
1.38 www 889: print "Invalid input.\n";
1.6 harris41 890: }
891: }
1.7 harris41 892: open(OUT,">$confdir$filename") or
893: die("Cannot output to $confdir$filename\n");
894: foreach my $key (keys %perlvar) {
895: my $value=$perlvar{$key};
1.8 harris41 896: print(OUT <<END) unless $perlvarstatic{$key};
1.7 harris41 897: PerlSetVar $key $value
898: END
899: }
900: close(OUT);
1.1 harris41 901: </perlscript>
902: </file>
903: <file>
904: <target dist='default'>loncom/hosts.tab</target>
905: <perlscript mode='fg'>
906: unless (-l "<TARGET />") {
1.36 albertel 907: my $hostname=`hostname -f`;chomp($hostname);
1.15 harris41 908: $date=`date -I`; chomp($date);
909: $lonHostID=$perlvar{'lonHostID'};
910: $lonHostID=~s/\W//g;
911: $lineexistflag=0;
912: $hostidexistflag=0;
1.22 albertel 913: $line2insert=<<END;
1.35 albertel 914: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname
1.15 harris41 915: END
1.43 raeburn 916: $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras:$primaryLibServer\n";
1.23 albertel 917: if ($lonCluster eq 'standalone') {
918: open(OUT,'>../'.$lonCluster.'_hosts.tab') or
919: die('file generation error');
920: print(OUT $line2insert);
921: close(OUT);
1.27 albertel 922: open(OUT,'>../'.$lonCluster.'_domain.tab') or
923: die('file generation error');
924: print(OUT $domaininsert);
925: close(OUT);
1.23 albertel 926: }
1.15 harris41 927: if ($flag==1) {
1.6 harris41 928: `rm -f ../hosts.tab`;
1.15 harris41 929: open(IN,'<../'.$lonCluster.'_hosts.tab');
1.13 harris41 930: while(<IN>) {
931: if (/^$line2insert$/) {
932: $lineexistflag=1;
933: }
1.15 harris41 934: if (/^$lonHostID\:/) {
1.13 harris41 935: $hostidexistflag=1;
936: }
937: }
938: close(IN);
939: if ($hostidexistflag and !$lineexistflag) {
940: print <<END;
941: WARNING: $lonHostID already exists inside
1.15 harris41 942: loncapa/loncom/${lonCluster}_hosts.tab. The entry inside
943: ${lonCluster}_hosts.tab does not match your settings.
944: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13 harris41 945: with your new values.
946: END
1.15 harris41 947: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
948: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
949: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14 harris41 950: print(OUT $line2insert);
1.13 harris41 951: close(OUT);
1.15 harris41 952: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13 harris41 953: # email appropriate message
1.34 albertel 954: `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13 harris41 955: }
956: elsif ($hostidexistflag and $lineexistflag) {
1.15 harris41 957: print <<END;
958: Entry exists in ${lonCluster}_hosts.tab.
959: END
960: `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
961: # email appropriate message
962: `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13 harris41 963: }
1.15 harris41 964: elsif (!$hostidexistflag and !$lineexistflag) {
965: print <<END;
966: New entry for $lonCluster.
1.6 harris41 967: END
1.15 harris41 968: `cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1.21 albertel 969: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
970: die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15 harris41 971: print(OUT $line2insert);
972: close(OUT);
973: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
974: # email appropriate message
975: `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27 albertel 976: }
977: }
978: $lineexistflag=0;
979: if ($flag==1) {
980: `rm -f ../domain.tab`;
981: open(IN,'<../'.$lonCluster.'_domain.tab');
982: while(<IN>) {
983: if (/^$domaininsert$/) {
984: $lineexistflag=1;
985: }
986: if (/^$perlvar{'lonDefDomain'}\:/) {
987: $domainexistflag=1;
988: }
989: }
990: close(IN);
991: if ($domainexistflag and !$lineexistflag) {
992: print <<END;
993: WARNING: $perlvar{'lonDefDomain'} already exists inside
994: loncapa/loncom/${lonCluster}_domain.tab. The entry inside
995: ${lonCluster}_domain.tab does not match your settings.
996: The entry inside ${lonCluster}_domain.tab is being replaced
997: with your new values.
998: END
999: `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
1000: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
1001: die("cannot open loncom/${lonCluster}_domain.tab for output\n");
1002: print(OUT $domaininsert);
1003: close(OUT);
1004: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1005: # email appropriate message
1.34 albertel 1006: `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27 albertel 1007: }
1008: elsif ($domainexistflag and $lineexistflag) {
1009: print <<END;
1010: Entry exists in ${lonCluster}_domain.tab.
1011: END
1012: `ln -s ${lonCluster}_domain.tab ../domain.tab`;
1013: # email appropriate message
1014: `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1015: }
1016: elsif (!$domainexistflag and !$lineexistflag) {
1017: print <<END;
1018: New entry for $lonCluster.
1019: END
1020: `cat ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
1021: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
1022: die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
1023: print(OUT $domaininsert);
1024: close(OUT);
1025: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
1026: # email appropriate message
1027: `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6 harris41 1028: }
1029: }
1.1 harris41 1030: }
1031: </perlscript>
1032: </file>
1033: </files>
1034: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>