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