version 1.471, 2011/05/13 02:32:40
|
version 1.473, 2011/05/14 15:47:01
|
Line 53 use LONCAPA::lonlocal;
|
Line 53 use LONCAPA::lonlocal;
|
use LONCAPA::lonssl; |
use LONCAPA::lonssl; |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Mail::Send; |
|
|
my $DEBUG = 0; # Non zero to enable debug log entries. |
my $DEBUG = 0; # Non zero to enable debug log entries. |
|
|
Line 420 sub ReadManagerTable {
|
Line 421 sub ReadManagerTable {
|
|
|
my $tablename = $perlvar{'lonTabDir'}."/managers.tab"; |
my $tablename = $perlvar{'lonTabDir'}."/managers.tab"; |
if (!open (MANAGERS, $tablename)) { |
if (!open (MANAGERS, $tablename)) { |
logthis('<font color="red">No manager table. Nobody can manage!!</font>'); |
my $hostname = &Apache::lonnet::hostname($perlvar{'lonHostID'}); |
return; |
if (&Apache::lonnet::is_LC_dns($hostname)) { |
|
&logthis('<font color="red">No manager table. Nobody can manage!!</font>'); |
|
} |
|
return; |
} |
} |
while(my $host = <MANAGERS>) { |
while(my $host = <MANAGERS>) { |
chomp($host); |
chomp($host); |
Line 446 sub ReadManagerTable {
|
Line 450 sub ReadManagerTable {
|
} |
} |
} else { |
} else { |
logthis('<font color="green"> existing host'." $host</font>\n"); |
logthis('<font color="green"> existing host'." $host</font>\n"); |
$managers{&Apache::lonnet::get_host_ip($host)} = $host; # Use info from cluster tab if clumemeber |
$managers{&Apache::lonnet::get_host_ip($host)} = $host; # Use info from cluster tab if cluster memeber |
} |
} |
} |
} |
} |
} |
Line 508 sub AdjustHostContents {
|
Line 512 sub AdjustHostContents {
|
my $me = $perlvar{'lonHostID'}; |
my $me = $perlvar{'lonHostID'}; |
|
|
foreach my $line (split(/\n/,$contents)) { |
foreach my $line (split(/\n/,$contents)) { |
if(!(($line eq "") || ($line =~ /^ *\#/) || ($line =~ /^ *$/))) { |
if(!(($line eq "") || ($line =~ /^ *\#/) || ($line =~ /^ *$/) || |
|
($line =~ /^\s*\^/))) { |
chomp($line); |
chomp($line); |
my ($id,$domain,$role,$name,$ip,$maxcon,$idleto,$mincon)=split(/:/,$line); |
my ($id,$domain,$role,$name,$ip,$maxcon,$idleto,$mincon)=split(/:/,$line); |
if ($id eq $me) { |
if ($id eq $me) { |
Line 596 sub InstallFile {
|
Line 601 sub InstallFile {
|
# |
# |
# ConfigFileFromSelector: converts a configuration file selector |
# ConfigFileFromSelector: converts a configuration file selector |
# into a configuration file pathname. |
# into a configuration file pathname. |
# It's probably no longer necessary to preserve |
# Supports the following file selectors: |
# special handling of hosts or domain as those |
# hosts, domain, dns_hosts, dns_domain |
# files have been superceded by dns_hosts, dns_domain. |
|
# The default action is just to prepend the directory |
|
# and append .tab |
|
# |
# |
# |
# |
# Parameters: |
# Parameters: |
Line 613 sub ConfigFileFromSelector {
|
Line 615 sub ConfigFileFromSelector {
|
my $tablefile; |
my $tablefile; |
|
|
my $tabledir = $perlvar{'lonTabDir'}.'/'; |
my $tabledir = $perlvar{'lonTabDir'}.'/'; |
if ($selector eq "hosts") { |
if (($selector eq "hosts") || ($selector eq "domain") || |
$tablefile = $tabledir."hosts.tab"; |
($selector eq "dns_hosts") || ($selector eq "dns_domain")) { |
} elsif ($selector eq "domain") { |
|
$tablefile = $tabledir."domain.tab"; |
|
} else { |
|
$tablefile = $tabledir.$selector.'.tab'; |
$tablefile = $tabledir.$selector.'.tab'; |
} |
} |
return $tablefile; |
return $tablefile; |
|
|
} |
} |
# |
# |
# PushFile: Called to do an administrative push of a file. |
# PushFile: Called to do an administrative push of a file. |
Line 647 sub PushFile {
|
Line 645 sub PushFile {
|
# supported: |
# supported: |
# hosts.tab ($filename eq host). |
# hosts.tab ($filename eq host). |
# domain.tab ($filename eq domain). |
# domain.tab ($filename eq domain). |
|
# dns_hosts.tab ($filename eq dns_host). |
|
# dns_domain.tab ($filename eq dns_domain). |
# Construct the destination filename or reject the request. |
# Construct the destination filename or reject the request. |
# |
# |
# lonManage is supposed to ensure this, however this session could be |
# lonManage is supposed to ensure this, however this session could be |
Line 678 sub PushFile {
|
Line 678 sub PushFile {
|
return "error:$!"; |
return "error:$!"; |
} else { |
} else { |
&logthis('<font color="green"> Installed new '.$tablefile |
&logthis('<font color="green"> Installed new '.$tablefile |
."</font>"); |
." - transaction by: $clientname ($clientip)</font>"); |
|
my $adminmail = $perlvar{'lonAdmEMail'}; |
|
my $admindom = &Apache::lonnet::host_domain($perlvar{'lonHostID'}); |
|
if ($admindom ne '') { |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['contacts'],$admindom); |
|
if (ref($domconfig{'contacts'}) eq 'HASH') { |
|
if ($domconfig{'contacts'}{'adminemail'} ne '') { |
|
$adminmail = $domconfig{'contacts'}{'adminemail'}; |
|
} |
|
} |
|
} |
|
if ($adminmail =~ /^[^\@]+\@[^\@]+$/) { |
|
my $msg = new Mail::Send; |
|
$msg->to($adminmail); |
|
$msg->subject('LON-CAPA DNS update on '.$perlvar{'lonHostID'}); |
|
$msg->add('Content-type','text/plain; charset=UTF-8'); |
|
if (my $fh = $msg->open()) { |
|
print $fh 'Update to '.$tablefile.' from Cluster Manager '. |
|
"$clientname ($clientip)\n"; |
|
$fh->close; |
|
} |
|
} |
} |
} |
|
|
|
|
# Indicate success: |
# Indicate success: |
|
|
return "ok"; |
return "ok"; |
Line 6072 sub HUPSMAN { # sig
|
Line 6092 sub HUPSMAN { # sig
|
# a setuid perl script that can be root for us to do this job. |
# a setuid perl script that can be root for us to do this job. |
# |
# |
sub ReloadApache { |
sub ReloadApache { |
|
# --------------------------- Handle case of another apachereload process (locking) |
my $execdir = $perlvar{'lonDaemons'}; |
my $execdir = $perlvar{'lonDaemons'}; |
my $script = $execdir."/apachereload"; |
my $script = $execdir."/apachereload"; |
system($script); |
system($script); |