Annotation of loncom/build/CHECKRPMS.sles10, revision 1.2

1.1       raeburn     1: #!/usr/bin/perl -w
                      2: #
                      3: # The LearningOnline Network with CAPA
                      4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/html/adm/gpl.txt
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
                     27: 
                     28: =pod
                     29: 
                     30: =head1 NAME
                     31: 
                     32: B<CHECKRPMS> - automated status report about RPMs on a system, rug version.
                     33: 
                     34: =head1 DESCRIPTION
                     35: 
                     36: This file automates the usage of yum to check for available updates
                     37: to SLES10 systems.
                     38: 
                     39: Must be run as root or www.
                     40: 
                     41: =cut
                     42: 
                     43: use strict;
                     44: use lib '/home/httpd/lib/perl/';
                     45: use LONCAPA::Configuration;
                     46: 
                     47: my $rug = '/usr/bin/rug';
                     48: my $tmpfile = '/tmp/CHECKRPMS.'.$$;
                     49: 
                     50: #
                     51: # Determine who we email
                     52: my %perlvar=%{LONCAPA::Configuration::read_conf('loncapa.conf')};
                     53: my $emailto = "$perlvar{'lonAdmEMail'}";
                     54: my $subj=$perlvar{'lonHostID'};
                     55: undef(%perlvar);
                     56: 
                     57: #
                     58: # Put some nice text in $tmpfile
                     59: my $hostname = `hostname`;
                     60: chomp($hostname);
                     61: open(TMPFILE,">$tmpfile");
                     62: print TMPFILE localtime(time).'    '.$hostname."\n";
                     63: print TMPFILE <<ENDHEADER;
                     64: Your system needs to be updated.  Please execute (as root) 
                     65: 
                     66: rug up
                     67: 
                     68: to bring it up to date.
                     69: 
                     70: This is very important for the security of your server.  The table below
                     71: lists the packages which need to be updated.
                     72: 
                     73: ENDHEADER
                     74: 
                     75: close(TMPFILE);
                     76: 
                     77: #
                     78: # Execute rug command to check for updates 
1.2     ! raeburn    79: if (open (PIPE, "$rug up -N 2>&1 |")) {
1.1       raeburn    80:     my $output=<PIPE>;
                     81:     close(PIPE);
                     82:     chomp $output;
                     83:     unless ($output eq 'No updates are available.') {
                     84:         open(TMPFILE,">>$tmpfile");
                     85:         print TMPFILE $output;
                     86:         close(TMPFILE);
                     87: 
                     88:         $subj.= ' RPMS to upgrade';
                     89:         # Send email
                     90:         system(qq{mail -s '$subj' $emailto < $tmpfile});
                     91:      }
                     92: } else {
                     93:     # Send email
                     94:     $subj.= ' Error running RPM update check';
                     95:     system(qq{mail -s '$subj' $emailto < $tmpfile});
                     96: }

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