Annotation of doc/loncapafiles/updatequery.piml, revision 1.22
1.2 harris41 1: <!-- updatequery.piml -->
1.1 harris41 2: <!-- Scott Harrison -->
3:
1.22 ! albertel 4: <!-- $Id: updatequery.piml,v 1.21 2002/12/09 18:54:40 albertel Exp $ -->
1.1 harris41 5:
6: <!--
7:
8: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9:
10: LON-CAPA is free software; you can redistribute it and/or modify
11: it under the terms of the GNU General Public License as published by
12: the Free Software Foundation; either version 2 of the License, or
13: (at your option) any later version.
14:
15: LON-CAPA is distributed in the hope that it will be useful,
16: but WITHOUT ANY WARRANTY; without even the implied warranty of
17: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: GNU General Public License for more details.
19:
20: You should have received a copy of the GNU General Public License
21: along with LON-CAPA; if not, write to the Free Software
22: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23:
24: /home/httpd/html/adm/gpl.txt
25:
26: http://www.lon-capa.org/
27:
28: -->
29:
30: <piml>
31: <targetroot>/</targetroot>
32: <files>
33: <file>
1.4 harris41 34: <target dist='default'>/</target>
1.1 harris41 35: <perlscript mode='fg'>
1.4 harris41 36: $|=1;
1.1 harris41 37: print(<<END);
38:
39:
40: *********************************************
41: *********************************************
42: **** ****
43: **** LON-CAPA SYSTEM INFORMATION REQUEST ****
44: **** ****
45: **** Please respond to the choices below ****
46: **** ****
47: *********************************************
48: *********************************************
49:
50: END
1.4 harris41 51: sleep(3);
1.1 harris41 52: </perlscript>
53: </file>
54: <file>
1.22 ! albertel 55: <target dist='default'>loncom/hosts.tab</target>
! 56: <perlscript mode='fg'>
! 57: unless (-l "<TARGET />") {
! 58: print(<<END);
! 59:
! 60: ===============================================================================
! 61: What hosts.tab would you like to have installed?
! 62: (hosts.tab is a listing of all other internet machines
! 63: that a server system considers to be valid server systems
! 64: on the LON-CAPA network)
! 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 (/home/httpd/lonTabs/hosts.tab)
! 72:
! 73: END
! 74: # Option number 26 will install rawhide_hosts.tab, but
! 75: # the typical user does not want to be part of an intensive
! 76: # machine test cluster.
! 77:
! 78: # get input
! 79: # if valid then process, otherwise loop
! 80: $flag=0;
! 81: while (!$flag) {
! 82: print "ENTER 1, 2, 3, or 4:\n";
! 83: my $choice=<>;
! 84: chomp($choice);
! 85: if ($choice==1) {
! 86: $lonCluster='production'; $flag=1;
! 87: }
! 88: elsif ($choice==2) {
! 89: die("FIXME Broken!!!");
! 90: $lonCluster='standalone'; $flag=1;
! 91: open(OUT,'>../'.$lonCluster.'_hosts.tab') or
! 92: die('file generation error');
! 93: print(OUT $line2insert);
! 94: close(OUT);
! 95: }
! 96: elsif ($choice==3) {
! 97: $lonCluster='development'; $flag=1;
! 98: }
! 99: elsif ($choice==4) {
! 100: $lonCluster='existing'; $flag=1;
! 101: if (-e '/home/httpd/lonTabs/hosts.tab') {
! 102: `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
! 103: }
! 104: else {
! 105: print <<END;
! 106: There is no existing /home/httpd/lonTabs/hosts.tab
! 107: END
! 108: die('');
! 109: }
! 110: }
! 111: elsif ($choice==26) {
! 112: $lonCluster='rawhide'; $flag=1;
! 113: }
! 114: }
! 115: }
! 116: </perlscript>
! 117: </file>
! 118: <file>
1.10 harris41 119: <target dist='default'>/home/httpd/lonTabs/hosts.tab</target>
1.1 harris41 120: <perlscript mode='fg'>
1.4 harris41 121: $|=1;
1.20 albertel 122: my $domainDescription;
1.1 harris41 123: unless (-e "<TARGET />") {
124: print(<<END);
125: WELCOME TO LON-CAPA!
126:
127: If you have questions, please visit http://install.lon-capa.org
1.5 harris41 128: or contact sharrison\@mail.lon-capa.org.
1.1 harris41 129:
130: ===============================================================================
1.4 harris41 131: The following 4 values are needed to configure LON-CAPA:
132: * Machine Role
1.8 harris41 133: * LON-CAPA Domain Name
134: * LON-CAPA Machine ID Name, and
1.1 harris41 135: * System Administration E-mail Address.
136: END
1.3 harris41 137:
1.4 harris41 138: open(OUT,'>/tmp/loncapa_updatequery.out');
139: close(OUT);
140:
1.3 harris41 141: # query for Machine Role
142: print(<<END);
143: **** Machine Role ****
144: Library server (recommended if first-time installation of LON-CAPA):
145: Servers that are repositories of authoritative educational resources.
146: These servers also provide the construction space by which instructors
147: assemble their classroom online material.
148: Access server:
149: Servers that load-balance high-traffic delivery of educational resources
150: over the world-wide web.
1.4 harris41 151: 1) Will this be a library server? (recommended if this is your first install)
1.3 harris41 152: 2) Or, will this be an access server?
153: END
1.4 harris41 154: my $flag=0;
155: my $r='';
156: my $lonRole;
157: while (!$flag) {
158: print "ENTER A CHOICE OF 1 or 2:\n";
159: my $choice=<>;
160: chomp($choice);
161: if ($choice==1) {
162: open(OUT,'>>/tmp/loncapa_updatequery.out');
163: print(OUT 'lonRole'."\t".'library'."\n");
164: close(OUT);
165: $lonRole='library';
166: $r='l';
167: $flag=1;
168: }
169: elsif ($choice==2) {
170: open(OUT,'>>/tmp/loncapa_updatequery.out');
171: print(OUT 'lonRole'."\t".'access'."\n");
172: close(OUT);
173: $lonRole='access';
174: $r='a';
175: $flag=2;
176: }
177: else {
178:
179: }
180: }
1.3 harris41 181:
182: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.4 harris41 183: my $hostname=`hostname`; chomp($hostname);
184: my $ipdomain='';
185: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
186: $ipdomain=$1;
187: }
1.1 harris41 188:
189: print(<<END);
190:
1.8 harris41 191: **** Domain ****
192: [this does NOT need to correspond to internet address domains,
193: examples might be "msu" or "bionet" or "vermontcc"]
1.1 harris41 194: END
1.8 harris41 195:
196: # get domain name
1.1 harris41 197: # accept if valid, if not valid, tell user and repeat
1.4 harris41 198: $flag=0;
1.8 harris41 199: my $lonDefDomain;
1.4 harris41 200: while (!$flag) {
201: if ($ipdomain) {
202: print(<<END);
1.8 harris41 203: ENTER LONCAPA DOMAIN [$ipdomain]:
1.4 harris41 204: END
205: }
206: else {
207: print(<<END);
1.8 harris41 208: ENTER LONCAPA DOMAIN:
1.4 harris41 209: END
210: }
211: my $choice=<>;
212: chomp($choice);
1.18 harris41 213: my $bad_domain_flag=0;
214: my @bad_domain_names=('raw','userfiles','priv','adm','uploaded');
215: foreach my $bad (@bad_domain_names) {
216: $bad_domain_flag=1 if $choice eq $bad;
217: }
1.8 harris41 218: if ($ipdomain and $choice=~/^\s*$/) {
219: $choice=$ipdomain;
1.4 harris41 220: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 221: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 222: close(OUT);
1.8 harris41 223: $lonDefDomain=$choice;
1.4 harris41 224: $flag=1;
225: }
226: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
227: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 228: print(OUT 'lonDefDomain'."\t".$choice."\n");
1.4 harris41 229: close(OUT);
1.8 harris41 230: $lonDefDomain=$choice;
231: $r='l';
1.4 harris41 232: $flag=1;
1.18 harris41 233: }
234: elsif ($bad_domain_flag) {
235: print "Invalid input ('$choice' conflicts with LON-CAPA namespace).\n";
236: print "Please try something different than '$choice'\n";
1.4 harris41 237: }
238: else {
239: print "Invalid input (only alphanumeric characters supported).\n";
240: }
241: }
1.1 harris41 242:
1.20 albertel 243:
244: # get domain description
245: # accept if valid, if not valid, tell user and repeat
246: $flag=0;
247:
248: while (!$flag) {
249: print(<<END);
250:
251: **** Domain Description ****
252: String describing the domain, to be shown to users.
253: [Example, msu is Michigan State University]
254: ENTER DOMAIN DESCRIPTION:
255: END
256:
257: my $choice=<>;
258: chomp($choice);
259: if ($choice!~/:/) {
260: open(OUT,'>>/tmp/loncapa_updatequery.out');
261: print(OUT 'domainDescription'."\t".$choice."\n");
262: close(OUT);
263: $domainDescription=$choice;
264: $flag=1;
265: }
266: else {
267: print "Invalid input (no ':' allowed).\n";
268: }
269: }
270:
1.8 harris41 271: my $lonHostID;
272: if ($lonDefDomain) {
273: $lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect
274: # against the hosts.tab
275: }
276:
1.1 harris41 277: print(<<END);
278:
1.8 harris41 279: **** Machine ID Name ****
280: [this does NOT need to correspond to internet address names;
281: this name MUST be unique to the whole LON-CAPA network;
282: we recommend that you use a name based off of your institution;
283: good examples: "msul1" or "bionetl1";
284: bad examples: "loncapabox" or "studentsinside"]
1.1 harris41 285: END
1.8 harris41 286: # get machine name
1.1 harris41 287: # accept if valid, if not valid, tell user and repeat
1.4 harris41 288: $flag=0;
289: while (!$flag) {
290: if ($ipdomain) {
291: print(<<END);
1.8 harris41 292: ENTER LONCAPA MACHINE ID [$lonHostID]:
1.4 harris41 293: END
294: }
295: else {
296: print(<<END);
1.8 harris41 297: ENTER LONCAPA MACHINE ID:
1.4 harris41 298: END
299: }
300: my $choice=<>;
301: chomp($choice);
1.8 harris41 302: if ($lonHostID and $choice=~/^\s*$/) {
303: $choice=$lonHostID;
1.4 harris41 304: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 305: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 306: close(OUT);
1.8 harris41 307: $lonHostID=$choice;
1.4 harris41 308: $flag=1;
309: }
310: elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
311: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.8 harris41 312: print(OUT 'lonHostID'."\t".$choice."\n");
1.4 harris41 313: close(OUT);
1.8 harris41 314: $lonHostID=$choice;
1.4 harris41 315: $flag=1;
316: }
317: else {
318: print "Invalid input (only alphanumeric characters supported).\n";
319: }
320: }
1.1 harris41 321:
1.4 harris41 322: # get e-mail address
323: # accept if valid, if not valid, tell user and repeat
324: $flag=0;
1.9 harris41 325: my $lonAdmEMail;
1.4 harris41 326: while (!$flag) {
1.1 harris41 327: print(<<END);
328:
329: **** System Administrator's E-mail ****
330: E-mail address of the person who will manage this machine
1.4 harris41 331: [should be in the form somebody\@somewhere]
1.1 harris41 332: ENTER E-MAIL ADDRESS:
333: END
334:
1.4 harris41 335: my $choice=<>;
336: chomp($choice);
337: if ($choice=~/\@/) {
338: open(OUT,'>>/tmp/loncapa_updatequery.out');
1.9 harris41 339: print(OUT 'lonAdmEMail'."\t".$choice."\n");
1.4 harris41 340: close(OUT);
1.9 harris41 341: $lonAdmEMail=$choice;
1.4 harris41 342: $flag=1;
343: }
344: else {
345: print "Invalid input (this needs to look like an e-mail address!).\n";
346: }
347: }
348:
1.1 harris41 349: # update loncapa.conf
1.7 harris41 350: my $confdir='/etc/httpd/conf/';
351: #my $confdir='';
1.5 harris41 352: my $filename='loncapa.conf';
353: my %perlvar;
354: if (-e "$confdir$filename") {
355: open(CONFIG,'<'.$confdir.$filename) or die("Can't read $confdir$filename");
356: while (my $configline=<CONFIG>) {
357: if ($configline =~ /^[^\#]*PerlSetVar/) {
358: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
359: chomp($varvalue);
1.12 harris41 360: $perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/;
1.5 harris41 361: }
362: }
363: close(CONFIG);
364: }
365: $perlvar{'lonHostID'}=$lonHostID;
366: $perlvar{'lonDefDomain'}=$lonDefDomain;
1.9 harris41 367: $perlvar{'lonAdmEMail'}=$lonAdmEMail;
1.5 harris41 368: $perlvar{'lonRole'}=$lonRole;
1.16 harris41 369: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
1.5 harris41 370: $perlvar{'lonLoadLim'}='2.00';
371: }
1.16 harris41 372: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
1.5 harris41 373: $perlvar{'lonExpire'}='86400';
374: }
1.16 harris41 375: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
1.5 harris41 376: my $lonReceipt='';
1.11 harris41 377: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
1.5 harris41 378: my @alnum=(0..9,a..z);
379: foreach my $i (1..20) {
380: $lonReceipt.=$alnum[int(rand(36))];
381: }
382: $perlvar{'lonReceipt'}=$lonReceipt;
383: }
384: open(OUT,">$confdir$filename") or
385: die("Cannot output to $confdir$filename\n");
386: foreach my $key (keys %perlvar) {
387: my $value=$perlvar{$key};
388: print(OUT <<END);
389: PerlSetVar $key $value
390: END
391: }
392: close(OUT);
1.1 harris41 393: }
394: </perlscript>
395: </file>
396: <file>
1.5 harris41 397: <target dist='default'>/</target>
1.1 harris41 398: <perlscript mode='fg'>
399: # read values from loncapa.conf
1.7 harris41 400: my $confdir='/etc/httpd/conf/';
1.5 harris41 401: my $filename='loncapa.conf';
402: my %perlvar;
403: if (-e "$confdir$filename") {
404: open(CONFIG,'<'.$confdir.$filename) or
405: die("Can't read $confdir$filename");
406: while (my $configline=<CONFIG>) {
407: if ($configline =~ /^[^\#]*PerlSetVar/) {
408: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
409: chomp($varvalue);
410: $perlvar{$varname}=$varvalue;
411: }
412: }
413: close(CONFIG);
414: }
1.16 harris41 415: unless ($perlvar{'lonLoadLim'} and $perlvar{'lonLoadLim'}!~/\{\[\[\[\[/) {
416: $perlvar{'lonLoadLim'}='2.00';
417: }
418: unless ($perlvar{'lonExpire'} and $perlvar{'lonExpire'}!~/\{\[\[\[\[/) {
419: $perlvar{'lonExpire'}='86400';
420: }
421: unless ($perlvar{'lonReceipt'} and $perlvar{'lonReceipt'}!~/\{\[\[\[\[/) {
422: my $lonReceipt='';
423: srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
424: my @alnum=(0..9,a..z);
425: foreach my $i (1..20) {
426: $lonReceipt.=$alnum[int(rand(36))];
427: }
428: $perlvar{'lonReceipt'}=$lonReceipt;
429: }
1.7 harris41 430: my %perlvarstatic;
431: if (-e "${confdir}loncapa_apache.conf") {
432: open(CONFIG,'<'.$confdir.'loncapa_apache.conf') or
433: die("Can't read ${confdir}loncapa_apache.conf");
434: while (my $configline=<CONFIG>) {
435: if ($configline =~ /^[^\#]*PerlSetVar/) {
436: my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
437: chomp($varvalue);
438: $perlvarstatic{$varname}=$varvalue;
439: }
440: }
441: close(CONFIG);
442: }
1.22 ! albertel 443: unless ($domainDescription) {
! 444: open(IN,'<../'.$lonCluster.'_hosts.tab');
! 445: while(<IN>) {
! 446: if (/^$perlvar{'lonHostID'}\:/) {
! 447: (undef,undef,undef,undef,undef,$domainDescription)=split(/:/,$_);
! 448: chomp($domainDescription);
! 449: last;
! 450: }
! 451: }
! 452: close(IN);
! 453: }
1.6 harris41 454: # implement editing logic below, interactively
1.22 ! albertel 455: # update loncapa.conf until 8 is entered
1.6 harris41 456:
457: $flag=0;
1.17 harris41 458:
1.6 harris41 459: while (!$flag) {
1.1 harris41 460: print(<<END);
461:
462: ===============================================================================
463: This is now the current configuration of your machine.
1.8 harris41 464: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 465: 2) Domain Description: $domainDescription
466: 3) Machine Name: $perlvar{'lonHostID'}
467: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
468: 5) Role: $perlvar{'lonRole'}
469: 6) Cache Expiration Time: $perlvar{'lonExpire'}
470: 7) Server Load: $perlvar{'lonLoadLim'}
471: 8) Everything is correct up above
1.6 harris41 472: END
1.17 harris41 473: my $hbug=-1;
474: my $dbug=-1;
475: {
476: my $v=$perlvar{'lonHostID'};
477: $hbug=0;
478: $hbug=1 if $v=~/\W/;
479: $hbug=1 if $v=~/\_/;
480: }
481: {
482: my $v=$1;
483: $dbug=0;
484: $dbug=1 if $v=~/\W/;
485: $dbug=1 if $v=~/\_/;
486: }
487:
488: if ($hbug) {
489: print "**** ERROR **** ".
490: "Invalid lonHostID (should only be letters and/or digits)\n";
491: }
492: if ($dbug) {
493: print "**** ERROR **** ".
494: "Invalid lonDefDomain (should only be letters and/or digits)\n";
495: }
496:
1.6 harris41 497: print(<<END);
1.20 albertel 498: ENTER A CHOICE OF 1-7 TO CHANGE, otherwise ENTER 8:
1.1 harris41 499: END
1.5 harris41 500: my $choice=<>;
501: chomp($choice);
1.6 harris41 502: if ($choice==1) {
503: print(<<END);
1.16 harris41 504: 1) Domain Name: $perlvar{'lonDefDomain'}
1.20 albertel 505: ENTER NEW VALUE (this is an internal value used to identify a group of
506: LON-CAPA machines, it must be alphanumerical, we suggest
507: using a part of your actual DNS domain. For example, for
508: the machine loncapa.msu.edu, we set the Domain to msu):
1.6 harris41 509: END
510: my $choice2=<>;
511: chomp($choice2);
1.8 harris41 512: $perlvar{'lonDefDomain'}=$choice2;
1.6 harris41 513: }
514: elsif ($choice==2) {
515: print(<<END);
1.20 albertel 516: 2) Domain Description: $domainDescription
517: ENTER NEW VALUE (this should be a string that describes your domain, spaces
518: and punctuation are fine except for ':'):
519: END
520: my $choice2=<>;
521: chomp($choice2);
522: $domainDescription=$choice2;
523: }
524: elsif ($choice==3) {
525: print(<<END);
526: 3) Machine Name: $perlvar{'lonHostID'}
527: ENTER NEW VALUE (this will be the name of the machine in the LON-CAPA network
528: it cannot contain any of '_' '-' '.' or ':'. We suggest that
529: if you are in the domain 'example' and are the first library
530: server you enter 'examplel1') :
1.6 harris41 531: END
532: my $choice2=<>;
533: chomp($choice2);
1.8 harris41 534: $perlvar{'lonHostID'}=$choice2;
1.6 harris41 535: }
1.20 albertel 536: elsif ($choice==4) {
1.6 harris41 537: print(<<END);
1.20 albertel 538: 4) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'}
1.6 harris41 539: ENTER NEW VALUE:
540: END
541: my $choice2=<>;
542: chomp($choice2);
1.9 harris41 543: $perlvar{'lonAdmEMail'}=$choice2;
1.6 harris41 544: }
1.20 albertel 545: elsif ($choice==5) {
1.6 harris41 546: print(<<END);
1.20 albertel 547: 5) Role: $perlvar{'lonRole'}
548: ENTER NEW VALUE (this should be either 'access' or 'library'
549: if in doubt select 'library'):
1.6 harris41 550: END
551: my $choice2=<>;
552: chomp($choice2);
553: $perlvar{'lonRole'}=$choice2;
554: }
1.20 albertel 555: elsif ($choice==6) {
1.6 harris41 556: print(<<END);
1.20 albertel 557: 6) Cache Expiration Time: $perlvar{'lonExpire'}
558: ENTER NEW VALUE (in seconds, 86400 is a reasonable value):
1.6 harris41 559: END
560: my $choice2=<>;
561: chomp($choice2);
562: $perlvar{'lonExpire'}=$choice2;
563: }
1.20 albertel 564: elsif ($choice==7) {
1.6 harris41 565: print(<<END);
1.20 albertel 566: 7) Server Load: $perlvar{'lonLoadLim'}
1.6 harris41 567: ENTER NEW VALUE:
568: END
569: my $choice2=<>;
570: chomp($choice2);
571: $perlvar{'lonLoadLim'}=$choice2;
572: }
1.20 albertel 573: elsif ($choice==8) {
1.6 harris41 574: $flag=1;
575: }
576: else {
1.1 harris41 577:
1.6 harris41 578: }
579: }
1.7 harris41 580: open(OUT,">$confdir$filename") or
581: die("Cannot output to $confdir$filename\n");
582: foreach my $key (keys %perlvar) {
583: my $value=$perlvar{$key};
1.8 harris41 584: print(OUT <<END) unless $perlvarstatic{$key};
1.7 harris41 585: PerlSetVar $key $value
586: END
587: }
588: close(OUT);
1.1 harris41 589: </perlscript>
590: </file>
591: <file>
592: <target dist='default'>loncom/hosts.tab</target>
593: <perlscript mode='fg'>
594: unless (-l "<TARGET />") {
1.22 ! albertel 595: my $hostname=`hostname`;chomp($hostname);
! 596: my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
! 597: $hostaddress=~s/\s//;
1.15 harris41 598: $date=`date -I`; chomp($date);
599: $lonHostID=$perlvar{'lonHostID'};
600: $lonHostID=~s/\W//g;
601: $lineexistflag=0;
602: $hostidexistflag=0;
1.22 ! albertel 603: $line2insert=<<END;
! 604: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress:$domainDescription
1.15 harris41 605: END
606: if ($flag==1) {
1.6 harris41 607: `rm -f ../hosts.tab`;
1.15 harris41 608: open(IN,'<../'.$lonCluster.'_hosts.tab');
1.13 harris41 609: while(<IN>) {
610: if (/^$line2insert$/) {
611: $lineexistflag=1;
612: }
1.15 harris41 613: if (/^$lonHostID\:/) {
1.13 harris41 614: $hostidexistflag=1;
615: }
616: }
617: close(IN);
618: if ($hostidexistflag and !$lineexistflag) {
619: print <<END;
620: WARNING: $lonHostID already exists inside
1.15 harris41 621: loncapa/loncom/${lonCluster}_hosts.tab. The entry inside
622: ${lonCluster}_hosts.tab does not match your settings.
623: The entry inside ${lonCluster}_hosts.tab is being replaced
1.13 harris41 624: with your new values.
625: END
1.15 harris41 626: `grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
627: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
628: die("cannot open loncom/${lonCluster}_hosts.tab for output\n");
1.14 harris41 629: print(OUT $line2insert);
1.13 harris41 630: close(OUT);
1.15 harris41 631: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
1.13 harris41 632: # email appropriate message
1.19 harris41 633: system('ping -c 1 www.lon-capa.org > /dev/null || ping -c 1 www.msu.edu > /dev/null || ping -c 1 www.mit.edu > /dev/null');
634: `echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org` unless $?;
1.13 harris41 635: }
636: elsif ($hostidexistflag and $lineexistflag) {
1.15 harris41 637: print <<END;
638: Entry exists in ${lonCluster}_hosts.tab.
639: END
640: `ln -s ${lonCluster}_hosts.tab ../hosts.tab`;
641: # email appropriate message
642: `echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.13 harris41 643: }
1.15 harris41 644: elsif (!$hostidexistflag and !$lineexistflag) {
645: print <<END;
646: New entry for $lonCluster.
1.6 harris41 647: END
1.15 harris41 648: `cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`;
1.21 albertel 649: open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or
650: die("cannot open loncom/new_${lonCluster}_hosts.tab for output\n");
1.15 harris41 651: print(OUT $line2insert);
652: close(OUT);
653: `ln -s new_${lonCluster}_hosts.tab ../hosts.tab`;
654: # email appropriate message
655: `echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`;
1.6 harris41 656: }
657: }
1.1 harris41 658: }
659: </perlscript>
660: </file>
661: </files>
662: </piml>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>