Annotation of doc/loncapafiles/updatequery.piml, revision 1.7

1.2       harris41    1: <!-- updatequery.piml -->
1.1       harris41    2: <!-- Scott Harrison -->
                      3: 
1.7     ! harris41    4: <!-- $Id: updatequery.piml,v 1.6 2002/05/13 02:24:44 harris41 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(&lt;&lt;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.7     ! harris41   55: <target dist='default'>/home/httpd/lonUsers/</target>
1.1       harris41   56: <perlscript mode='fg'>
1.4       harris41   57: $|=1;
1.1       harris41   58: unless (-e "<TARGET />") {
                     59:   print(&lt;&lt;END);
                     60:            WELCOME TO LON-CAPA!
                     61: 
                     62: If you have questions, please visit http://install.lon-capa.org
1.5       harris41   63: or contact sharrison\@mail.lon-capa.org.
1.1       harris41   64: 
                     65: ===============================================================================
1.4       harris41   66: The following 4 values are needed to configure LON-CAPA:
                     67: * Machine Role
1.1       harris41   68: * Machine ID Name
                     69: * LON-CAPA Domain Name, and
                     70: * System Administration E-mail Address.
                     71: END
1.3       harris41   72: 
1.4       harris41   73: open(OUT,'&gt;/tmp/loncapa_updatequery.out');
                     74: close(OUT);
                     75: 
1.3       harris41   76: # query for Machine Role
                     77:   print(&lt;&lt;END);
                     78: **** Machine Role ****
                     79: Library server (recommended if first-time installation of LON-CAPA):
                     80:    Servers that are repositories of authoritative educational resources.
                     81:    These servers also provide the construction space by which instructors
                     82:    assemble their classroom online material.
                     83: Access server:
                     84:    Servers that load-balance high-traffic delivery of educational resources
                     85:    over the world-wide web.
1.4       harris41   86: 1) Will this be a library server? (recommended if this is your first install)
1.3       harris41   87: 2) Or, will this be an access server?
                     88: END
1.4       harris41   89: my $flag=0;
                     90: my $r='';
                     91: my $lonRole;
                     92: while (!$flag) {
                     93:   print "ENTER A CHOICE OF 1 or 2:\n";
                     94:   my $choice=&lt;&gt;;
                     95:   chomp($choice);
                     96:   if ($choice==1) {
                     97:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                     98:     print(OUT 'lonRole'."\t".'library'."\n");
                     99:     close(OUT);
                    100:     $lonRole='library';
                    101:     $r='l';
                    102:     $flag=1;
                    103:   }
                    104:   elsif ($choice==2) {
                    105:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    106:     print(OUT 'lonRole'."\t".'access'."\n");
                    107:     close(OUT);
                    108:     $lonRole='access';
                    109:     $r='a';
                    110:     $flag=2;
                    111:   }
                    112:   else {
                    113: 
                    114:   }
                    115: }
1.3       harris41  116: 
                    117: # need to recommend a machine ID name (ipdomain.l.somenumber)
1.4       harris41  118: my $hostname=`hostname`; chomp($hostname);
                    119: my $ipdomain='';
                    120: if ($hostname=~/([^\.]*)\.([^\.]*)$/) {
                    121:   $ipdomain=$1;
                    122: }
                    123: my $lonHostID;
                    124: if ($ipdomain) {
                    125:   $lonHostID=$ipdomain.$r.int(1+rand(9)); # should be probably detect against
                    126:                                           # the hosts.tab
                    127: }
1.1       harris41  128: 
                    129:   print(&lt;&lt;END);
                    130: 
                    131: **** Machine ID Name ****
                    132: [this does NOT need to correspond to internet address names;
                    133:  this name MUST be unique to the whole LON-CAPA network;
                    134:  we recommend that you use a name based off of your institution;
                    135:  good examples: "msul1" or "bionetl1";
                    136:  bad examples: "loncapabox" or "studentsinside"]
                    137: END
                    138: # get machine name
                    139: # accept if valid, if not valid, tell user and repeat
