version 1.6, 2002/05/13 02:24:44
|
version 1.13, 2002/06/06 15:36:41
|
Line 52 sleep(3);
|
Line 52 sleep(3);
|
</perlscript> |
</perlscript> |
</file> |
</file> |
<file> |
<file> |
<target dist='default'>/home/httpd/lonUsers2/</target> |
<target dist='default'>/home/httpd/lonTabs/hosts.tab</target> |
<perlscript mode='fg'> |
<perlscript mode='fg'> |
$|=1; |
$|=1; |
unless (-e "<TARGET />") { |
unless (-e "<TARGET />") { |
Line 65 or contact sharrison\@mail.lon-capa.org.
|
Line 65 or contact sharrison\@mail.lon-capa.org.
|
=============================================================================== |
=============================================================================== |
The following 4 values are needed to configure LON-CAPA: |
The following 4 values are needed to configure LON-CAPA: |
* Machine Role |
* Machine Role |
* Machine ID Name |
* LON-CAPA Domain Name |
* LON-CAPA Domain Name, and |
* LON-CAPA Machine ID Name, and |
* System Administration E-mail Address. |
* System Administration E-mail Address. |
END |
END |
|
|
Line 120 my $ipdomain='';
|
Line 120 my $ipdomain='';
|
if ($hostname=~/([^\.]*)\.([^\.]*)$/) { |
if ($hostname=~/([^\.]*)\.([^\.]*)$/) { |
$ipdomain=$1; |
$ipdomain=$1; |
} |
} |
my $lonHostID; |
|
if ($ipdomain) { |
|
$lonHostID=$ipdomain.$r.int(1+rand(9)); # should be probably detect against |
|
# the hosts.tab |
|
} |
|
|
|
print(<<END); |
print(<<END); |
|
|
**** Machine ID Name **** |
**** Domain **** |
[this does NOT need to correspond to internet address names; |
[this does NOT need to correspond to internet address domains, |
this name MUST be unique to the whole LON-CAPA network; |
examples might be "msu" or "bionet" or "vermontcc"] |
we recommend that you use a name based off of your institution; |
|
good examples: "msul1" or "bionetl1"; |
|
bad examples: "loncapabox" or "studentsinside"] |
|
END |
END |
# get machine name |
|
|
# get domain name |
# accept if valid, if not valid, tell user and repeat |
# accept if valid, if not valid, tell user and repeat |
$flag=0; |
$flag=0; |
|
my $lonDefDomain; |
while (!$flag) { |
while (!$flag) { |
if ($ipdomain) { |
if ($ipdomain) { |
print(<<END); |
print(<<END); |
ENTER LONCAPA MACHINE ID [$lonHostID]: |
ENTER LONCAPA DOMAIN [$ipdomain]: |
END |
END |
} |
} |
else { |
else { |
print(<<END); |
print(<<END); |
ENTER LONCAPA MACHINE ID: |
ENTER LONCAPA DOMAIN: |
END |
END |
} |
} |
my $choice=<>; |
my $choice=<>; |
chomp($choice); |
chomp($choice); |
if ($lonHostID and $choice=~/^\s*$/) { |
if ($ipdomain and $choice=~/^\s*$/) { |
$choice=$lonHostID; |
$choice=$ipdomain; |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
print(OUT 'lonHostID'."\t".$choice."\n"); |
print(OUT 'lonDefDomain'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
|
$lonDefDomain=$choice; |
$flag=1; |
$flag=1; |
} |
} |
elsif ($choice!~/\_/ and $choice=~/^\w+$/) { |
elsif ($choice!~/\_/ and $choice=~/^\w+$/) { |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
print(OUT 'lonHostID'."\t".$choice."\n"); |
print(OUT 'lonDefDomain'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
|
$lonDefDomain=$choice; |
|
$r='l'; |
$flag=1; |
$flag=1; |
} |
} |
else { |
else { |
Line 169 END
|
Line 166 END
|
} |
} |
} |
} |
|
|
|
my $lonHostID; |
|
if ($lonDefDomain) { |
|
$lonHostID=$lonDefDomain.$r.int(1+rand(9)); # should be probably also detect |
|
# against the hosts.tab |
|
} |
|
|
print(<<END); |
print(<<END); |
|
|
**** Domain **** |
**** Machine ID Name **** |
[this does NOT need to correspond to internet address domains, |
[this does NOT need to correspond to internet address names; |
examples might be "msu" or "bionet" or "vermontcc"] |
this name MUST be unique to the whole LON-CAPA network; |
|
we recommend that you use a name based off of your institution; |
|
good examples: "msul1" or "bionetl1"; |
|
bad examples: "loncapabox" or "studentsinside"] |
END |
END |
|
# get machine name |
# get domain name |
|
# accept if valid, if not valid, tell user and repeat |
# accept if valid, if not valid, tell user and repeat |
$flag=0; |
$flag=0; |
my $lonDefDomain; |
|
while (!$flag) { |
while (!$flag) { |
if ($ipdomain) { |
if ($ipdomain) { |
print(<<END); |
print(<<END); |
ENTER LONCAPA DOMAIN [$ipdomain]: |
ENTER LONCAPA MACHINE ID [$lonHostID]: |
END |
END |
} |
} |
else { |
else { |
print(<<END); |
print(<<END); |
ENTER LONCAPA DOMAIN: |
ENTER LONCAPA MACHINE ID: |
END |
END |
} |
} |
my $choice=<>; |
my $choice=<>; |
chomp($choice); |
chomp($choice); |
if ($ipdomain and $choice=~/^\s*$/) { |
if ($lonHostID and $choice=~/^\s*$/) { |
$choice=$ipdomain; |
$choice=$lonHostID; |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
print(OUT 'lonDefDomain'."\t".$choice."\n"); |
print(OUT 'lonHostID'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
$lonDefDomain=$choice; |
$lonHostID=$choice; |
$flag=1; |
$flag=1; |
} |
} |
elsif ($choice!~/\_/ and $choice=~/^\w+$/) { |
elsif ($choice!~/\_/ and $choice=~/^\w+$/) { |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
print(OUT 'lonDefDomain'."\t".$choice."\n"); |
print(OUT 'lonHostID'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
$lonDefDomain=$choice; |
$lonHostID=$choice; |
$r='l'; |
|
$flag=1; |
$flag=1; |
} |
} |
else { |
else { |
Line 217 END
|
Line 220 END
|
# get e-mail address |
# get e-mail address |
# accept if valid, if not valid, tell user and repeat |
# accept if valid, if not valid, tell user and repeat |
$flag=0; |
$flag=0; |
my $lonAdmEmail; |
my $lonAdmEMail; |
while (!$flag) { |
while (!$flag) { |
print(<<END); |
print(<<END); |
|
|
Line 231 END
|
Line 234 END
|
chomp($choice); |
chomp($choice); |
if ($choice=~/\@/) { |
if ($choice=~/\@/) { |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
open(OUT,'>>/tmp/loncapa_updatequery.out'); |
print(OUT 'lonAdmEmail'."\t".$choice."\n"); |
print(OUT 'lonAdmEMail'."\t".$choice."\n"); |
close(OUT); |
close(OUT); |
$lonAdmEmail=$choice; |
$lonAdmEMail=$choice; |
$flag=1; |
$flag=1; |
} |
} |
else { |
else { |
Line 242 END
|
Line 245 END
|
} |
} |
|
|
# update loncapa.conf |
# update loncapa.conf |
#my $confdir='/etc/httpd/conf/'; |
my $confdir='/etc/httpd/conf/'; |
my $confdir=''; |
#my $confdir=''; |
my $filename='loncapa.conf'; |
my $filename='loncapa.conf'; |
my %perlvar; |
my %perlvar; |
if (-e "$confdir$filename") { |
if (-e "$confdir$filename") { |
Line 252 my %perlvar;
|
Line 255 my %perlvar;
|
if ($configline =~ /^[^\#]*PerlSetVar/) { |
if ($configline =~ /^[^\#]*PerlSetVar/) { |
my ($unused,$varname,$varvalue)=split(/\s+/,$configline); |
my ($unused,$varname,$varvalue)=split(/\s+/,$configline); |
chomp($varvalue); |
chomp($varvalue); |
$perlvar{$varname}=$varvalue; |
$perlvar{$varname}=$varvalue if $varvalue!~/^\{\[\[\[\[/; |
} |
} |
} |
} |
close(CONFIG); |
close(CONFIG); |
} |
} |
$perlvar{'lonHostID'}=$lonHostID; |
$perlvar{'lonHostID'}=$lonHostID; |
$perlvar{'lonDefDomain'}=$lonDefDomain; |
$perlvar{'lonDefDomain'}=$lonDefDomain; |
$perlvar{'lonAdmEmail'}=$lonAdmEmail; |
$perlvar{'lonAdmEMail'}=$lonAdmEMail; |
$perlvar{'lonRole'}=$lonRole; |
$perlvar{'lonRole'}=$lonRole; |
unless ($perlvar{'lonSqlAccess'}) { |
unless ($perlvar{'lonSqlAccess'}) { |
$perlvar{'lonSqlAccess'}='localhostkey'; |
$perlvar{'lonSqlAccess'}='localhostkey'; |
Line 272 my %perlvar;
|
Line 275 my %perlvar;
|
} |
} |
unless ($perlvar{'lonReceipt'}) { |
unless ($perlvar{'lonReceipt'}) { |
my $lonReceipt=''; |
my $lonReceipt=''; |
srand($$.time); |
srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`); |
my @alnum=(0..9,a..z); |
my @alnum=(0..9,a..z); |
foreach my $i (1..20) { |
foreach my $i (1..20) { |
$lonReceipt.=$alnum[int(rand(36))]; |
$lonReceipt.=$alnum[int(rand(36))]; |
Line 295 END
|
Line 298 END
|
<target dist='default'>/</target> |
<target dist='default'>/</target> |
<perlscript mode='fg'> |
<perlscript mode='fg'> |
# read values from loncapa.conf |
# read values from loncapa.conf |
#my $confdir='/etc/httpd/conf/'; |
my $confdir='/etc/httpd/conf/'; |
my $confdir=''; |
#my $confdir=''; |
my $filename='loncapa.conf'; |
my $filename='loncapa.conf'; |
my %perlvar; |
my %perlvar; |
if (-e "$confdir$filename") { |
if (-e "$confdir$filename") { |
Line 311 my %perlvar;
|
Line 314 my %perlvar;
|
} |
} |
close(CONFIG); |
close(CONFIG); |
} |
} |
|
my %perlvarstatic; |
|
if (-e "${confdir}loncapa_apache.conf") { |
|
open(CONFIG,'<'.$confdir.'loncapa_apache.conf') or |
|
die("Can't read ${confdir}loncapa_apache.conf"); |
|
while (my $configline=<CONFIG>) { |
|
if ($configline =~ /^[^\#]*PerlSetVar/) { |
|
my ($unused,$varname,$varvalue)=split(/\s+/,$configline); |
|
chomp($varvalue); |
|
$perlvarstatic{$varname}=$varvalue; |
|
} |
|
} |
|
close(CONFIG); |
|
} |
# implement editing logic below, interactively |
# implement editing logic below, interactively |
# update loncapa.conf until 7 is entered |
# update loncapa.conf until 7 is entered |
|
|
Line 320 while (!$flag) {
|
Line 336 while (!$flag) {
|
|
|
=============================================================================== |
=============================================================================== |
This is now the current configuration of your machine. |
This is now the current configuration of your machine. |
1) Machine Name: $perlvar{'lonHostID'} |
1) Domain Name: $perlvar{'lonDefDomain'} |
2) Domain Name: $perlvar{'lonDefDomain'} |
2) Machine Name: $perlvar{'lonHostID'} |
3) System Administrator's E-mail Address: $perlvar{'lonAdmEmail'} |
3) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'} |
4) Role: $perlvar{'lonRole'} |
4) Role: $perlvar{'lonRole'} |
5) Cache Expiration Time: $perlvar{'lonExpire'} |
5) Cache Expiration Time: $perlvar{'lonExpire'} |
6) Server Load: $perlvar{'lonLoadLim'} |
6) Server Load: $perlvar{'lonLoadLim'} |
Line 335 my $choice=<>;
|
Line 351 my $choice=<>;
|
chomp($choice); |
chomp($choice); |
if ($choice==1) { |
if ($choice==1) { |
print(<<END); |
print(<<END); |
1) Machine Name: $perlvar{'lonHostID'} |
2) Domain Name: $perlvar{'lonDefDomain'} |
ENTER NEW VALUE: |
ENTER NEW VALUE: |
END |
END |
my $choice2=<>; |
my $choice2=<>; |
chomp($choice2); |
chomp($choice2); |
$perlvar{'lonHostID'}=$choice2; |
$perlvar{'lonDefDomain'}=$choice2; |
} |
} |
elsif ($choice==2) { |
elsif ($choice==2) { |
print(<<END); |
print(<<END); |
2) Domain Name: $perlvar{'lonDefDomain'} |
1) Machine Name: $perlvar{'lonHostID'} |
ENTER NEW VALUE: |
ENTER NEW VALUE: |
END |
END |
my $choice2=<>; |
my $choice2=<>; |
chomp($choice2); |
chomp($choice2); |
$perlvar{'lonDefDomain'}=$choice2; |
$perlvar{'lonHostID'}=$choice2; |
} |
} |
elsif ($choice==3) { |
elsif ($choice==3) { |
print(<<END); |
print(<<END); |
3) System Administrator's E-mail Address: $perlvar{'lonAdmEmail'} |
3) System Administrator's E-mail Address: $perlvar{'lonAdmEMail'} |
ENTER NEW VALUE: |
ENTER NEW VALUE: |
END |
END |
my $choice2=<>; |
my $choice2=<>; |
chomp($choice2); |
chomp($choice2); |
$perlvar{'lonAdmEmail'}=$choice2; |
$perlvar{'lonAdmEMail'}=$choice2; |
} |
} |
elsif ($choice==4) { |
elsif ($choice==4) { |
print(<<END); |
print(<<END); |
Line 394 END
|
Line 410 END
|
|
|
} |
} |
} |
} |
|
open(OUT,">$confdir$filename") or |
|
die("Cannot output to $confdir$filename\n"); |
|
foreach my $key (keys %perlvar) { |
|
my $value=$perlvar{$key}; |
|
print(OUT <<END) unless $perlvarstatic{$key}; |
|
PerlSetVar $key $value |
|
END |
|
} |
|
close(OUT); |
</perlscript> |
</perlscript> |
</file> |
</file> |
<file> |
<file> |
Line 429 while (!$flag) {
|
Line 454 while (!$flag) {
|
print "ENTER 1, 2, 3, or 4:\n"; |
print "ENTER 1, 2, 3, or 4:\n"; |
my $choice=<>; |
my $choice=<>; |
chomp($choice); |
chomp($choice); |
|
$line2insert=<<END; |
|
$perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress |
|
END |
|
$date=`date -I`; chomp($date); |
|
$lonHostID=$perlvar{'lonHostID'}; |
|
$lonHostID=~s/\W//g; |
|
$lineexistflag=0; |
|
$hostidexistflag=0; |
if ($choice==1) { |
if ($choice==1) { |
$lonCluster='production'; |
$lonCluster='production'; |
`rm -f ../hosts.tab`; |
`rm -f ../hosts.tab`; |
`ln -s production_hosts.tab ../hosts.tab`; |
open(IN,'<../production_hosts.tab'); |
|
while(<IN>) { |
|
if (/^$line2insert$/) { |
|
$lineexistflag=1; |
|
} |
|
if (/^$perlvar{'lonHostID'}\:/) { |
|
$hostidexistflag=1; |
|
} |
|
} |
|
close(IN); |
|
if ($hostidexistflag and !$lineexistflag) { |
|
print <<END; |
|
WARNING: $lonHostID already exists inside |
|
loncapa/loncom/production_hosts.tab. The entry inside |
|
production_hosts.tab does not match your settings. |
|
The entry inside production_hosts.tab is being replaced |
|
with your new values. |
|
END |
|
`grep -v "$lonHostID:" ../production_hosts.tab > ../new_production_hosts.tab`; |
|
open(OUT,'>>../new_production_hosts.tab') or |
|
die("cannot open loncom/standalone_hosts.tab for output\n"); |
|
print(OUT <<END); |
|
$line2insert |
|
END |
|
close(OUT); |
|
`ln -s new_production_hosts.tab ../hosts.tab`; |
|
# email appropriate message |
|
# `echo "$date" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`; |
|
`echo "REPLACE:$lonHostID:date:$line2insert" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`; |
|
# "REPLACE:hostid:date" |
|
# "REPLACE:hostid:date:line" |
|
} |
|
elsif ($hostidexistflag and $lineexistflag) { |
|
`ln -s production_hosts.tab ../hosts.tab`; |
|
} |
|
elsif (!$$hostidexistflag and !$lineexistflag) { |
|
`cat ../production_hosts.tab > ../new_production_hosts.tab`; |
|
`ln -s new_production_hosts.tab > ../hosts.tab`; |
|
} |
$flag=1; |
$flag=1; |
} |
} |
elsif ($choice==2) { |
elsif ($choice==2) { |