Annotation of loncom/build/CHECKRPMS.default, revision 1.2
1.1 harris41 1: #!/usr/bin/perl
2:
1.2 ! harris41 3: =pod
! 4:
! 5: =head1 NAME
! 6:
! 7: B<CHECKRPMS> - automated status report about RPMs on a system
! 8:
! 9: =head1 SYNOPSIS
! 10:
! 11: ./CHECKRPMS
! 12:
! 13: or
! 14:
! 15: perl CHECKRPMS
! 16:
! 17: =head1 DESCRIPTION
! 18:
! 19: This file automates the usage of Martin Siegert's "check-rpms"
! 20: script. It runs through a list of possible mirror sites
! 21: until it finds one with a reasonably good FTP connection.
! 22:
! 23: =head2 Future directions
! 24:
! 25: Eventually, this script may have a simple argument format
! 26: that allows the user to VIEW, DOWNLOAD, or AUTOUPDATE their
! 27: computer. Or, this script may evolve into an interactive
! 28: series of steps: For example, there may be questions like this:
! 29:
! 30: =over 4
! 31:
! 32: =item *
! 33:
! 34: Do you want to (D)ownload or (A)utoupdate the RPMs
! 35: in the list above?
! 36:
! 37: =item *
! 38:
! 39: Specify a download location for the RPMs
! 40: (default=/tmp/update_my_rpms/)?
! 41:
! 42: =back
! 43:
! 44: Note that there are no current plans to automate a software upgrade of the
! 45: kernel. This step should be performed by a qualified system administrator.
! 46:
! 47: =head1 AUTHOR
! 48:
! 49: Scott Harrison, sharrison@users.sourceforge.net, 2002
! 50:
! 51: =cut
! 52:
! 53: # =================================================== GENERAL INITIAL VARIABLES
! 54: # ---------------- The FTP servers (and their directory paths) to check against
! 55: my @serverpaths_to_try=(
! 56: 'spock.lite.msu.edu/linux/redhat/linux/updates/',
! 57: 'mirror234.pa.msu.edu/linux/redhat/linux/updates/',
! 58: 'mirror.pa.msu.edu/linux/redhat/linux/updates/',
! 59: 'rufus.w3.org/linux/redhat/linux/updates/',
! 60: 'distro.ibiblio.org/pub/linux/distributions/redhat/updates/',
! 61: 'limestone.uoregon.edu/redhat/updates/',
! 62: 'opnsrc.support.compaq.com/linux/redhat/updates.redhat.com/',
! 63: );
! 64:
! 65: my $RHversion = (split /\s/, `cat /etc/redhat-release`)[4]; # - 6.2 or 7.3 or ?
! 66: my $checkcommand='check-rpms -ftp '; # -------- use check-rpms command this way
! 67:
! 68: my $FTPSERVER; # ------------------------- the server portion of the serverpath
! 69: my $FTPUPDATES; # ----------------------------- the actual update root location
! 70: my @rpms; # ---------------------------------- this will store the list of RPMs
! 71: my $goodoutput; # ------------------------------------ good stuff was returned!
! 72: my $reallygoodoutput; # ------------------------------- you are 100% up-to-date
! 73:
! 74: # ----------------------------------------- Find the check-rpms script location
! 75: if (-e './check-rpms') {
! 76: $commandpre='perl ./';
! 77: }
! 78: elsif (-e 'loncom/build/check-rpms') {
! 79: $commandpre='perl loncom/build/';
! 80: }
! 81: else {
! 82: die("**** ERROR **** CANNOT FIND THE check-rpms SCRIPT\n");
! 83: }
! 84:
! 85: $checkcommand=$commandpre.$checkcommand;
! 86:
! 87: # =============== Go through all the servers until a decent connection is found
! 88: print(<<END);
! 89: THIS SCRIPT IS NOW PROBING SEVERAL FTP SERVERS....
! 90: PLEASE BE PATIENT, THIS MAY TAKE A FEW MINUTES.
! 91: END
! 92:
! 93: SERVERLOOP: foreach my $serverpath (@serverpaths_to_try) {
! 94: $serverpath=~/^(.*?)\//;
! 95: $FTPSERVER=$1;
! 96: print "Trying $FTPSERVER...\n";
! 97: `ping -q -c 1 $FTPSERVER 2>/dev/null`;
1.1 harris41 98: if ($?==0) {
1.2 ! harris41 99: `ncftpls ftp://$FTPSERVER`;
! 100: if ($?==0) {
! 101: $FTPUPDATES="$serverpath$RHversion/en/os";
! 102: print "$checkcommand $FTPUPDATES\n";
! 103: @rpms=`$checkcommand $FTPUPDATES`;
! 104: my $rpmtext=join('',@rpms);
! 105: if ($rpmtext=~/This account is currently not/) { # ---------- uh-oh
! 106: print "...strange error, moving on ($FTPSERVER)\n";
! 107: }
! 108: else { # ------------------------------------- the output is "good"
! 109: $goodoutput=$rpmtext;
! 110: unless (@rpms) {
! 111: $reallygoodoutput=<<END;
! 112: **** NOTE **** All RPMS on your system appear to be up to date.
! 113: END
! 114: }
! 115: last SERVERLOOP;
! 116: }
! 117: }
! 118: print "...cannot establish an ftp session with $FTPSERVER\n";
! 119: }
! 120: else {
! 121: print "...cannot find $FTPSERVER on the network\n";
1.1 harris41 122: }
123: }
1.2 ! harris41 124: if (!$goodoutput) {
! 125: print "**** ERROR **** Cannot find a working ftp server.\n";
! 126: exit(1);
1.1 harris41 127: }
1.2 ! harris41 128: elsif ($reallygoodoutput) {
! 129: print $reallygoodoutput;
1.1 harris41 130: }
1.2 ! harris41 131: else {
! 132: my $rpmcount=scalar(@rpms);
1.1 harris41 133: print(<<END);
1.2 ! harris41 134: **** WARNING **** You need to update at least $rpmcount RPMS shown in
1.1 harris41 135: the list below. THIS IS IMPORTANT FOR SECURITY.
136:
137: END
1.2 ! harris41 138: print $goodoutput;
1.1 harris41 139: print(<<END);
140:
141: Please visit ftp://$FTPUPDATES
142: and download the RPMS you need.
143: For instructions on working with (and upgrading) RPMS, please
144: visit http://www.rpm.org/max-rpm/.
145: END
146: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>