1.4       harris41  140: $flag=0;
                    141: while (!$flag) {
                    142: if ($ipdomain) {
                    143: print(&lt;&lt;END);
                    144: ENTER LONCAPA MACHINE ID [$lonHostID]:
                    145: END
                    146: }
                    147: else {
                    148:   print(&lt;&lt;END);
                    149: ENTER LONCAPA MACHINE ID:
                    150: END
                    151: }
                    152:   my $choice=&lt;&gt;;
                    153:   chomp($choice);
1.5       harris41  154:   if ($lonHostID and $choice=~/^\s*$/) {
                    155:     $choice=$lonHostID;
1.4       harris41  156:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    157:     print(OUT 'lonHostID'."\t".$choice."\n");
                    158:     close(OUT);
                    159:     $flag=1;
                    160:   }
                    161:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    162:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    163:     print(OUT 'lonHostID'."\t".$choice."\n");
                    164:     close(OUT);
                    165:     $flag=1;
                    166:   }
                    167:   else {
                    168:     print "Invalid input (only alphanumeric characters supported).\n";
                    169:   }
                    170: }
1.1       harris41  171: 
                    172:   print(&lt;&lt;END);
                    173: 
                    174: **** Domain ****
                    175: [this does NOT need to correspond to internet address domains,
                    176:  examples might be "msu" or "bionet" or "vermontcc"]
                    177: END
                    178: 
                    179: # get domain name
                    180: # accept if valid, if not valid, tell user and repeat
1.4       harris41  181: $flag=0;
1.5       harris41  182: my $lonDefDomain;
1.4       harris41  183: while (!$flag) {
                    184: if ($ipdomain) {
                    185: print(&lt;&lt;END);
                    186: ENTER LONCAPA DOMAIN [$ipdomain]:
                    187: END
                    188: }
                    189: else {
                    190:   print(&lt;&lt;END);
                    191: ENTER LONCAPA DOMAIN:
                    192: END
                    193: }
                    194:   my $choice=&lt;&gt;;
                    195:   chomp($choice);
                    196:   if ($ipdomain and $choice=~/^\s*$/) {
                    197:     $choice=$ipdomain;
                    198:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    199:     print(OUT 'lonDefDomain'."\t".$choice."\n");
                    200:     close(OUT);
1.5       harris41  201:     $lonDefDomain=$choice;
1.4       harris41  202:     $flag=1;
                    203:   }
                    204:   elsif ($choice!~/\_/ and $choice=~/^\w+$/) {
                    205:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    206:     print(OUT 'lonDefDomain'."\t".$choice."\n");
                    207:     close(OUT);
1.5       harris41  208:     $lonDefDomain=$choice;
1.4       harris41  209:     $r='l';
                    210:     $flag=1;
                    211:   }
                    212:   else {
                    213:     print "Invalid input (only alphanumeric characters supported).\n";
                    214:   }
                    215: }
1.1       harris41  216: 
1.4       harris41  217: # get e-mail address
                    218: # accept if valid, if not valid, tell user and repeat
                    219: $flag=0;
                    220: my $lonAdmEmail;
                    221: while (!$flag) {
1.1       harris41  222:   print(&lt;&lt;END);
                    223: 
                    224: **** System Administrator's E-mail ****
                    225: E-mail address of the person who will manage this machine
1.4       harris41  226: [should be in the form somebody\@somewhere]
1.1       harris41  227: ENTER E-MAIL ADDRESS:
                    228: END
                    229: 
1.4       harris41  230:   my $choice=&lt;&gt;;
                    231:   chomp($choice);
                    232:   if ($choice=~/\@/) {
                    233:     open(OUT,'&gt;&gt;/tmp/loncapa_updatequery.out');
                    234:     print(OUT 'lonAdmEmail'."\t".$choice."\n");
                    235:     close(OUT);
1.5       harris41  236:     $lonAdmEmail=$choice;
1.4       harris41  237:     $flag=1;
                    238:   }
                    239:   else {
                    240:     print "Invalid input (this needs to look like an e-mail address!).\n";
                    241:   }
                    242: }
                    243: 
