# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
CheckZones()
{
    if [ "$ROOTDIR" = "/" -a -x /usr/bin/zonename ]; then
        ZONENAME=`/usr/bin/zonename`
        if [ ${ZONENAME} = "global" ]; then
            GLOBAL_ZONE=true
        else
            GLOBAL_ZONE=false
        fi
    else
        # Unable to determine zone
        GLOBAL_ZONE=true
    fi
}

CheckZones
if [ "${GLOBAL_ZONE}" != "true" ]; then
    exit 0
fi

mypatchid=120335-02

UNINSTALL_ORDER="SUNWsupdatemgru SUNWkupdatemgru SUNWjupdatemgru SUNWiupdatemgru SUNWhupdatemgru SUNWfupdatemgru SUNWeupdatemgru SUNWdupdatemgru SUNWcupdatemgru SUNWsbreg SUNWkbreg SUNWjbreg SUNWibreg SUNWhbreg SUNWfbreg SUNWebreg SUNWdbreg SUNWcbreg "
ALWAYS_UNINSTALL=""
ADMINFILE=/var/run/admin.quiet.$$

cat << EOF > $ADMINFILE
mail=
instance=overwrite
partial=ask
runlevel=ask
idepend=nocheck
rdepend=nocheck
space=ask
setuid=nocheck
conflict=nocheck
action=nocheck
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
proxy=
EOF

for pkg in $UNINSTALL_ORDER; do

    pkginfo -R ${ROOTDIR} $pkg > /dev/null 2>&1
    stat=$?
    if [ $stat -ne 0 ]; then
        continue
    fi

    echo $ALWAYS_UNINSTALL | grep $pkg > /dev/null 2>&1
    stat=$?
    if [ $stat -eq 0 ]; then
        pkgrm -R ${ROOTDIR} -n -a $ADMINFILE $pkg
        continue
    fi

    grep $pkg ${ROOTDIR}/var/sadm/patch/${mypatchid}/pkgrm_list > /dev/null 2>&1
    stat=$?
    if [ $stat -eq 0 ]; then
        pkgrm -R ${ROOTDIR} -n -a $ADMINFILE $pkg
        continue
    fi
done
rm ${ROOTDIR}/var/sadm/patch/${mypatchid}/pkgrm_list

#XXXSpecial_CommandsXXX#


