Diff for /loncom/lond between versions 1.472 and 1.477

version 1.472, 2011/05/13 02:58:02 version 1.477, 2011/07/31 22:55:48
Line 421  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)) {
        if (&loncapa_dns_server()) {         my $hostname = &Apache::lonnet::hostname($perlvar{'lonHostID'});
          if (&Apache::lonnet::is_LC_dns($hostname)) {
            &logthis('<font color="red">No manager table.  Nobody can manage!!</font>');             &logthis('<font color="red">No manager table.  Nobody can manage!!</font>');
        }         }
        return;         return;
Line 677  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 $adminmail = $perlvar{'lonAdmEMail'};
         my $admindom = &Apache::lonnet::host_domain($perlvar{'lonHostID'});          my $admindom = &Apache::lonnet::host_domain($perlvar{'lonHostID'});
         if ($admindom ne '') {          if ($admindom ne '') {
Line 691  sub PushFile { Line 692  sub PushFile {
         }          }
         if ($adminmail =~ /^[^\@]+\@[^\@]+$/) {          if ($adminmail =~ /^[^\@]+\@[^\@]+$/) {
             my $msg = new Mail::Send;              my $msg = new Mail::Send;
             my $senderaddress =  $perlvar{'lonSysEMail'};  
             $msg->to($adminmail);              $msg->to($adminmail);
             $msg->subject('LON-CAPA DNS update on '.$perlvar{'lonHostID'});              $msg->subject('LON-CAPA DNS update on '.$perlvar{'lonHostID'});
             if ($senderaddress) {  
                  $msg->add('From',$senderaddress);  
             }  
             $msg->add('Content-type','text/plain; charset=UTF-8');              $msg->add('Content-type','text/plain; charset=UTF-8');
             if (my $fh = $msg->open()) {              if (my $fh = $msg->open()) {
                 print $fh 'Update to '.$tablefile.' from Cluster Manager '.                  print $fh 'Update to '.$tablefile.' from Cluster Manager '.
                           $client."\n";                            "$clientname ($clientip)\n";
                 $fh->close;                  $fh->close;
             }              }
         }          }
Line 712  sub PushFile { Line 709  sub PushFile {
   
 }  }
   
 sub loncapa_dns_server {  
     my $lonhost = &Apache::lonnet::get_host_ip($perlvar{'lonHostID'});  
     my $hoststable = "$perlvar{'lonTabDir'}/hosts.tab";  
     my $is_dns_server;  
     if (!open(HOSTS,"<$hoststable")) {  
         &logthis('<font color="yellow">Could not open hosts.tab to check for LON-CAPA DNS servers.</font>');  
         while (my $host = <HOSTS>) {  
             chomp($host);  
             $host =~ s/(^\s+|\s+$)//g;  
             if ($host =~ /^\Q^$lonhost\E/) {  
                 $is_dns_server = 1;  
                 last;  
             }  
         }  
         close(HOSTS);  
     }  
     return $is_dns_server;  
 }  
   
 #  #
 #  Called to re-init either lonc or lond.  #  Called to re-init either lonc or lond.
 #  #
Line 1663  sub ls3_handler { Line 1641  sub ls3_handler {
 }  }
 &register_handler("ls3", \&ls3_handler, 0, 1, 0);  &register_handler("ls3", \&ls3_handler, 0, 1, 0);
   
   sub read_lonnet_global {
       my ($cmd,$tail,$client) = @_;
       my $userinput = "$cmd:$tail";
       my $requested = &Apache::lonnet::thaw_unescape($tail);
       my $result;
       if (ref($requested) eq 'HASH') {
           foreach my $what (keys(%{$requested})) {
               my $type = $requested->{$what};
               my $lonnetglobal = 'Apache::lonnet::'.$what;
               my $response;
               if ($type eq 'HASH') {
                   if (defined(%{$lonnetglobal})) {
                       my $hashref = \%{$lonnetglobal};
                       $response = &Apache::lonnet::freeze_escape($hashref);
                   }
               } else {
                   if (defined(${$lonnetglobal})) {
                       $response = &escape(${$item});
                   }
               }
           }
           $result .= &escape($what).'='.$response.'&';
       }
       $result =~ s/\&$//;
       &Reply($client,\$result,$userinput);
       return 1;
   }
   &register_handler("readlonnetglobal", \&read_lonnet_global, 0, 1, 0);
   
 sub server_timezone_handler {  sub server_timezone_handler {
     my ($cmd,$tail,$client) = @_;      my ($cmd,$tail,$client) = @_;
     my $userinput = "$cmd:$tail";      my $userinput = "$cmd:$tail";
Line 2300  sub fetch_user_file_handler { Line 2307  sub fetch_user_file_handler {
   
  my $destname=$udir.'/'.$ufile;   my $destname=$udir.'/'.$ufile;
  my $transname=$udir.'/'.$ufile.'.in.transit';   my $transname=$udir.'/'.$ufile.'.in.transit';
  my $remoteurl='http://'.$clientip.'/userfiles/'.$fname;          my $clientprotocol=$Apache::lonnet::protocol{$clientname};
           $clientprotocol = 'http' if ($clientprotocol ne 'https');
    my $remoteurl=$clientprotocol.'://'.$clientip.'/userfiles/'.$fname;
  my $response;   my $response;
  Debug("Remote URL : $remoteurl Transfername $transname Destname: $destname");   Debug("Remote URL : $remoteurl Transfername $transname Destname: $destname");
  alarm(120);   alarm(120);
Line 6114  sub HUPSMAN {                      # sig Line 6123  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 {
     my $execdir = $perlvar{'lonDaemons'};  # --------------------------- Handle case of another apachereload process (locking)
     my $script  = $execdir."/apachereload";      if (&LONCAPA::try_to_lock('/tmp/lock_apachereload')) {
     system($script);          my $execdir = $perlvar{'lonDaemons'};
           my $script  = $execdir."/apachereload";
           system($script);
           unlink('/tmp/lock_apachereload'); #  Remove the lock file.
       }
 }  }
   
 #  #
Line 6383  my %iphost = &Apache::lonnet::get_iphost Line 6396  my %iphost = &Apache::lonnet::get_iphost
 my $dist=`$perlvar{'lonDaemons'}/distprobe`;  my $dist=`$perlvar{'lonDaemons'}/distprobe`;
   
 my $arch = `uname -i`;  my $arch = `uname -i`;
   chomp($arch);
 if ($arch eq 'unknown') {  if ($arch eq 'unknown') {
     $arch = `uname -m`;      $arch = `uname -m`;
       chomp($arch);
 }  }
   
 # --------------------------------------------------------------  # --------------------------------------------------------------
Line 7183  sub subscribe { Line 7198  sub subscribe {
                 # the metadata                  # the metadata
  unless ($fname=~/\.meta$/) { &unsub("$fname.meta",$clientip); }   unless ($fname=~/\.meta$/) { &unsub("$fname.meta",$clientip); }
  $fname=~s/\/home\/httpd\/html\/res/raw/;   $fname=~s/\/home\/httpd\/html\/res/raw/;
  $fname="http://".&Apache::lonnet::hostname($perlvar{'lonHostID'})."/".$fname;                  my $protocol = $Apache::lonnet::protocol{$perlvar{'lonHostID'}};
                   $protocol = 'http' if ($protocol ne 'https');
    $fname=$protocol.'://'.&Apache::lonnet::hostname($perlvar{'lonHostID'})."/".$fname;
  $result="$fname\n";   $result="$fname\n";
     }      }
  } else {   } else {

Removed from v.1.472  
changed lines
  Added in v.1.477


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