#!/usr/bin/ksh
## Copyright 2005 Sun Microsystems, Inc. All rights reserved.

_GetOsVersion() {
        typeset -r rel_file=$1
        head -1 $rel_file | awk '{print $2}'
}

PrintErr() {
        echo "ERROR: $@" >&2
}

typeset -r REG_ALT_ROOT=${ROOTDIR:-/}
typeset -r RELEASE_FILE=$REG_ALT_ROOT/etc/release

if [ ! -f "$RELEASE_FILE" ] ; then
        PrintErr "Unable to find the $RELEASE_FILE the target system."
        exit 1
fi

OS_VER=$(_GetOsVersion $RELEASE_FILE)

if [ -z "$OS_VER" ] ; then
        PrintErr "Invalid OS version"
        exit 1
fi

if [[ "$OS_VER" != @(9|10) ]] ; then
   PrintErr "This SunMC patch can only be installed on a SunOS 5.9 or 5.10"\
                "system.\nPlease install the correct patch."
   exit 1
fi
