File:  [LON-CAPA] / loncom / build / Attic / CHECKRPMS.default
Revision 1.18: download - view: text, annotated - select for diffs
Wed Aug 25 14:44:32 2004 UTC (19 years, 10 months ago) by matthew
Branches: MAIN
CVS tags: version_1_2_0, HEAD
Complete rewrite to use the new checkrpms package.

    1: #!/usr/bin/perl -w
    2: #
    3: # The LearningOnline Network with CAPA
    4: #
    5: # $Id: CHECKRPMS.default,v 1.18 2004/08/25 14:44:32 matthew Exp $
    6: #
    7: # Copyright Michigan State University Board of Trustees
    8: #
    9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: #
   11: # LON-CAPA is free software; you can redistribute it and/or modify
   12: # it under the terms of the GNU General Public License as published by
   13: # the Free Software Foundation; either version 2 of the License, or
   14: # (at your option) any later version.
   15: #
   16: # LON-CAPA is distributed in the hope that it will be useful,
   17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: # GNU General Public License for more details.
   20: #
   21: # You should have received a copy of the GNU General Public License
   22: # along with LON-CAPA; if not, write to the Free Software
   23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: #
   25: # /home/httpd/html/adm/gpl.txt
   26: #
   27: # http://www.lon-capa.org/
   28: #
   29: # (Navigate problems for statistical reports
   30: #
   31: 
   32: =pod
   33: 
   34: =head1 NAME
   35: 
   36: B<CHECKRPMS> - automated status report about RPMs on a system.
   37: 
   38: =head1 DESCRIPTION
   39: 
   40: Runs Martin Seigert's checkrpms script.  See 
   41: http://www.sfu.ca/acs/security/linux/check-rpms.html for more information.
   42: 
   43: Must be run as root or www.
   44: 
   45: =cut
   46: 
   47: use strict;
   48: use lib '/home/httpd/lib/perl/';
   49: use LONCAPA::Configuration;
   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'}.' rpm status';
   55: 
   56: $emailto = 'hallmat3@msu.edu';
   57: 
   58: my $checkrpms = '/usr/local/bin/check-rpms';
   59: #
   60: # Check that checkrpms is installed and is the proper version...
   61: my $mailmsg = '';
   62: if (! -e $checkrpms) {
   63:     $mailmsg = <<END;
   64: 
   65: Unable to locate check-rpms on your system.  Please go to 
   66: http://www.sfu.ca/acs/security/linux/check-rpms.html, download and 
   67: install check-rpms on this system.
   68: 
   69: END
   70: 
   71: }
   72: 
   73: #
   74: # Run check-rpms and capture its output
   75: $mailmsg = `$checkrpms`;
   76: 
   77: #
   78: # Email the user the output of checkrpms
   79: if ($mailmsg ne '') {
   80:     $mailmsg =<<"END";
   81: checkrpms checked the status of the packages on your system and 
   82: produced the following output:
   83: -------------------------------------------------------
   84: $mailmsg
   85: -------------------------------------------------------
   86: If there are rpms which need to be installed, please log into
   87: $perlvar{'lonHostID'} and run the following command
   88: 
   89: $checkrpms --update
   90: 
   91: If there are kernel packages to be installed, use
   92: 
   93: $checkrpms --update --install-kernel
   94: 
   95: Keeping your system up to date is very important.
   96: Ensuring you are using up to date software is a prerequisite for a 
   97: secure system.
   98: 
   99: END
  100:     my $mail_file = '/tmp/CHECKRPMS.'.$$;
  101:     open(MAILFILE,">$mail_file") || die("Unable to write to ".$mail_file);
  102:     print MAILFILE $mailmsg.$/;
  103:     close(MAILFILE);
  104:     my $mailcommand = "mail -s '$subj' $emailto <$mail_file";
  105:     print STDERR $mailcommand;
  106:     system($mailcommand);
  107: }
  108: 
  109: exit;

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