Annotation of loncom/build/CHECKRPMS.rhel, revision 1.1
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: # (Navigate problems for statistical reports
! 28: #
! 29:
! 30: =pod
! 31:
! 32: =head1 NAME
! 33:
! 34: B<CHECKRPMS> - automated status report about RPMs on a system, Up2date version.
! 35:
! 36: =head1 DESCRIPTION
! 37:
! 38: This file automates the usage of up2date to check for available updates
! 39: to RHEL systems.
! 40:
! 41: Must be run as root or www.
! 42:
! 43: =cut
! 44:
! 45: use strict;
! 46: use lib '/home/httpd/lib/perl/';
! 47: use LONCAPA::Configuration;
! 48:
! 49: my $up2date = '/usr/bin/up2date-nox';
! 50: my $tmpfile = '/tmp/CHECKRPMS.'.$$;
! 51:
! 52: #
! 53: # Determine who we email
! 54: my %perlvar=%{LONCAPA::Configuration::read_conf('loncapa.conf')};
! 55: my $emailto = "$perlvar{'lonAdmEMail'}";
! 56: my $subj=$perlvar{'lonHostID'};
! 57: undef(%perlvar);
! 58:
! 59: #
! 60: # Put some nice text in $tmpfile
! 61: my $hostname = `hostname`;
! 62: chomp($hostname);
! 63: open(TMPFILE,">$tmpfile");
! 64: print TMPFILE localtime(time).' '.$hostname."\n";
! 65: print TMPFILE <<ENDHEADER;
! 66: Your system needs to be updated. Please execute (as root)
! 67:
! 68: up2date -u --nox
! 69:
! 70: to bring it up to date.
! 71:
! 72: This is very important for the security of your server. The table below
! 73: lists the packages which need to be updated.
! 74:
! 75: ENDHEADER
! 76:
! 77: close(TMPFILE);
! 78:
! 79: #
! 80: # Execute online_update command to check for updates
! 81: my $up2date_error = 1;
! 82: if (open (PIPE, "$up2date -l 2>&1 |")) {
! 83: my @result=<PIPE>;
! 84: close(PIPE);
! 85: if (@result > 0) {
! 86: my $output = join('',@result);
! 87: if ($output =~ /Fetching Obsoletes list/) {
! 88: $up2date_error = 0;
! 89: if ($output =~ /Name\s+Version\s+Rel\s+[\n\r\f]+\-+[\n\r\f]+(.+)/s) {
! 90: my $packagelist = $1;
! 91: unless (($packagelist =~ /^The following Packages were marked to be skipped by your configuration:/) || ($packagelist eq '')) {
! 92: open(TMPFILE,">>$tmpfile");
! 93: print TMPFILE $packagelist;
! 94: close(TMPFILE);
! 95: $subj.= ' RPMS to upgrade';
! 96: # Send email
! 97: system(qq{mail -s '$subj' $emailto < $tmpfile});
! 98: }
! 99: }
! 100: }
! 101: }
! 102: }
! 103: if ($up2date_error) {
! 104: # Send email
! 105: $subj.= ' Error running RPM update script';
! 106: system(qq{mail -s '$subj' $emailto < $tmpfile});
! 107: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>