Annotation of loncom/build/CHECKRPMS.suse, revision 1.2
1.1 albertel 1: #!/usr/bin/perl -w
2: #
3: # The LearningOnline Network with CAPA
4: #
1.2 ! raeburn 5: # $Id: CHECKRPMS.suse,v 1.1 2005/04/13 18:56:46 albertel Exp $
1.1 albertel 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: #
1.2 ! raeburn 82: # Execute online_update command to check for updates
! 83: if (open (PIPE, "$you -d -k -l en 2>&1 |")) {
! 84: my $output=<PIPE>;
! 85: close(PIPE);
! 86: chomp $output;
! 87: unless ($output eq 'No updates available.') {
! 88: my $command = $you.' -s -k -l en |grep ^[^I] >>'.$tmpfile;
! 89: system($command);
! 90:
! 91: $subj.= ' RPMS to upgrade';
! 92: # Send email
! 93: system(qq{mail -s '$subj' $emailto < $tmpfile});
! 94: }
! 95: } else {
1.1 albertel 96: # Send email
97: $subj.= ' Error running RPM update script';
98: system(qq{mail -s '$subj' $emailto < $tmpfile});
99: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>