Diff for /loncom/clusteradmin between versions 1.7 and 1.8

version 1.7, 2018/08/20 22:31:49 version 1.8, 2018/08/20 22:42:05
Line 156  sub usage { Line 156  sub usage {
     print STDERR "   subcommand describes what to actually do:\n";      print STDERR "   subcommand describes what to actually do:\n";
     print STDERR "    help    - Prints this message (args ignored)\n";      print STDERR "    help    - Prints this message (args ignored)\n";
     print STDERR "    update  - Updates an administrative file\n";      print STDERR "    update  - Updates an administrative file\n";
     print STDERR "              args is one of dns_hosts.tab or dns_domain.tab\n";      print STDERR "              args is one of dns_hosts.tab, dns_domain.tab\n";
       print STDERR "              or loncapaCAcrl.pem\n";
   
 }  }
   
Line 185  my $logfile = $config{'lonDaemons'}.'/lo Line 186  my $logfile = $config{'lonDaemons'}.'/lo
   
 sub construct_table_path {  sub construct_table_path {
     my ($basename) = @_;      my ($basename) = @_;
     my $directory = $config{'lonTabDir'};      my $directory;
       if ($basename eq 'managers.tab') {
           $directory = $config{'lonTabDir'};
       } elsif ($basename eq 'loncapaCAcrl.pem') {
           $directory = $config{'lonCertificateDirectory'};
       } elsif ($basename =~ /^(dns_|)(hosts|domain)\.tab$/) {
           $directory = $config{'lonTabDir'};
       }
     return $directory . '/' . $basename;      return $directory . '/' . $basename;
 }  }
   
Line 200  sub get_dns_hosts() Line 207  sub get_dns_hosts()
 {  {
     my @result;      my @result;
     my $hosts_tab = &construct_table_path('hosts.tab');      my $hosts_tab = &construct_table_path('hosts.tab');
     open(HOSTS, "<$hosts_tab");      if (open(HOSTS,'<',$hosts_tab)) {
     while (my $line = <HOSTS>) {          while (my $line = <HOSTS>) {
  chomp($line);      chomp($line);
  if ($line =~ /^\^/) {      if ($line =~ /^\^/) {
             if ($line =~ /^\^([\w.\-]+)/) {                  if ($line =~ /^\^([\w.\-]+)/) {
                 push(@result,$1);                      push(@result,$1);
             }                  }
  }      }
           }
     }      }
     return (@result);      return (@result);
 }  }
Line 233  sub push_file { Line 241  sub push_file {
   
     my $contents;      my $contents;
     my $line;      my $line;
     open(FILE, "<$pushfile");      open(FILE,'<',$pushfile);
     while ($line = <FILE>) {      while ($line = <FILE>) {
  $contents .= $line;   $contents .= $line;
     }      }
Line 284  sub update_file { Line 292  sub update_file {
  # Validate the filename:   # Validate the filename:
   
  if (($filename eq 'dns_hosts.tab') || ($filename eq 'dns_domain.tab') ||    if (($filename eq 'dns_hosts.tab') || ($filename eq 'dns_domain.tab') || 
             ($filename eq 'hosts.tab') || ($filename eq 'domain.tab')) {              ($filename eq 'hosts.tab') || ($filename eq 'domain.tab') ||
               ($filename eq 'loncapaCAcrl.pem')) {
             my ($result,$fh);              my ($result,$fh);
             if (!-e $logfile) {              if (!-e $logfile) {
                 system("touch $logfile");                  system("touch $logfile");
                 system("chown www:www $logfile");                  system("chown www:www $logfile");
             }              }
             if (open ($fh,">>$logfile")) {              if (open ($fh,'>>',$logfile)) {
                 print $fh "clusteradmin update started: ".localtime(time)."\n";                  print $fh "clusteradmin update started: ".localtime(time)."\n";
         my $pushfile   = &construct_table_path($filename);          my $pushfile   = &construct_table_path($filename);
         my $specifier  = basename($filename, ('.tab'));                  my @hosts         = (&get_dns_hosts());
                   my $ext = 'tab';
                   if ($filename eq 'loncapaCAcrl.pem') {
                       $ext = 'pem';
                   }
           my $specifier  = basename($filename, (".$ext"));
         my @hosts         = (&get_dns_hosts());          my @hosts         = (&get_dns_hosts());
         $result = &push_file($specifier, $pushfile,  \@hosts, $fh);          $result = &push_file($specifier, $pushfile,  \@hosts, $fh);
                 print $fh "ended: ".localtime(time)."\n";                                   print $fh "ended: ".localtime(time)."\n";                 
Line 303  sub update_file { Line 317  sub update_file {
             }              }
             return $result;              return $result;
  } else {   } else {
     print STDERR "Only dns_hosts.tab or dns_domain.tab can be updated\n";      print STDERR "Only dns_hosts.tab, dns_domain.tab or loncapaCAcrl.pem can be updated\n";
     &usage();      &usage();
     return 0;      return 0;
  }   }

Removed from v.1.7  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.