
# 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

#XXXSpecial_CommandsXXX#
#########################################################
# smpatch will be moved from SUNWswmt to another package.
# Save it so we can undo on backout.
#########################################################
smpatch_pkg=`grep "smpatch f" /var/sadm/install/contents | awk '{print $10}'`
if [ "$smpatch_pkg" == "SUNWswmt" ]; then
    cp -p $ROOTDIR/usr/sbin/smpatch $ROOTDIR/var/run/119107-03.smpatch.SUNWswmt.undo

    # Inform the system that we're updating the database
    removef -R $ROOTDIR SUNWswmt /usr/sbin/smpatch > /dev/null 2>&1
    removef -R $ROOTDIR SUNWswmt /usr/sadm/bin/smpatch > /dev/null 2>&1

    # Remove the files
    rm $ROOTDIR/usr/sadm/bin/smpatch
    rm $ROOTDIR/usr/sbin/smpatch

    # Update the database
    removef -R $ROOTDIR -f SUNWswmt 
fi

#########################################################
# Change the BASEDIR for SUNWbreg
#########################################################
if [ -f $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo ]; then
    cp -p $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo.new
    sed 's/BASEDIR=.*/BASEDIR=\//' $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo > $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo.new
    if [ $? -eq 0 ]; then
        mv $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo.new $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo
    else
        rm -f $ROOTDIR/var/sadm/pkg/SUNWbreg/pkginfo.new
    fi
fi

#########################################################
# Change the BASEDIR for SUNWdc
#########################################################
if [ -f $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo ]; then
    cp -p $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo.new
    sed 's/BASEDIR=.*/BASEDIR=\//' $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo > $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo.new
    if [ $? -eq 0 ]; then
        mv $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo.new $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo
    else
        rm -f $ROOTDIR/var/sadm/pkg/SUNWdc/pkginfo.new
    fi
fi


exit 0



exit 0
