version 1.13, 2002/06/06 15:36:41
|
version 1.15, 2002/06/09 23:31:09
|
Line 299 END
|
Line 299 END
|
<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 $filename='loncapa.conf'; |
my $filename='loncapa.conf'; |
my %perlvar; |
my %perlvar; |
if (-e "$confdir$filename") { |
if (-e "$confdir$filename") { |
Line 454 while (!$flag) {
|
Line 453 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; |
$line2insert=<<END; |
$perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress |
$perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress |
END |
END |
$date=`date -I`; chomp($date); |
$date=`date -I`; chomp($date); |
$lonHostID=$perlvar{'lonHostID'}; |
$lonHostID=$perlvar{'lonHostID'}; |
$lonHostID=~s/\W//g; |
$lonHostID=~s/\W//g; |
$lineexistflag=0; |
$lineexistflag=0; |
$hostidexistflag=0; |
$hostidexistflag=0; |
if ($choice==1) { |
if ($choice==1) { |
$lonCluster='production'; |
$lonCluster='production'; $flag=1; |
|
} |
|
elsif ($choice==2) { |
|
$lonCluster='standalone'; $flag=1; |
|
open(OUT,'>../'.$lonCluster.'_hosts.tab') or |
|
die('file generation error'); |
|
print(OUT $line2insert); |
|
close(OUT); |
|
} |
|
elsif ($choice==3) { |
|
$lonCluster='development'; $flag=1; |
|
} |
|
elsif ($choice==4) { |
|
$lonCluster='existing'; $flag=1; |
|
if (-e '/home/httpd/lonTabs/hosts.tab') { |
|
`cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`; |
|
} |
|
else { |
|
print <<END; |
|
There is no existing /home/httpd/lonTabs/hosts.tab |
|
END |
|
die(''); |
|
} |
|
} |
|
elsif ($choice==26) { |
|
$lonCluster='rawhide'; $flag=1; |
|
} |
|
if ($flag==1) { |
`rm -f ../hosts.tab`; |
`rm -f ../hosts.tab`; |
open(IN,'<../production_hosts.tab'); |
open(IN,'<../'.$lonCluster.'_hosts.tab'); |
while(<IN>) { |
while(<IN>) { |
if (/^$line2insert$/) { |
if (/^$line2insert$/) { |
$lineexistflag=1; |
$lineexistflag=1; |
} |
} |
if (/^$perlvar{'lonHostID'}\:/) { |
if (/^$lonHostID\:/) { |
$hostidexistflag=1; |
$hostidexistflag=1; |
} |
} |
} |
} |
Line 478 END
|
Line 504 END
|
if ($hostidexistflag and !$lineexistflag) { |
if ($hostidexistflag and !$lineexistflag) { |
print <<END; |
print <<END; |
WARNING: $lonHostID already exists inside |
WARNING: $lonHostID already exists inside |
loncapa/loncom/production_hosts.tab. The entry inside |
loncapa/loncom/${lonCluster}_hosts.tab. The entry inside |
production_hosts.tab does not match your settings. |
${lonCluster}_hosts.tab does not match your settings. |
The entry inside production_hosts.tab is being replaced |
The entry inside ${lonCluster}_hosts.tab is being replaced |
with your new values. |
with your new values. |
END |
END |
`grep -v "$lonHostID:" ../production_hosts.tab > ../new_production_hosts.tab`; |
`grep -v "$lonHostID:" ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`; |
open(OUT,'>>../new_production_hosts.tab') or |
open(OUT,'>>../new_'.$lonCluster.'_hosts.tab') or |
die("cannot open loncom/standalone_hosts.tab for output\n"); |
die("cannot open loncom/${lonCluster}_hosts.tab for output\n"); |
print(OUT <<END); |
print(OUT $line2insert); |
$line2insert |
|
END |
|
close(OUT); |
close(OUT); |
`ln -s new_production_hosts.tab ../hosts.tab`; |
`ln -s new_${lonCluster}_hosts.tab ../hosts.tab`; |
# email appropriate message |
# email appropriate message |
# `echo "$date" | mail -s "REPLACE:$lonHostID:$date" installrecord\@mail.lon-capa.org`; |
`echo "REPLACE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "REPLACE:$lonCluster:$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) { |
elsif ($hostidexistflag and $lineexistflag) { |
`ln -s production_hosts.tab ../hosts.tab`; |
print <<END; |
} |
Entry exists in ${lonCluster}_hosts.tab. |
elsif (!$$hostidexistflag and !$lineexistflag) { |
END |
`cat ../production_hosts.tab > ../new_production_hosts.tab`; |
`ln -s ${lonCluster}_hosts.tab ../hosts.tab`; |
`ln -s new_production_hosts.tab > ../hosts.tab`; |
# email appropriate message |
|
`echo "STABLEUPDATE:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "STABLEUPDATE:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`; |
} |
} |
$flag=1; |
elsif (!$hostidexistflag and !$lineexistflag) { |
} |
print <<END; |
elsif ($choice==2) { |
New entry for $lonCluster. |
$lonCluster='standalone'; |
|
open(OUT,'>../standalone_hosts.tab') or |
|
die("cannot open loncom/standalone_hosts.tab for output\n"); |
|
print(OUT <<END); |
|
$perlvar{'lonHostID'}:$perlvar{'lonDefDomain'}:$perlvar{'lonRole'}:$hostname:$hostaddress |
|
END |
END |
close(OUT); |
`cat ../${lonCluster}_hosts.tab > ../new_${lonCluster}_hosts.tab`; |
`rm -f ../hosts.tab`; |
open(OUT,'>../new_'.$lonCluster.'_hosts.tab') or |
`ln -s standalone_hosts.tab ../hosts.tab`; |
die("cannot open loncom/${lonCluster}_hosts.tab for output\n"); |
$flag=1; |
print(OUT $line2insert); |
} |
close(OUT); |
elsif ($choice==3) { |
`ln -s new_${lonCluster}_hosts.tab ../hosts.tab`; |
$lonCluster='development'; |
# email appropriate message |
`rm -f loncom/hosts.tab`; |
`echo "INSERT:$lonCluster:$lonHostID:$date:$line2insert" | mail -s "INSERT:$lonCluster:$lonHostID:$date" installrecord\@mail.lon-capa.org`; |
`ln -s development_hosts.tab ../hosts.tab`; |
|
$flag=1; |
|
} |
|
elsif ($choice==4) { |
|
$lonCluster='existing'; |
|
`rm -f ../hosts.tab`; |
|
`touch existing_hosts.tab`; |
|
if (-e '/home/httpd/lonTabs/hosts.tab') { |
|
`cp /home/httpd/lonTabs/hosts.tab ../existing_hosts.tab`; |
|
} |
} |
`ln -s existing_hosts.tab ../hosts.tab`; |
|
$flag=1; |
|
} |
|
elsif ($choice==26) { |
|
$lonCluster='rawhide'; |
|
`rm -f ../hosts.tab`; |
|
`ln -s rawhide_hosts.tab ../hosts.tab`; |
|
$flag=1; |
|
} |
|
else { |
|
|
|
} |
} |
} |
} |
|
|