version 1.2, 2009/03/16 09:43:00
|
version 1.3, 2009/05/13 19:58:32
|
Line 260 sub update_file {
|
Line 260 sub update_file {
|
} |
} |
} |
} |
&define_command("update", \&update_file); |
&define_command("update", \&update_file); |
|
|
|
# |
|
# Checks if current lonHostID is in managers.tab for the cluster, and is in the cluster. |
|
# Parameters: |
|
# args - none |
|
# Returns: |
|
# 1 - lonHostID is is managers.tab |
|
# '' - Failure (printing messages to STDERR). |
|
# |
|
sub is_manager { |
|
my $currhost = $config{'lonHostID'}; |
|
my $canmanage; |
|
if ($currhost eq '') { |
|
print STDERR "Could not determine LON-CAPA host ID\n"; |
|
return; |
|
} elsif (!defined &Apache::lonnet::get_host_ip($currhost)) { |
|
print STDERR "This LON-CAPA host is not part of the cluster.\n"; |
|
} |
|
my $tablename = &construct_table_path('managers.tab'); |
|
if (!open (MANAGERS, $tablename)) { |
|
print STDERR "No managers.tab table. Could not verify host is a manager\n"; |
|
return; |
|
} |
|
while(my $host = <MANAGERS>) { |
|
chomp($host); |
|
next if ($host =~ /^\#/); |
|
if ($host eq $currhost) { |
|
$canmanage = 1; |
|
last; |
|
} |
|
} |
|
close(MANAGERS); |
|
return $canmanage; |
|
} |
#--------------------------------------------------------------------------------- |
#--------------------------------------------------------------------------------- |
# |
# |
# Program entry point. Decode the subcommand from the args array and |
# Program entry point. Decode the subcommand from the args array and |
Line 273 if ($argc == 0) {
|
Line 307 if ($argc == 0) {
|
exit(-1); |
exit(-1); |
} |
} |
|
|
|
if (!&is_manager()) { |
|
print STDERR 'Script needs to be run from a server designated as a "Manager" in the LON-CAPA cluster'."\n"; |
|
exit(-1); |
|
} |
|
|
my $subcommand = shift(@ARGV); # argv now the tail. |
my $subcommand = shift(@ARGV); # argv now the tail. |
|
|
if (!&dispatch_command($subcommand, \@ARGV)) { |
if (!&dispatch_command($subcommand, \@ARGV)) { |