--- loncom/build/Attic/CHECKRPMS.default 2002/08/03 17:06:21 1.2 +++ loncom/build/Attic/CHECKRPMS.default 2002/09/05 17:36:39 1.4 @@ -50,11 +50,27 @@ Scott Harrison, sharrison@users.sourcefo =cut +# =================================================== READ IN COMMAND ARGUMENTS +# ---------------------------------------------------- Process download option. +my $download=shift(@ARGV); +if ($download eq '--download') + { + if ($< != 0) # Download mode requires 'root'. + { + print('**** ERROR **** Download mode needs to be run as root'."\n"); + exit(1); # Exit with error status. + } + `rm -Rf /tmp/loncapa_rpm_updates`; + $download='-v -dl -d /tmp/loncapa_rpm_updates'; # Part of check-rpms args. + } +else + { + $download=''; + } + # =================================================== GENERAL INITIAL VARIABLES # ---------------- The FTP servers (and their directory paths) to check against my @serverpaths_to_try=( - 'spock.lite.msu.edu/linux/redhat/linux/updates/', - 'mirror234.pa.msu.edu/linux/redhat/linux/updates/', 'mirror.pa.msu.edu/linux/redhat/linux/updates/', 'rufus.w3.org/linux/redhat/linux/updates/', 'distro.ibiblio.org/pub/linux/distributions/redhat/updates/', @@ -62,8 +78,11 @@ my @serverpaths_to_try=( 'opnsrc.support.compaq.com/linux/redhat/updates.redhat.com/', ); +# --------------------------------------------------- Determine RedHat version. my $RHversion = (split /\s/, `cat /etc/redhat-release`)[4]; # - 6.2 or 7.3 or ? -my $checkcommand='check-rpms -ftp '; # -------- use check-rpms command this way + + # ------------------------------------------- Use check-rpms command this way. +my $checkcommand='check-rpms '.$download.' --rpmuser www -ftp'; my $FTPSERVER; # ------------------------- the server portion of the serverpath my $FTPUPDATES; # ----------------------------- the actual update root location @@ -94,14 +113,25 @@ SERVERLOOP: foreach my $serverpath (@ser $serverpath=~/^(.*?)\//; $FTPSERVER=$1; print "Trying $FTPSERVER...\n"; - `ping -q -c 1 $FTPSERVER 2>/dev/null`; + `ping -c 1 $FTPSERVER 2>/dev/null`; if ($?==0) { + print "$FTPSERVER found...\n"; `ncftpls ftp://$FTPSERVER`; if ($?==0) { $FTPUPDATES="$serverpath$RHversion/en/os"; print "$checkcommand $FTPUPDATES\n"; - @rpms=`$checkcommand $FTPUPDATES`; + if ($download) { + $|=1; + print `$checkcommand $FTPUPDATES 2>\&1`; + exit(0); + } + @rpms=`$checkcommand $FTPUPDATES 2>\&1`; my $rpmtext=join('',@rpms); + if ($rpmtext=~/You do not seem to have a/) { + print "You do not have a 'www' user on your system.\n". + "Please add this user and try this command again.\n"; + exit(1); + } if ($rpmtext=~/This account is currently not/) { # ---------- uh-oh print "...strange error, moving on ($FTPSERVER)\n"; } @@ -131,7 +161,7 @@ elsif ($reallygoodoutput) { else { my $rpmcount=scalar(@rpms); print(<