--- loncom/build/Attic/CHECKRPMS.default 2002/09/09 15:04:48 1.7 +++ loncom/build/Attic/CHECKRPMS.default 2002/12/11 18:28:30 1.12 @@ -19,39 +19,42 @@ other modes can be specified as shown in =over 4 +=item DEFAULT +When left blank, the script runs in interactive mode. First, a proposed +list of RPMs is presented to the user. Then, the user is asked if he or +she wants to download the RPMs to /tmp/loncapa_rpm_updates/. -=back +=item view -=head1 DESCRIPTION +A proposed list of RPMs to update is presented to the user. -This file automates the usage of Martin Siegert's "check-rpms" -script. It runs through a list of possible mirror sites -until it finds one with a reasonably good FTP connection. +=item download -=head2 Future directions +A proposed set of RPMs to update are downloaded into /tmp/loncapa_rpm_updates/. +Note that prior information inside /tmp/loncapa_rpm_updates/ is removed. -Eventually, this script may have a simple argument format -that allows the user to VIEW, DOWNLOAD, or AUTOUPDATE their -computer. Or, this script may evolve into an interactive -series of steps: For example, there may be questions like this: +=item redownload -=over 4 +A proposed set of RPMs to update are downloaded into /tmp/loncapa_rpm_updates/. +Note that prior information inside /tmp/loncapa_rpm_updates/ is not removed. +(This helps support continual attempts from dialup connections.) -=item * +=item html -Do you want to (D)ownload or (A)utoupdate the RPMs -in the list above? +Similar to view mode. XHTML-formatted output is delivered; presumably +to a web client. html mode is automatically chosen if $ENV{'QUERY_STRING'} is +defined. -=item * +=back -Specify a download location for the RPMs -(default=/tmp/update_my_rpms/)? +=head1 DESCRIPTION -=back +This file automates the usage of Martin Siegert's "check-rpms" +script. It runs through a list of possible mirror sites +until it finds one with a reasonably good FTP connection. -Note that there are no current plans to automate a software upgrade of the -kernel. This step should be performed by a qualified system administrator. +For instructions on usage, see L. =head1 AUTHOR @@ -59,6 +62,7 @@ Scott Harrison, sharrison@users.sourcefo =cut +# ' stupid emacs # ================================================== READ IN COMMAND ARGUMENTS. # ---------------------------------------------------- Process download option. @@ -69,7 +73,7 @@ if ($argument eq '--download' or $argume { if ($< != 0) # Download mode requires 'root'. { - print($out + print( '**** ERROR **** Download mode needs to be run as root'."\n"); exit(0); # Exit. } @@ -100,11 +104,11 @@ my $command_name=$0; # ---------------- The FTP servers (and their directory paths) to check against my @serverpaths_to_try = ( - 'distro.ibiblio.org/pub/linux/distributions/redhat/updates/', + 'ftpmirror:loncapa@install.lon-capa.org/pub/redhat/linux/updates/', 'mirror.pa.msu.edu/linux/redhat/linux/updates/', + 'distro.ibiblio.org/pub/linux/distributions/redhat/updates/', 'limestone.uoregon.edu/redhat/updates/', 'rufus.w3.org/linux/redhat/linux/updates/', - 'opnsrc.support.compaq.com/linux/redhat/updates.redhat.com/', ); # -------------------------------------------- Use check-rpms command this way. @@ -188,8 +192,11 @@ SERVERLOOP: foreach my $serverpath (@ser { $serverpath=~/^(.*?)\//; # Pattern match the ip name. $FTPSERVER=$1; # Set to the ip name. - print($out "Trying $FTPSERVER...\n"); # Notify of attempts with ip name. - `ping -c 1 $FTPSERVER 2>/dev/null`; # Ping ftp server (are you out there?). + $FTPSERVER_noauth=$FTPSERVER; + $FTPSERVER_noauth=~s/^.*?\@//; + print($out + "Trying $FTPSERVER_noauth...\n"); # Notify of attempts with ip name. + `ping -c 1 $FTPSERVER_noauth 2>/dev/null`; # Ping ftp server (you there?). if ($?==0) # If the ftp server can be pinged. { print($out "$FTPSERVER found...\n"); # Tell user ftp server is found. @@ -315,6 +322,7 @@ sub clean_exit if ($mode eq 'cronmail') # If cronmail mode, then mail LON-CAPA sys admin. { close(FOUT); + # Read in configuration to get e-mail addresses. my $perlvarref = read_conf('loncapa.conf'); my %perlvar = %{$perlvarref}; @@ -324,11 +332,26 @@ sub clean_exit # Set metadata for the e-mail. my $emailto = "$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}"; -# my $emailto = "sharrison\@users.sourceforge.net"; - my $subj="LON: $perlvar{'lonHostID'}, RPMS to upgrade"; - system( - 'metasend -b -t '.$emailto.' -s '. - "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain"); + + my $subj=$perlvar{'lonHostID'}.', RPMS to upgrade'; + + # Make the e-mail's subject header to describe whether up-to-date. + if ($reallygoodoutput) + { + $subj = 'happy_lon: '.$subj; # Machine is up-to-date. + } + else + { + $subj = 'ALERT_lon: '.$subj; # There are out-of-date RPMs. + } + + # Send the e-mail. + if (!$reallygoodoutput) + { + system( + 'metasend -b -t '.$emailto.' -s '. + "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain"); + } } print($out <