Annotation of loncom/build/CHECKRPMS.suse, revision 1.1
1.1 ! albertel 1: #!/usr/bin/perl -w
! 2: #
! 3: # The LearningOnline Network with CAPA
! 4: #
! 5: # $Id: CHECKRPMS.fedora,v 1.2 2004/07/19 21:01:51 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, Yum version.
! 37:
! 38: =head1 DESCRIPTION
! 39:
! 40: This file automates the usage of yum to check for available updates
! 41: to Fedora systems.
! 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: my $you = '/usr/bin/online_update';
! 52: my $tmpfile = '/tmp/CHECKRPMS.'.$$;
! 53:
! 54: #
! 55: # Determine who we email
! 56: my %perlvar=%{LONCAPA::Configuration::read_conf('loncapa.conf')};
! 57: my $emailto = "$perlvar{'lonAdmEMail'}";
! 58: my $subj=$perlvar{'lonHostID'};
! 59: undef(%perlvar);
! 60:
! 61: #
! 62: # Put some nice text in $tmpfile
! 63: my $hostname = `hostname`;
! 64: chomp($hostname);
! 65: open(TMPFILE,">$tmpfile");
! 66: print TMPFILE localtime(time).' '.$hostname."\n";
! 67: print TMPFILE <<ENDHEADER;
! 68: Your system needs to be updated. Please execute (as root)
! 69:
! 70: you
! 71:
! 72: to bring it up to date.
! 73:
! 74: This is very important for the security of your server. The table below
! 75: lists the packages which need to be updated.
! 76:
! 77: ENDHEADER
! 78:
! 79: close(TMPFILE);
! 80:
! 81: #
! 82: # Execute yum command
! 83: my $command = $you.' -s -k -l en '.'>>'.$tmpfile;
! 84: system($command);
! 85:
! 86: my $returnvalue = $?>>8;
! 87:
! 88: #
! 89: # Determine status of yum run
! 90: if (100 == $returnvalue) {
! 91: $subj.= ' RPMS to upgrade';
! 92: # Send email
! 93: system(qq{mail -s '$subj' $emailto < $tmpfile});
! 94: } elsif (0 != $returnvalue) {
! 95: # Send email
! 96: $subj.= ' Error running RPM update script';
! 97: system(qq{mail -s '$subj' $emailto < $tmpfile});
! 98: } else {
! 99: # you returned 0, so everything is up to date.
! 100: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>