Keeping The FTP Installation Server Updated

To keep the FTP Installation Server updated, I will need these packages:

A relatively simple bash shell script running as a cron (or anacron) job on a daily or weekly basis keeps the 'updates' part of the RPM repository updated and also 'Yum friendly':

#!/bin/bash

NCFTP=/usr/bin/ncftpget
FOPT=-R
YUMARCH=/usr/bin/yum-arch
YOPT=-q
FIND=/usr/bin/find
GREP=/bin/grep

# defaults
FHOST=updates.redhat.com
PATHPRE=
PATHPOST=en/os

# check for arg and then file with mirror info
if [ -n "$1" ]; then
        SRCFILE=$0.$1
        if [ -r $SRCFILE ]; then
                echo "Including configuration from $SRCFILE:"
                #cat $SRCFILE
                source $SRCFILE
        fi
fi

echo "=== Starting Red Hat Linux Update Download ==="

for VER in 7.3 9 ; do
        LOC=/var/ftp/pub/redhat/$VER/updates/
        FPATH=$PATHPRE/$VER/$PATHPOST
        echo "  = Red Hat $VER ="
        cd $LOC
        if [ $? == 0 ]; then
                echo "Getting updates on $FHOST from /$FPATH/"
                $NCFTP $FOPT ftp://$FHOST/$FPATH/athlon
                $NCFTP $FOPT ftp://$FHOST/$FPATH/i386
                $NCFTP $FOPT ftp://$FHOST/$FPATH/i486
                $NCFTP $FOPT ftp://$FHOST/$FPATH/i586
                $NCFTP $FOPT ftp://$FHOST/$FPATH/i686
                $NCFTP $FOPT ftp://$FHOST/$FPATH/noarch
                echo "Setting file modes"
                $FIND $LOC -type d -exec /bin/chmod 755 \{\} \;
                $FIND $LOC -type f -exec /bin/chmod 644 \{\} \;
                echo "YUM-ifying updates"
                $YUMARCH $YOPT $LOC > /dev/null 2>&1
        else
                echo "Error changing to $LOC, skipping $VER"
        fi
done

echo "=== Ending Red Hat Linux Update Download ==="
To access different mirrors (on different days of the week, or whenever), create a file with the same filename as the above script with a meaningful extension (like "get-rh-updates" and "get-rh-updates.umn"):
FHOST=ftp.software.umn.edu
PATHPRE=pub/linux/redhat/linux/updates
PATHPOST=en/os
and call the script with the extension ("umn") as an argument:
$ /home/myuser/cron/get-rh-updates umn
Note that this script will get updates for multiple Red Hat versions. I prefer cron to anacron because I can know exactly when things are supposed to happen. I choose the University of Minnsota Red Hat mirror because it is close (network wise) to my work. To choose another, simply connect to the via ftp, make note of where the updates are kept, and use that path instead.

I put the script in my unprivileged user's '~/cron/' directory and schedule it daily (using 'crontab -e'). This is a typical crontab entry:

  0 1 * * * /home/myuser/cron/get-rh-updates umn
assuming that 1 AM is a slow time for the FTP mirror. Also, I make sure my 'ncftpget' defaults to "get only new files and new versions of files". On Red Hat Linux it has consistently behaved this way for me (but not so on Solaris). If yours does not try some other tool (like wget, curl, or rsync) that will not download every file every time.