Annotation of loncom/build/CHECKRPMS.default, revision 1.18

1.18    ! matthew     1: #!/usr/bin/perl -w
        !             2: #
        !             3: # The LearningOnline Network with CAPA
        !             4: #
        !             5: # $Id$
        !             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: #
1.1       harris41   31: 
1.2       harris41   32: =pod
                     33: 
                     34: =head1 NAME
                     35: 
1.18    ! matthew    36: B<CHECKRPMS> - automated status report about RPMs on a system.
1.2       harris41   37: 
1.8       harris41   38: =head1 DESCRIPTION
1.2       harris41   39: 
1.18    ! matthew    40: Runs Martin Seigert's checkrpms script.  See 
        !            41: http://www.sfu.ca/acs/security/linux/check-rpms.html for more information.
1.2       harris41   42: 
1.18    ! matthew    43: Must be run as root or www.
1.2       harris41   44: 
                     45: =cut
                     46: 
1.18    ! matthew    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';
1.7       harris41   55: 
1.18    ! matthew    56: $emailto = 'hallmat3@msu.edu';
1.7       harris41   57: 
1.18    ! matthew    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;
1.2       harris41   64: 
1.18    ! matthew    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.
1.1       harris41   68: 
                     69: END
1.7       harris41   70: 
1.18    ! matthew    71: }
1.7       harris41   72: 
1.18    ! matthew    73: #
        !            74: # Run check-rpms and capture its output
        !            75: $mailmsg = `$checkrpms`;
1.7       harris41   76: 
1.18    ! matthew    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: }
1.7       harris41  108: 
1.18    ! matthew   109: exit;

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