1.1       harris41  244: # update loncapa.conf
1.7     ! harris41  245: my $confdir='/etc/httpd/conf/';
        !           246: #my $confdir='';
1.5       harris41  247: my $filename='loncapa.conf';
                    248: my %perlvar;
                    249:     if (-e "$confdir$filename") {
                    250: 	open(CONFIG,'&lt;'.$confdir.$filename) or die("Can't read $confdir$filename");
                    251: 	while (my $configline=&lt;CONFIG&gt;) {
                    252: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    253: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    254: 		chomp($varvalue);
                    255: 		$perlvar{$varname}=$varvalue;
                    256: 	    }
                    257: 	}
                    258: 	close(CONFIG);
                    259:     }
                    260:     $perlvar{'lonHostID'}=$lonHostID;
                    261:     $perlvar{'lonDefDomain'}=$lonDefDomain;
                    262:     $perlvar{'lonAdmEmail'}=$lonAdmEmail;
                    263:     $perlvar{'lonRole'}=$lonRole;
                    264:     unless ($perlvar{'lonSqlAccess'}) {
                    265:        $perlvar{'lonSqlAccess'}='localhostkey';
                    266:     }
                    267:     unless ($perlvar{'lonLoadLim'}) {
                    268:        $perlvar{'lonLoadLim'}='2.00';
                    269:     }
                    270:     unless ($perlvar{'lonExpire'}) {
                    271:        $perlvar{'lonExpire'}='86400';
                    272:     }
                    273:     unless ($perlvar{'lonReceipt'}) {
                    274:        my $lonReceipt='';
                    275:        srand($$.time);
                    276:        my @alnum=(0..9,a..z);
                    277:        foreach my $i (1..20) {
                    278: 	 $lonReceipt.=$alnum[int(rand(36))];
                    279:        }
                    280:        $perlvar{'lonReceipt'}=$lonReceipt;
                    281:     }
                    282:     open(OUT,"&gt;$confdir$filename") or
                    283:       die("Cannot output to $confdir$filename\n");
                    284:     foreach my $key (keys %perlvar) {
                    285:       my $value=$perlvar{$key};
                    286:       print(OUT &lt;&lt;END);
                    287: PerlSetVar     $key      $value
                    288: END
                    289:     }
                    290:     close(OUT);
1.1       harris41  291: }
                    292: </perlscript>
                    293: </file>
                    294: <file>
1.5       harris41  295: <target dist='default'>/</target>
1.1       harris41  296: <perlscript mode='fg'>
                    297: # read values from loncapa.conf
1.7     ! harris41  298: my $confdir='/etc/httpd/conf/';
        !           299: #my $confdir='';
1.5       harris41  300: my $filename='loncapa.conf';
                    301: my %perlvar;
                    302:     if (-e "$confdir$filename") {
                    303: 	open(CONFIG,'&lt;'.$confdir.$filename) or 
                    304:           die("Can't read $confdir$filename");
                    305: 	while (my $configline=&lt;CONFIG&gt;) {
                    306: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
                    307: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
                    308: 		chomp($varvalue);
                    309: 		$perlvar{$varname}=$varvalue;
                    310: 	    }
                    311: 	}
                    312: 	close(CONFIG);
                    313:     }
