Diff for /loncom/build/Attic/CHECKRPMS.default between versions 1.8 and 1.17

version 1.8, 2002/09/09 15:17:05 version 1.17, 2003/07/30 16:49:27
Line 72  if ($argument eq '--download' or $argume Line 72  if ($argument eq '--download' or $argume
   {    {
     if ($< != 0) # Download mode requires 'root'.      if ($< != 0) # Download mode requires 'root'.
       {        {
         print($out          print(
       '**** ERROR **** Download mode needs to be run as root'."\n");        '**** ERROR **** Download mode needs to be run as root'."\n");
  exit(0); # Exit.   exit(0); # Exit.
       }        }
Line 103  my $command_name=$0; Line 103  my $command_name=$0;
 # ---------------- The FTP servers (and their directory paths) to check against  # ---------------- The FTP servers (and their directory paths) to check against
 my @serverpaths_to_try =   my @serverpaths_to_try = 
   (    (
     'distro.ibiblio.org/pub/linux/distributions/redhat/updates/',      'ftpmirror:loncapa@install.lon-capa.org/pub/redhat/linux/updates/',
     'mirror.pa.msu.edu/linux/redhat/linux/updates/',      'mirror.pa.msu.edu/linux/redhat/linux/updates/',
       'distro.ibiblio.org/pub/linux/distributions/redhat/updates/',
     'limestone.uoregon.edu/redhat/updates/',      'limestone.uoregon.edu/redhat/updates/',
     'rufus.w3.org/linux/redhat/linux/updates/',      'rufus.w3.org/linux/redhat/linux/updates/',
     'opnsrc.support.compaq.com/linux/redhat/updates.redhat.com/',  
   );    );
   
 # -------------------------------------------- Use check-rpms command this way.  # -------------------------------------------- Use check-rpms command this way.
 my $checkcommand = 'check-rpms '.$download.' --rpmuser www -ftp';  my $checkcommand = 'check-rpms -nk '.$download.' --rpmuser www -ftp';
   
 my $FTPSERVER; # ------------------------- the server portion of the serverpath  my $FTPSERVER; # ------------------------- the server portion of the serverpath
 my $FTPUPDATES; # ----------------------------- the actual update root location  my $FTPUPDATES; # ----------------------------- the actual update root location
Line 119  my @rpms; # ---------------------------- Line 119  my @rpms; # ----------------------------
 my $goodoutput; # ------------------------------------ good stuff was returned!  my $goodoutput; # ------------------------------------ good stuff was returned!
 my $reallygoodoutput; # ------------------------------- you are 100% up-to-date  my $reallygoodoutput; # ------------------------------- you are 100% up-to-date
   
   my $simplestatus='time='.time.'&';
   
 # ===================================================== Control flow of output.  # ===================================================== Control flow of output.
 my $out = \*STDOUT; # Default: go to standard output (directly to terminal).  my $out = \*STDOUT; # Default: go to standard output (directly to terminal).
   
Line 191  SERVERLOOP: foreach my $serverpath (@ser Line 193  SERVERLOOP: foreach my $serverpath (@ser
   {    {
     $serverpath=~/^(.*?)\//; # Pattern match the ip name.      $serverpath=~/^(.*?)\//; # Pattern match the ip name.
     $FTPSERVER=$1; # Set to the ip name.      $FTPSERVER=$1; # Set to the ip name.
     print($out "Trying $FTPSERVER...\n"); # Notify of attempts with ip name.      $FTPSERVER_noauth=$FTPSERVER;
     `ping -c 1 $FTPSERVER 2>/dev/null`; # Ping ftp server (are you out there?).      $FTPSERVER_noauth=~s/^.*?\@//;
       print($out
     "Trying $FTPSERVER_noauth...\n"); # Notify of attempts with ip name.
       `ping -c 1 -w 10 $FTPSERVER_noauth 2>/dev/null`;#Ping ftp server (u there?)
     if ($?==0) # If the ftp server can be pinged.      if ($?==0) # If the ftp server can be pinged.
       {        {
  print($out "$FTPSERVER found...\n"); # Tell user ftp server is found.   print($out "$FTPSERVER found...\n"); # Tell user ftp server is found.
Line 261  END Line 266  END
 if (!$goodoutput) # If never received any useable output, assume "no server".  if (!$goodoutput) # If never received any useable output, assume "no server".
   {    {
     print($out '**** ERROR **** Cannot find a working ftp server.'."\n");      print($out '**** ERROR **** Cannot find a working ftp server.'."\n");
       $simplestatus.='status=fail';
     clean_exit($mode,$out,0);      clean_exit($mode,$out,0);
   }    }
 elsif ($reallygoodoutput) # Everything is peachy keen and up-to-date already.  elsif ($reallygoodoutput) # Everything is peachy keen and up-to-date already.
   {    {
     print($out $reallygoodoutput);      print($out $reallygoodoutput);
       $simplestatus.='status=okay';
   }    }
 else # There are RPMs that need to be updated; show list to user.  else # There are RPMs that need to be updated; show list to user.
   {    {
Line 276  the list below.  THIS IS IMPORTANT FOR S Line 283  the list below.  THIS IS IMPORTANT FOR S
   
 END  END
     print($out $goodoutput); # Output the RPM list.      print($out $goodoutput); # Output the RPM list.
       $simplestatus.='status=okay&rpmcount='.$rpmcount;
     if ($mode eq 'interactive')      if ($mode eq 'interactive')
       {        {
  print($out <<END);   print($out <<END);
Line 314  clean_exit($mode,$out,0); Line 322  clean_exit($mode,$out,0);
 sub clean_exit  sub clean_exit
   {    {
     my ($mode,$out,$code)=@_;      my ($mode,$out,$code)=@_;
   #
   # Store simple status
   #
       open(SMP,'>/home/httpd/html/lon-status/checkrpms.txt');
       print SMP $simplestatus."\n";
       close(SMP);
   #
   # Mail
   #
     if ($mode eq 'cronmail') # If cronmail mode, then mail LON-CAPA sys admin.      if ($mode eq 'cronmail') # If cronmail mode, then mail LON-CAPA sys admin.
       {        {
         close(FOUT);          close(FOUT);
   
  # Read in configuration to get e-mail addresses.   # Read in configuration to get e-mail addresses.
  my $perlvarref = read_conf('loncapa.conf');   my $perlvarref = read_conf('loncapa.conf');
  my %perlvar = %{$perlvarref};   my %perlvar = %{$perlvarref};
Line 326  sub clean_exit Line 343  sub clean_exit
  delete $perlvar{'lonSqlAccess'}; # remove since sensitive   delete $perlvar{'lonSqlAccess'}; # remove since sensitive
   
  # Set metadata for the e-mail.   # Set metadata for the e-mail.
         my $emailto = "$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";          my $emailto = "$perlvar{'lonAdmEMail'}";
 # my $emailto = "sharrison\@users.sourceforge.net";  
  my $subj="LON: $perlvar{'lonHostID'}, RPMS to upgrade";   my $subj=$perlvar{'lonHostID'}.', RPMS to upgrade';
  system(  
        'metasend -b -t '.$emailto.' -s '.   # Make the e-mail's subject header to describe whether up-to-date.
        "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain");   if ($reallygoodoutput)
     {
       $subj = 'happy_lon: '.$subj; # Machine is up-to-date.
     }
    else
     {
       $subj = 'ALERT_lon: '.$subj; # There are out-of-date RPMs.
     }
   
    # Send the e-mail.
    my $date = `date +"\%e"`; # Always send a day after the "Ides" or after
                             # the beginning of a month.  (In other words,
                             # send an e-mail every two weeks regardless.)
           if (!$reallygoodoutput or
       $date == 2 or
       $date == 16)
     {
       system(
      'metasend -b -t '.$emailto.' -s '.
      "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain");
     }
       }        }
   
     print($out <<END) if $mode eq 'html'; # If html mode, print ending tags.      print($out <<END) if $mode eq 'html'; # If html mode, print ending tags.

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


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