#!/bin/sh
#
# ident "%W%    %E% SMI"
#
# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# Checks to see if at least 1 recommended patch is installed.

PatchList() {
    ## List of patches, of which one is recommended to be installed 
    ## on the system
	cat <<-eof
		110936-13 For SunMC 3.0 GA Solaris 5.6
		110937-13 For SunMC 3.0 GA Solaris 5.7
		110938-13 For SunMC 3.0 GA Solaris 5.8
		110971-13 For SunMC 3.0 RR Solaris 5.6
		110972-13 For SunMC 3.0 RR Solaris 5.7
		110973-13 For SunMC 3.0 RR Solaris 5.8
	eof
}

PatchInstalled () {
    # $1 =  patchid in the form of xxxxxx-rr
    MinPatchRev=`echo $1 | cut -d '-' -f2`
    PatchBase=`echo $1 | cut -d '-' -f1`
    PatchID=${PatchBase}${MinPatchRev}
    cd $PATCHDB
    HighestRev=`/bin/ls -dt $PatchBase* 2>/dev/null | head -1 | sed 's/-//'`
    [ -n "$HighestRev" ] &&  [  $PatchID -le $HighestRev ] && exit 0
    exit 1
}

FoundPatch() {
    while read x
    do
	set -- $x
        `PatchInstalled $1` && exit 0
    done

    cat <<-eof

	To receive the maximum benefit from this patch 
	install the the SUNMC 3.0 patch (or higher) that 
	is compatible with your SunMC installation from the
	list below.

	`PatchList`

	eof
	
    exit 0
}


PatchList | FoundPatch