1.7     ! harris41  314: my %perlvarstatic;
        !           315:     if (-e "${confdir}loncapa_apache.conf") {
        !           316: 	open(CONFIG,'&lt;'.$confdir.'loncapa_apache.conf') or 
        !           317:           die("Can't read ${confdir}loncapa_apache.conf");
        !           318: 	while (my $configline=&lt;CONFIG&gt;) {
        !           319: 	    if ($configline =~ /^[^\#]*PerlSetVar/) {
        !           320: 		my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
        !           321: 		chomp($varvalue);
        !           322: 		$perlvarstatic{$varname}=$varvalue;
        !           323: 	    }
        !           324: 	}
        !           325: 	close(CONFIG);
        !           326:     }
1.6       harris41  327: # implement editing logic below, interactively
                    328: # update loncapa.conf until 7 is entered
                    329: 
                    330: $flag=0;
                    331: while (!$flag) {
1.1       harris41  332:   print(&lt;&lt;END);
                    333: 
                    334: ===============================================================================
                    335: This is now the current configuration of your machine.
1.5       harris41  336: 1) Machine Name: $perlvar{'lonHostID'}
                    337: 2) Domain Name: $perlvar{'lonDefDomain'}
                    338: 3) System Administrator's E-mail Address: $perlvar{'lonAdmEmail'}
                    339: 4) Role: $perlvar{'lonRole'}
                    340: 5) Cache Expiration Time: $perlvar{'lonExpire'}
                    341: 6) Server Load: $perlvar{'lonLoadLim'}
1.1       harris41  342: 7) Everything is correct up above
1.6       harris41  343: END
                    344:   print(&lt;&lt;END);
1.1       harris41  345: ENTER A CHOICE OF 1-6 TO CHANGE, otherwise ENTER 7:
                    346: END
1.5       harris41  347: my $choice=&lt;&gt;;
                    348: chomp($choice);
1.6       harris41  349:   if ($choice==1) {
                    350:   print(&lt;&lt;END);
                    351: 1) Machine Name: $perlvar{'lonHostID'}
                    352: ENTER NEW VALUE:
                    353: END
                    354:     my $choice2=&lt;&gt;;
                    355:     chomp($choice2);
                    356:     $perlvar{'lonHostID'}=$choice2;
                    357:   }
                    358:   elsif ($choice==2) {
                    359:   print(&lt;&lt;END);
                    360: 2) Domain Name: $perlvar{'lonDefDomain'}
                    361: ENTER NEW VALUE:
                    362: END
                    363:     my $choice2=&lt;&gt;;
                    364:     chomp($choice2);
                    365:     $perlvar{'lonDefDomain'}=$choice2;
                    366:   }
                    367:   elsif ($choice==3) {
                    368:   print(&lt;&lt;END);
                    369: 3) System Administrator's E-mail Address: $perlvar{'lonAdmEmail'}
                    370: ENTER NEW VALUE:
                    371: END
                    372:     my $choice2=&lt;&gt;;
                    373:     chomp($choice2);
                    374:     $perlvar{'lonAdmEmail'}=$choice2;
                    375:   }
                    376:   elsif ($choice==4) {
                    377:   print(&lt;&lt;END);
                    378: 4) Role: $perlvar{'lonRole'}
                    379: ENTER NEW VALUE:
                    380: END
                    381:     my $choice2=&lt;&gt;;
                    382:     chomp($choice2);
                    383:     $perlvar{'lonRole'}=$choice2;
                    384:   }
                    385:   elsif ($choice==5) {
                    386:   print(&lt;&lt;END);
                    387: 5) Cache Expiration Time: $perlvar{'lonExpire'}
                    388: ENTER NEW VALUE:
                    389: END
                    390:     my $choice2=&lt;&gt;;
                    391:     chomp($choice2);
                    392:     $perlvar{'lonExpire'}=$choice2;
                    393:   }
                    394:   elsif ($choice==6) {
                    395:   print(&lt;&lt;END);
                    396: 6) Server Load: $perlvar{'lonLoadLim'}
                    397: ENTER NEW VALUE:
                    398: END
                    399:     my $choice2=&lt;&gt;;
                    400:     chomp($choice2);
                    401:     $perlvar{'lonLoadLim'}=$choice2;
                    402:   }
                    403:   elsif ($choice==7) {
                    404:     $flag=1;
                    405:   }
                    406:   else {
1.1       harris41  407: 
1.6       harris41  408:   }
                    409: }
