Diff for /loncom/build/CHECKRPMS between versions 1.14 and 1.19

version 1.14, 2011/10/17 19:11:42 version 1.19, 2019/10/23 20:34:39
Line 32 Line 32
   
 =head1 NAME  =head1 NAME
   
 B<CHECKRPMS> - automated status report about RPMs (RHEL/Fedora/CentOS/SuSE)   B<CHECKRPMS> - automated status report about RPMs (RHEL/Fedora/CentOS/Oracle Linux/SuSE/SLES) 
                or debs (Debian/Ubuntu) on a system.                  or debs (Debian/Ubuntu) on a system. 
   
 =head1 DESCRIPTION  =head1 DESCRIPTION
Line 42  to LON-CAPA systems. distprobe is used t Line 42  to LON-CAPA systems. distprobe is used t
   
 The utility which is used to complete the check depends on the distro:  The utility which is used to complete the check depends on the distro:
   
 fedora, rhel >= 5, centos, scientific - yum  fedora < 22; rhel (5, 6, 7); centos/scientific/oracle linux <=7 - yum
   fedora >= 22 - dnf
   rhel/centos/oracle linux >= 8 - dnf
 suse 9.X and sles9 - you  suse 9.X and sles9 - you
 suse 10.2,10.3,11.1,11.2,11.3,11.4,sles11 - zypper   suse 10.2, 10.3, 11.X and 12.X; sles (>= 11) - zypper
 sles10,suse10.1 - rug  sles10, suse10.1 - rug
 rhel 4 - up2date  rhel 4 - up2date
 debian, ubuntu - apt-get  debian, ubuntu - apt-get
 others - check-rpms  others - check-rpms
Line 85  open(TMPFILE,">$tmpfile"); Line 87  open(TMPFILE,">$tmpfile");
 print TMPFILE localtime(time).'    '.$hostname."\n";  print TMPFILE localtime(time).'    '.$hostname."\n";
 close(TMPFILE);  close(TMPFILE);
   
   if ($docroot ne '') {
       if (-e "$docroot/lon-status/checkrpms.txt") {
           unlink("$docroot/lon-status/checkrpms.txt");
       }
   }
   
 my ($cmd,$send,$addsubj);  my ($cmd,$send,$addsubj);
 if ($distro =~ /^fedora\d+$/) {  if ($distro =~ /^fedora(\d+)$/) {
     $cmd = 'yum update';      my $version =$1;
     &prepare_msg($tmpfile,$cmd);      if ($version > 21) {
     ($send,$addsubj) = &check_with_yum($tmpfile);          $cmd = 'dnf update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'dnf');
       } else {
           $cmd = 'yum update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'yum');
       }
 } elsif ($distro =~ /^(suse|sles)9\.?\d?$/) {  } elsif ($distro =~ /^(suse|sles)9\.?\d?$/) {
     $cmd = 'you';      $cmd = 'you';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
Line 120  if ($distro =~ /^fedora\d+$/) { Line 135  if ($distro =~ /^fedora\d+$/) {
         $cmd ='up2date -u --nox';          $cmd ='up2date -u --nox';
         &prepare_msg($tmpfile,$cmd);          &prepare_msg($tmpfile,$cmd);
         ($send,$addsubj) = &check_with_up2date($tmpfile);          ($send,$addsubj) = &check_with_up2date($tmpfile);
     } elsif ($version > 4) {      } elsif ($version <= 7) {
         $cmd = 'yum update';          $cmd = 'yum update';
         &prepare_msg($tmpfile,$cmd);          &prepare_msg($tmpfile,$cmd);
         ($send,$addsubj) = &check_with_yum($tmpfile);          ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'yum');
       } else {
           $cmd = 'dnf update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'dnf');
       }
   } elsif ($distro =~ /^(?:centos|scientific|oracle)(\d+)$/) {
       my $version = $1;
       if ($version <= 7) {
           $cmd = 'yum update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'yum');
       } else {
           $cmd = 'dnf update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum_or_dnf($tmpfile,'dnf');
     }      }
 } elsif ($distro =~ /^centos\d+$/) {  
     $cmd = 'yum update';  
     &prepare_msg($tmpfile,$cmd);  
     ($send,$addsubj) = &check_with_yum($tmpfile);  
 } elsif ($distro =~ /^scientific\d+$/) {  
     $cmd = 'yum update';  
     &prepare_msg($tmpfile,$cmd);  
     ($send,$addsubj) = &check_with_yum($tmpfile);  
 } elsif ($distro =~ /^(debian|ubuntu)\d+/) {  } elsif ($distro =~ /^(debian|ubuntu)\d+/) {
     $cmd = 'apt-get upgrade';      $cmd = 'apt-get upgrade';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
Line 145  if ($send) { Line 167  if ($send) {
     $subj .= $addsubj;      $subj .= $addsubj;
     if ($docroot ne '') {      if ($docroot ne '') {
         system("cat $tmpfile > $docroot/lon-status/checkrpms.txt");          system("cat $tmpfile > $docroot/lon-status/checkrpms.txt");
           if ($< == 0) {
               system("chown www:www $docroot/lon-status/checkrpms.txt");
           }
           chmod(0600,"$docroot/lon-status/checkrpms.txt");
     }      }
     system(qq{mail -s '$subj' "$emailto" < $tmpfile});      system(qq{mail -s '$subj' "$emailto" < $tmpfile});
 }  }
Line 208  sub check_with_you { Line 234  sub check_with_you {
     return ($sendflag,$append_to_subj);      return ($sendflag,$append_to_subj);
 }  }
   
 sub check_with_yum {  sub check_with_yum_or_dnf {
     my ($tmpfile) = @_;      my ($tmpfile,$progname) = @_;
     my $yum = '/usr/bin/yum';      my $path_to_exec = '/usr/bin/';
       if ($progname eq 'dnf') {
           $path_to_exec .= $progname;
       } else {
           $path_to_exec .= 'yum';
       }
     my $sendflag = 0;      my $sendflag = 0;
     my $append_to_subj;      my $append_to_subj;
   
     #      #
     # Execute yum command      # Execute command
     my $command = $yum.' check-update '.'>>'.$tmpfile;      my $command = $path_to_exec.' check-update '.'>>'.$tmpfile;
     system($command);      system($command);
   
     my $returnvalue = $?>>8;      my $returnvalue = $?>>8;
   
     #      #
     # Determine status of yum run      # Determine status of yum or dnf run
     if (100 == $returnvalue) {      if (100 == $returnvalue) {
         $sendflag = 1;          $sendflag = 1;
         $append_to_subj = ' RPMS to upgrade';          $append_to_subj = ' RPMS to upgrade';
Line 230  sub check_with_yum { Line 261  sub check_with_yum {
         $sendflag = 1;          $sendflag = 1;
         $append_to_subj = ' Error running RPM update script';          $append_to_subj = ' Error running RPM update script';
     } else {      } else {
         # yum returned 0, so everything is up to date.          # yum or dnf returned 0, so everything is up to date.
     }      }
     return ($sendflag,$append_to_subj);      return ($sendflag,$append_to_subj);
 }  }

Removed from v.1.14  
changed lines
  Added in v.1.19


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