Cover V11, I02

Article
Listing 1
Listing 2

feb2002.tar

Listing 2 Patch retrieval and prep

#!/usr/bin/ksh

PD=/usr/local/patchdiag/patchdiag

PATH=/usr/bin:/usr/local/bin; export PATH
SUN_MIRROR=sunsolve.sun.com
let MY_VER=`uname -r | cut -f2 -d.`; export MY_VER
SUNSOLVE_ID=my_login_id
SUNSOLVE_PW=my_passwd
PATCH_DIR=/tmp/patches

PATCHES=`${PD} | grep ^1 | grep -v CURRENT | sed '/^[0-9\-]*\ *[0-9]*\*$/d'\ | grep -iv Obsoleted | nawk '{ print $1 }' | sort -u`

${PD} | grep -v CURRENT | sed '/^[0-9\-]*\ *[0-9]*\*$/d' \ 
| -grep -v Obsoleted | mailx -s "Patches retrieved" my_email@company.com

undo_patch() {
    if [ "$MY_VER" -ge "7" ]; then
        unzip -o ${1}*.zip && rm -f ${1}*.zip >/dev/null 2>&1
    else
        uncompress ${1}*.tar.Z && tar -xf ${1}*.tar && \
            rm -f ${1}*.tar >/dev/null 2>&1
    fi
}

mkdir -p ${PATCH_DIR} >/dev/null 2>&1
cd ${PATCH_DIR}
touch patch.ignore

for i in ${PATCHES}
do
    grep -s ${i} patch.ignore >/dev/null 2>&1
    if [ "$?" -ne "0" ]; then
        wget -nd -l2 -r -A "${i}*" --http-user=${SUNSOLVE_ID} \
            --http-passwd=${SUNSOLVE_PW} \
            "http://${SUN_MIRROR}/private-cgi/pls.pl?arg=${i}*" >/dev/null
2>&1
        rm -f pls.pl*

        undo_patch ${i}
    fi
done