Annotation of doc/loncapafiles/updatequery.piml, revision 1.31
1.2 harris41 1: <!-- updatequery.piml -->
1.1 harris41 2:
1.31 ! albertel 3: <!-- $Id: updatequery.piml,v 1.30 2004/05/21 20:40:53 www 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.27 albertel 73: 4) PRESERVE the existing hosts.tab and domain.tab
74: (/home/httpd/lonTabs/hosts.tab and
75: /home/httpd/lonTabs/domain.tab)
1.22 albertel 76:
77: END
78: # Option number 26 will install rawhide_hosts.tab, but
79: # the typical user does not want to be part of an intensive
80: # machine test cluster.
81:
82: # get input
83: # if valid then process, otherwise loop
84: $flag=0;
85: while (!$flag) {
86: print "ENTER 1, 2, 3, or 4:\n";
87: my $choice=<>;
88: chomp($choice);
89: if ($choice==1) {
90: $lonCluster='production'; $flag=1;
91: }
92: elsif ($choice==2) {
93: $lonCluster='standalone'; $flag=1;
94: }
95: elsif ($choice==3) {
96: $lonCluster='development'; $flag=1;
97: }
98: elsif ($choice==4) {
99: $lonCluster='existing'; $flag=1;
100: if (-e '/home/httpd/lonTabs/hosts.tab') {
101: `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
102: }
103: else {
104: print <<END;
105: There is no existing /home/httpd/lonTabs/hosts.tab
106: END
107: die('');
108: }
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.1 harris41 132: unless (-e "<TARGET />") {
133: print(<<END);
134: WELCOME TO LON-CAPA!
135:
136: If you have questions, please visit http://install.lon-capa.org
1.5 harris41 137: or contact sharrison\@mail.lon-capa.org.
1.1 harris41 138:
139: ===============================================================================
1.4 harris41 140: The following 4 values are needed to configure LON-CAPA:
141: * Machine Role
1.8 harris41 142: * LON-CAPA Domain Name
143: * LON-CAPA Machine ID Name, and
1.1 harris41 144: * System Administration E-mail Address.
145: END
1.3 harris41 146:
1.4 harris41 147: open(OUT,'>/tmp/loncapa_updatequery.out');
148: close(OUT);
149:
1.3 harris41 150: # query for Machine Role
151: print(<<END);
152: **** Machine Role ****
153: Library server (recommended if first-time installation of LON-CAPA):
154: Servers that are repositories of authoritative educational resources.
155: These servers also provide the construction space by which instructors
156: assemble their classroom online material.
157: Access server:
158: Servers that load-balance high-traffic delivery of educational resources
159: over the world-wide web.
1.4 harris41 160: 1) Will this be a library server? (recommended if this is your first install)
1.3 harris41 161: 2) Or, will this be an access server?
162: END
1.4 harris41 163: my $flag=0;
164: my $r='';
165: my $lonRole;
166: while (!$flag) {
167: print "ENTER A CHOICE OF 1 or 2:\n";
168: my $choice=<>;
169: chomp($choice);
170: if ($choice==1) {
171: open(OUT,'>>/tmp/loncapa_updatequery.out');
172: print(OUT 'lonRole'."\t".'library'."\n");
173: close(OUT);
174: $lonRole='library';
175: $r='l';
176: $flag=1;
177: }
178: elsif ($choice==2) {
179: open(OUT,'>>/tmp/loncapa_updatequery.out');
180: print(OUT 'lonRole'."\t".'access'."\n");
181: close(OUT);
182: $lonRole='access';
183: $r='a';
184: $flag=2;
185: }
186: else {
187:
188: }
189: }
1.3 harris41 190:
191: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.4 harris41 192: my $hostname=`hostname`; chomp($hostname);
193: my $ipdomain='';
194: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
195: $ipdomain=$1;
196: }
1.1 harris41 197:
198: print(<<END);
199:
1.8 harris41 200: **** Domain ****
201: [this does NOT need to correspond to internet address domains,
202: examples might be "msu" or "bionet" or "vermontcc"]
1.1 harris41 203: END
1.8 harris41 204:
205: # get domain name
1.1 harris41 206: # accept if valid, if not valid, tell user and repeat
1.4 harris41 207: $flag=0;
1.8 harris41 208: my $lonDefDomain;
1.4 harris41 209: while (!$flag) {
210: if ($ipdomain) {
211: print(<<END);
1.8 harris41 212: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4 harris41 213: END
214: }
215: else {
216: print(<<END);
1.8 harris41 217: ENTER LONCAPA DOMAIN:
1.4 harris41 218: END
219: }
220: my $choice=<>;
221: chomp($choice);
1.18 harris41 222: my $bad_domain_flag=0;
223: my @bad_domain_names=('raw','userfiles','priv','adm','uploaded');
224: foreach my $bad (@bad_domain_names) {
225: $bad_domain_flag=1 if $choice eq $bad;
226: }
1.8 harris41 227: if ($ipdomain and $choice=~/^\s*$/) {
228: $choice=$ipdomain;
1.4 harris41 229: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 230: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 231: close(OUT);
1.8 harris41 232: $lonDefDomain=$choice;
1.4 harris41 233: $flag=1;
234: }
235: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
236: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 237: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 238: close(OUT);
1.8 harris41 239: $lonDefDomain=$choice;
240: $r='l';
1.4 harris41 241: $flag=1;
1.18 harris41 242: }
243: elsif ($bad_domain_flag) {
244: print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
245: print "Please try something different than '$choice'\n";
1.4 harris41 246: }
247: else {
248: print "Invalid input (only alphanumeric characters supported).\n";
249: }
250: }
1.1 harris41 251:
1.20 albertel 252:
253: # get domain description
254: # accept if valid, if not valid, tell user and repeat
255: $flag=0;
256:
257: while (!$flag) {
258: print(<<END);
259:
260: **** Domain Description ****
261: String describing the domain, to be shown to users.
262: [Example, msu is Michigan State University]
263: ENTER DOMAIN DESCRIPTION:
264: END
265:
266: my $choice=<>;
267: chomp($choice);
268: if ($choice!~/:/) {
269: open(OUT,'>>/tmp/loncapa_updatequery.out');
270: print(OUT 'domainDescription'."\t".$choice."\n");
271: close(OUT);
272: $domainDescription=$choice;
273: $flag=1;
274: }
275: else {
276: print "Invalid input (no ':' allowed).\n";
277: }
278: }
279:
1.8 harris41 280: my $lonHostID;
281: if ($lonDefDomain) {
282: $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
283: # against the hosts.tab
284: }
285:
1.1 harris41 286: print(<<END);
287:
1.8 harris41 288: **** Machine ID Name ****
289: [this does NOT need to correspond to internet address names;
290: this name MUST be unique to the whole LON-CAPA network;
291: we recommend that you use a name based off of your institution;
292: good examples: "msul1" or "bionetl1";
293: bad examples: "loncapabox" or "studentsinside"]
1.1 harris41 294: END
1.8 harris41 295: # get machine name
1.1 harris41 296: # accept if valid, if not valid, tell user and repeat
1.4 harris41 297: $flag=0;
298: while (!$flag) {
299: if ($ipdomain) {
300: print(<<END);
1.8 harris41 301: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4 harris41 302: END
303: }
304: else {
305: print(<<END);
1.8 harris41 306: ENTER LONCAPA MACHINE ID:
1.4 harris41 307: END
308: }
309: my $choice=<>;
310: chomp($choice);
1.8 harris41 311: if ($lonHostID and $choice=~/^\s*$/) {
312: $choice=$lonHostID;
1.4 harris41 313: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 314: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 315: close(OUT);
1.8 harris41 316: $lonHostID=$choice;
1.4 harris41 317: $flag=1;
318: }
319: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
320: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 321: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 322: close(OUT);
1.8 harris41 323: $lonHostID=$choice;
1.4 harris41 324: $flag=1;
325: }
326: else {
327: print "Invalid input (only alphanumeric characters supported).\n";
328: }
329: }
1.1 harris41 330:
1.4 harris41 331: # get e-mail address
332: # accept if valid, if not valid, tell user and repeat
333: $flag=0;
1.9 harris41 334: my $lonAdmEMail;
1.4 harris41 335: while (!$flag) {
1.1 harris41 336: print(<<END);
337:
338: **** System Administrator's E-mail ****
339: E-mail address of the person who will manage this machine
1.4 harris41 340: [should be in the form somebody\@somewhere]
1.1 harris41 341: ENTER E-MAIL ADDRESS:
342: END
343:
1.4 harris41 344: my $choice=<>;
345: chomp($choice);
346: if ($choice=~/\@/) {
347: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.9 harris41 348: print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4 harris41 349: close(OUT);
1.9 harris41 350: $lonAdmEMail=$choice;
1.4 harris41 351: $flag=1;
352: }
353: else {
354: print "Invalid input (this needs to look like an e-mail address!).\n";
355: }
356: }
357:
1.1 harris41 358: # update loncapa.conf
1.7 harris41 359: my $confdir='/etc/httpd/conf/';
360: #my $confdir='';
1.5 harris41 361: my $filename='loncapa.conf';
362: my %perlvar;
363: if (-e "$confdir$filename") {
364: open(CONFIG,'<'.$confdir.$filename) or die("Can't read $confdir$filename");
365: while (my $configline=<CONFIG>) {
366: if ($configline =~ /^[^\#]*PerlSetVar/) {
367: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
368: chomp($varvalue);
1.12 harris41 369: $perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5 harris41 370: }
371: }
372: close(CONFIG);
373: }
374: $perlvar{'lonHostID'}=$lonHostID;
375: $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9 harris41 376: $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.5 harris41 377: $perlvar{'lonRole'}=$lonRole;
1.16 harris41 378: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5 harris41 379: $perlvar{'lonLoadLim'}='2.00';
380: }
1.25 albertel 381: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
382: $perlvar{'lonUserLoadLim'}='0';
383: }
1.16 harris41 384: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5 harris41 385: $perlvar{'lonExpire'}='86400';
386: }
1.16 harris41 387: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5 harris41 388: my $lonReceipt='';
1.11 harris41 389: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5 harris41 390: my @alnum=(0..9,a..z);
391: foreach my $i (1..20) {
392: $lonReceipt.=$alnum[int(rand(36))];
393: }
394: $perlvar{'lonReceipt'}=$lonReceipt;
395: }
396: open(OUT,">$confdir$filename") or
397: die("Cannot output to $confdir$filename\n");
398: foreach my $key (keys %perlvar) {
399: my $value=$perlvar{$key};
400: print(OUT <<END);
401: PerlSetVar $key $value
402: END
403: }
404: close(OUT);
1.1 harris41 405: }
406: </perlscript>
407: </file>
408: <file>
1.5 harris41 409: <target dist='default'>/</target>
1.1 harris41 410: <perlscript mode='fg'>
1.31 ! albertel 411: sub securesetting {
! 412: my (%perlvar)=@_;
! 413: my $securestatus='unknown';
! 414: my $securenum='';
! 415: if ( $perlvar{'loncAllowInsecure'}&& $perlvar{'londAllowInsecure'}) {
! 416: $securestatus='no'; $securenum='4';
! 417: } elsif ( $perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
! 418: $securestatus='lond'; $securenum='3';
! 419: } elsif (!$perlvar{'loncAllowInsecure'}&& $perlvar{'londAllowInsecure'}) {
! 420: $securestatus='lonc'; $securenum='2';
! 421: } elsif (!$perlvar{'loncAllowInsecure'}&& !$perlvar{'londAllowInsecure'}) {
! 422: $securestatus='yes (lond and lonc)'; $securenum='1';
! 423: }
! 424: return ($securestatus,$securenum);
! 425: }
1.1 harris41 426: # read values from loncapa.conf
1.7 harris41 427: my $confdir='/etc/httpd/conf/';
1.5 harris41 428: my $filename='loncapa.conf';
429: my %perlvar;
1.31 ! albertel 430: my ($securestatus,$securenum);
1.5 harris41 431: if (-e "$confdir$filename") {
432: open(CONFIG,'<'.$confdir.$filename) or
433: die("Can't read $confdir$filename");
434: while (my $configline=<CONFIG>) {
435: if ($configline =~ /^[^\#]*PerlSetVar/) {
436: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
437: chomp($varvalue);
438: $perlvar{$varname}=$varvalue;
439: }
440: }
441: close(CONFIG);
442: }
1.16 harris41 443: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
444: $perlvar{'lonLoadLim'}='2.00';
445: }
1.25 albertel 446: unless ($perlvar{'lonUserLoadLim'} and $perlvar{'lonUserLoadLim'}!~/\{\[\[\[\[/) {
447: $perlvar{'lonUserLoadLim'}='0';
448: }
1.16 harris41 449: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
450: $perlvar{'lonExpire'}='86400';
451: }
1.31 ! albertel 452: unless ($perlvar{'londAllowInsecure'} and $perlvar{'londAllowInsecure'}!~/\{\[\[\[\[/) {
! 453: $perlvar{'londAllowInsecure'}='1';
! 454: }
! 455: unless ($perlvar{'loncAllowInsecure'} and $perlvar{'loncAllowInsecure'}!~/\{\[\[\[\[/) {
! 456: $perlvar{'loncAllowInsecure'}='1';
! 457: }
! 458: ($securestatus,$securenum)=&securesetting(%perlvar);
1.16 harris41 459: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
460: my $lonReceipt='';
461: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
462: my @alnum=(0..9,a..z);
463: foreach my $i (1..20) {
464: $lonReceipt.=$alnum[int(rand(36))];
465: }
466: $perlvar{'lonReceipt'}=$lonReceipt;
467: }
1.7 harris41 468: my %perlvarstatic;
469: if (-e "${confdir}loncapa_apache.conf") {
470: open(CONFIG,'<'.$confdir.'loncapa_apache.conf') or
471: die("Can't read ${confdir}loncapa_apache.conf");
472: while (my $configline=<CONFIG>) {
473: if ($configline =~ /^[^\#]*PerlSetVar/) {
474: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
475: chomp($varvalue);
476: $perlvarstatic{$varname}=$varvalue;
477: }
478: }
479: close(CONFIG);
480: }
1.23 albertel 481: if (!$domainDescription && $lonCluster ne 'existing') {
1.27 albertel 482: open(IN,'<../'.$lonCluster.'_domain.tab');
1.22 albertel 483: while(<IN>) {
1.27 albertel 484: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 albertel 485: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.22 albertel 486: chomp($domainDescription);
1.29 albertel 487: chomp($domainTabExtras);
1.22 albertel 488: last;
489: }
490: }
1.23 albertel 491: close(IN);
1.22 albertel 492: }
1.23 albertel 493: if (!$domainDescription) {
1.27 albertel 494: open(IN,'</home/httpd/lonTabs/domain.tab');
1.23 albertel 495: while(<IN>) {
1.27 albertel 496: if (/^$perlvar{'lonDefDomain'}\:/) {
1.29 albertel 497: (undef,$domainDescription,$domainTabExtras)=split(/:/,$_,3);
1.23 albertel 498: chomp($domainDescription);
1.29 albertel 499: chomp($domainTabExtras);
1.23 albertel 500: last;
501: }
502: }
503: close(IN);
504: }
505:
1.6 harris41 506: # implement editing logic below, interactively
1.22 albertel 507: # update loncapa.conf until 8 is entered
1.6 harris41 508:
509: $flag=0;
1.17 harris41 510:
1.6 harris41 511: while (!$flag) {
1.1 harris41 512: print(<<END);
513:
514: ===============================================================================
515: This is now the current configuration of your machine.
1.31 ! albertel 516: 1) Domain Name: $perlvar{'lonDefDomain'}
! 517: 2) Domain Description: $domainDescription
! 518: 3) Machine Name: $perlvar{'lonHostID'}
! 519: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
! 520: 5) Role: $perlvar{'lonRole'}
! 521: 6) Cache Expiration Time: $perlvar{'lonExpire'}
! 522: 7) Server Load: $perlvar{'lonLoadLim'}
! 523: 8) User Load: $perlvar{'lonUserLoadLim'}
! 524: 9) Allow only secure connections: $securestatus
! 525: 10) Everything is correct up above
1.6 harris41 526: END
1.17 harris41 527: my $hbug=-1;
528: my $dbug=-1;
529: {
530: my $v=$perlvar{'lonHostID'};
531: $hbug=0;
532: $hbug=1 if $v=~/\W/;
533: $hbug=1 if $v=~/\_/;
534: }
535: {
536: my $v=$1;
537: $dbug=0;
538: $dbug=1 if $v=~/\W/;
539: $dbug=1 if $v=~/\_/;
540: }
541:
542: if ($hbug) {
543: print "**** ERROR **** ".
544: "Invalid lonHostID (should only be letters and/or digits)\n";
545: }
546: if ($dbug) {
547: print "**** ERROR **** ".
548: "Invalid lonDefDomain (should only be letters and/or digits)\n";
549: }
550:
1.6 harris41 551: print(<<END);
1.31 ! albertel 552: ENTER A CHOICE OF 1-9 TO CHANGE, otherwise ENTER 10:
1.1 harris41 553: END
1.5 harris41 554: my $choice=<>;
555: chomp($choice);
1.6 harris41 556: if ($choice==1) {
557: print(<<END);
1.16 harris41 558: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 559: ENTER NEW VALUE (this is an internal value used to identify a group of
560: LON-CAPA machines, it must be alphanumerical, we suggest
561: using a part of your actual DNS domain. For example, for
562: the machine loncapa.msu.edu, we set the Domain to msu):
1.6 harris41 563: END
564: my $choice2=<>;
565: chomp($choice2);
1.8 harris41 566: $perlvar{'lonDefDomain'}=$choice2;
1.6 harris41 567: }
568: elsif ($choice==2) {
569: print(<<END);
1.20 albertel 570: 2) Domain Description: $domainDescription
571: ENTER NEW VALUE (this should be a string that describes your domain, spaces
572: and punctuation are fine except for ':'):
573: END
574: my $choice2=<>;
575: chomp($choice2);
576: $domainDescription=$choice2;
577: }
578: elsif ($choice==3) {
579: print(<<END);
580: 3) Machine Name: $perlvar{'lonHostID'}
581: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
582: it cannot contain any of '_' '-' '.' or ':'. We suggest that
583: if you are in the domain 'example' and are the first library
584: server you enter 'examplel1') :
1.6 harris41 585: END
586: my $choice2=<>;
587: chomp($choice2);
1.8 harris41 588: $perlvar{'lonHostID'}=$choice2;
1.6 harris41 589: }
1.20 albertel 590: elsif ($choice==4) {
1.6 harris41 591: print(<<END);
1.20 albertel 592: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6 harris41 593: ENTER NEW VALUE:
594: END
595: my $choice2=<>;
596: chomp($choice2);
1.9 harris41 597: $perlvar{'lonAdmEMail'}=$choice2;
1.6 harris41 598: }
1.20 albertel 599: elsif ($choice==5) {
1.6 harris41 600: print(<<END);
1.20 albertel 601: 5) Role: $perlvar{'lonRole'}
602: ENTER NEW VALUE (this should be either 'access' or 'library'
603: if in doubt select 'library'):
1.6 harris41 604: END
605: my $choice2=<>;
606: chomp($choice2);
607: $perlvar{'lonRole'}=$choice2;
608: }
1.20 albertel 609: elsif ($choice==6) {
1.6 harris41 610: print(<<END);
1.20 albertel 611: 6) Cache Expiration Time: $perlvar{'lonExpire'}
612: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6 harris41 613: END
614: my $choice2=<>;
615: chomp($choice2);
616: $perlvar{'lonExpire'}=$choice2;
617: }
1.20 albertel 618: elsif ($choice==7) {
1.6 harris41 619: print(<<END);
1.20 albertel 620: 7) Server Load: $perlvar{'lonLoadLim'}
1.6 harris41 621: ENTER NEW VALUE:
622: END
623: my $choice2=<>;
624: chomp($choice2);
625: $perlvar{'lonLoadLim'}=$choice2;
626: }
1.20 albertel 627: elsif ($choice==8) {
1.25 albertel 628: print(<<END);
629: 8) User Load: $perlvar{'lonUserLoadLim'}
630: Numer of users that can login before machine is 'overloaded'
1.26 albertel 631: ENTER NEW VALUE (integer value, 0 means there is no limit):
1.25 albertel 632: END
633: my $choice2=<>;
634: chomp($choice2);
635: $perlvar{'lonUserLoadLim'}=$choice2;
636: }
637: elsif ($choice==9) {
1.31 ! albertel 638: print(<<END);
! 639: 9) Allow only secure connections: $securestatus
! 640: The Lon-CAPA communication daemons lonc and lond can be configured to
! 641: allow only secure connections by default.
! 642:
! 643: POSSIBLE CHOICES:
! 644: 1) allow only secure connections and don't connect to machines that
! 645: can not be connected to securely
! 646: 2) allow only secure connections but allow this machine to connect to
! 647: machines that don't support secure connections
! 648: 3) allow insecure connections to this machine but only allow connections
! 649: to machines that support secure connections
! 650: 4) allow insecure connections
! 651: ENTER NEW VALUE (currenly $securenum):
! 652: END
! 653: my $choice2=<>;
! 654: chomp($choice2);
! 655: if ($choice2 eq '1') {
! 656: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=0;
! 657: } elsif ($choice2 eq '2') {
! 658: $perlvar{'loncAllowInsecure'}=0;$perlvar{'londAllowInsecure'}=1;
! 659: } elsif ($choice2 eq '3') {
! 660: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=0;
! 661: } elsif ($choice2 eq '4') {
! 662: $perlvar{'loncAllowInsecure'}=1;$perlvar{'londAllowInsecure'}=1;
! 663: }
! 664: ($securestatus,$securenum)=&securesetting(%perlvar);
! 665: }
! 666: elsif ($choice==10) {
1.6 harris41 667: $flag=1;
668: }
669: else {
1.1 harris41 670:
1.6 harris41 671: }
672: }
1.7 harris41 673: open(OUT,">$confdir$filename") or
674: die("Cannot output to $confdir$filename\n");
675: foreach my $key (keys %perlvar) {
676: my $value=$perlvar{$key};
1.8 harris41 677: print(OUT <<END) unless $perlvarstatic{$key};
1.7 harris41 678: PerlSetVar $key $value
679: END
680: }
681: close(OUT);
1.1 harris41 682: </perlscript>
683: </file>
684: <file>
685: <target dist='default'>loncom/hosts.tab</target>
686: <perlscript mode='fg'>
687: unless (-l "<TARGET />") {
1.22 albertel 688: my $hostname=`hostname`;chomp($hostname);
689: my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
690: $hostaddress=~s/\s//;
1.15 harris41 691: $date=`date -I`; chomp($date);
692: $lonHostID=$perlvar{'lonHostID'};
693: $lonHostID=~s/\W//g;
694: $lineexistflag=0;
695: $hostidexistflag=0;
1.22 albertel 696: $line2insert=<<END;
1.27 albertel 697: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
1.15 harris41 698: END
1.29 albertel 699: $domaininsert="$perlvar{'lonDefDomain'}:$domainDescription:$domainTabExtras\n";
1.23 albertel 700: if ($lonCluster eq 'standalone') {
701: open(OUT,'>../'.$lonCluster.'_hosts.tab') or
702: die('file generation error');
703: print(OUT $line2insert);
704: close(OUT);
1.27 albertel 705: open(OUT,'>../'.$lonCluster.'_domain.tab') or
706: die('file generation error');
707: print(OUT $domaininsert);
708: close(OUT);
1.23 albertel 709: }
1.15 harris41 710: if ($flag==1) {
1.6 harris41 711: `rm -f ../hosts.tab`;
1.15 harris41 712: open(IN,'<../'.$lonCluster.'_hosts.tab');
1.13 harris41 713: while(<IN>) {
714: if (/^$line2insert$/) {
715: $lineexistflag=1;
716: }
1.15 harris41 717: if (/^$lonHostID\:/) {
1.13 harris41 718: $hostidexistflag=1;
719: }
720: }
721: close(IN);
722: if ($hostidexistflag and !$lineexistflag) {
723: print <<END;
724: WARNING: $lonHostID already exists inside
1.15 harris41 725: loncapa/loncom/${lonCluster}_hosts.tab. The entry inside
726: ${lonCluster}_hosts.tab does not match your settings.
727: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13 harris41 728: with your new values.
729: END
1.15 harris41 730: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
731: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
732: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14 harris41 733: print(OUT $line2insert);
1.13 harris41 734: close(OUT);
1.15 harris41 735: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13 harris41 736: # email appropriate message
1.28 albertel 737: system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
1.19 harris41 738: `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
1.13 harris41 739: }
740: elsif ($hostidexistflag and $lineexistflag) {
1.15 harris41 741: print <<END;
742: Entry exists in ${lonCluster}_hosts.tab.
743: END
744: `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
745: # email appropriate message
746: `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13 harris41 747: }
1.15 harris41 748: elsif (!$hostidexistflag and !$lineexistflag) {
749: print <<END;
750: New entry for $lonCluster.
1.6 harris41 751: END
1.15 harris41 752: `cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1.21 albertel 753: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
754: die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15 harris41 755: print(OUT $line2insert);
756: close(OUT);
757: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
758: # email appropriate message
759: `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.27 albertel 760: }
761: }
762: $lineexistflag=0;
763: if ($flag==1) {
764: `rm -f ../domain.tab`;
765: open(IN,'<../'.$lonCluster.'_domain.tab');
766: while(<IN>) {
767: if (/^$domaininsert$/) {
768: $lineexistflag=1;
769: }
770: if (/^$perlvar{'lonDefDomain'}\:/) {
771: $domainexistflag=1;
772: }
773: }
774: close(IN);
775: if ($domainexistflag and !$lineexistflag) {
776: print <<END;
777: WARNING: $perlvar{'lonDefDomain'} already exists inside
778: loncapa/loncom/${lonCluster}_domain.tab. The entry inside
779: ${lonCluster}_domain.tab does not match your settings.
780: The entry inside ${lonCluster}_domain.tab is being replaced
781: with your new values.
782: END
783: `grep -v "$perlvar{'lonDefDomain'}:" ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
784: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
785: die("cannot open loncom/${lonCluster}_domain.tab for output\n");
786: print(OUT $domaininsert);
787: close(OUT);
788: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
789: # email appropriate message
1.28 albertel 790: system('ping -c 1 -W 5 www.lon-capa.org > /dev/null || ping -c 1 -W 5 www.msu.edu > /dev/null || ping -c 1 -W 5 www.mit.edu > /dev/null');
1.27 albertel 791: `echo "REPLACEdom:$lonCluster:$lonHostID:$date:$domaninsert" | mail -s "REPLACEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
792: }
793: elsif ($domainexistflag and $lineexistflag) {
794: print <<END;
795: Entry exists in ${lonCluster}_domain.tab.
796: END
797: `ln -s ${lonCluster}_domain.tab ../domain.tab`;
798: # email appropriate message
799: `echo "STABLEUPDATEdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "STABLEUPDATEdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
800: }
801: elsif (!$domainexistflag and !$lineexistflag) {
802: print <<END;
803: New entry for $lonCluster.
804: END
805: `cat ../${lonCluster}_domain.tab > ../new_${lonCluster}_domain.tab`;
806: open(OUT,'>>../new_'.$lonCluster.'_domain.tab') or
807: die("cannot open loncom/new_${lonCluster}_domain.tab for output\n");
808: print(OUT $domaininsert);
809: close(OUT);
810: `ln -s new_${lonCluster}_domain.tab ../domain.tab`;
811: # email appropriate message
812: `echo "INSERTdom:$lonCluster:$lonHostID:$date:$domaininsert" | mail -s "INSERTdom:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6 harris41 813: }
814: }
1.1 harris41 815: }
816: </perlscript>
817: </file>
818: </files>
819: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>