1.7     ! harris41  410:     open(OUT,"&gt;$confdir$filename") or
        !           411:       die("Cannot output to $confdir$filename\n");
        !           412:     foreach my $key (keys %perlvar) {
        !           413:       my $value=$perlvar{$key};
        !           414:       print(OUT &lt;&lt;END) unless $perlvarstat{$key};
        !           415: PerlSetVar     $key      $value
        !           416: END
        !           417:     }
        !           418:     close(OUT);
1.1       harris41  419: </perlscript>
                    420: </file>
                    421: <file>
                    422: <target dist='default'>loncom/hosts.tab</target>
                    423: <perlscript mode='fg'>
                    424: unless (-l "<TARGET />") {
                    425:   print(&lt;&lt;END);
                    426: 
                    427: ===============================================================================
                    428: What hosts.tab would you like to have installed?
                    429: (hosts.tab is a listing of all other internet machines
                    430: that a server system considers to be valid server systems
                    431: on the LON-CAPA network)
                    432: 
                    433: 1) PRODUCTION - you want to deliver courses today or sometime very soon
                    434:                 on this machine
1.5       harris41  435: 2) STAND-ALONE - you want this machine to run in 'stand-alone' mode and
                    436:                  not be connected to other LON-CAPA machines for now
                    437: 3) DEVELOPMENT - you want to play with or explore LON-CAPA
1.6       harris41  438: 4) PRESERVE the existing hosts.tab (/home/httpd/lonTabs/hosts.tab)
1.1       harris41  439: 
                    440: END
                    441: # Option number 26 will install rawhide_hosts.tab, but
                    442: # the typical user does not want to be part of an intensive
                    443: # machine test cluster.
                    444: 
                    445: # get input
                    446: # if valid then process, otherwise loop
1.6       harris41  447: my $hostname=`hostname`;chomp($hostname);
                    448: my $hostaddress=`hostname -i $hostname`;chomp($hostaddress);
                    449: $flag=0;
                    450: while (!$flag) {
                    451:   print "ENTER 1, 2, 3, or 4:\n";
                    452:   my $choice=&lt;&gt;;
                    453:   chomp($choice);
                    454:   if ($choice==1) {
                    455:     $lonCluster='production';
                    456:     `rm -f ../hosts.tab`;
                    457:     `ln -s production_hosts.tab ../hosts.tab`;
                    458:     $flag=1;
                    459:   }
                    460:   elsif ($choice==2) {
                    461:     $lonCluster='standalone';
                    462:     open(OUT,'&gt;../standalone_hosts.tab') or
                    463:       die("cannot open loncom/standalone_hosts.tab for output\n");
                    464:     print(OUT &lt;&lt;END);
                    465: $perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress
                    466: END
                    467:     close(OUT);
                    468:     `rm -f ../hosts.tab`;
                    469:     `ln -s standalone_hosts.tab ../hosts.tab`;
                    470:     $flag=1;
                    471:   }
                    472:   elsif ($choice==3) {
                    473:     $lonCluster='development';
                    474:     `rm -f loncom/hosts.tab`;
                    475:     `ln -s development_hosts.tab ../hosts.tab`;
                    476:     $flag=1;
                    477:   }
                    478:   elsif ($choice==4) {
                    479:     $lonCluster='existing';
                    480:     `rm -f ../hosts.tab`;
                    481:     `touch existing_hosts.tab`;
                    482:     if (-e '/home/httpd/lonTabs/hosts.tab') {
                    483:       `cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`;
                    484:     }
                    485:     `ln -s existing_hosts.tab ../hosts.tab`;
                    486:     $flag=1;
                    487:   }
                    488:   elsif ($choice==26) {
                    489:     $lonCluster='rawhide';
                    490:     `rm -f ../hosts.tab`;
                    491:     `ln -s rawhide_hosts.tab ../hosts.tab`;
                    492:     $flag=1;
                    493:   }
                    494:   else {
                    495: 
                    496:   }
                    497: }
1.1       harris41  498: 
                    499: }
                    500: </perlscript>
                    501: </file>
                    502: </files>
                    503: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>