# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
CheckZones()
{
    if [ "$ROOT_DIR" = "/" -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

# Execute in both global and local zones to correct the 
# VERSION if need be 
#if [ "${GLOBAL_ZONE}" != "true" ]; then
#    exit 0
#fi

ROOT_DIR=$1
mypatchid=121454-02
version_list_file=$ROOT_DIR/var/run/$mypatchid.version_list

#########################################################
# Change the VERSION for SUNWdc
#########################################################
for pkg in SUNWdc; do
    pkginfo_filename=$ROOT_DIR/var/sadm/pkg/$pkg/pkginfo

    if [ ! -f $pkginfo_filename ]; then
        continue
    fi

    egrep 'VERSION *= *0.1' $pkginfo_filename > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        
        cp -p $pkginfo_filename ${pkginfo_filename}.new
        sed 's/VERSION=.*/VERSION=1.0/'  $pkginfo_filename > ${pkginfo_filename}.new
        if [ $? -eq 0 ]; then
            mv ${pkginfo_filename}.new $pkginfo_filename
            touch $version_list_file
            echo $pkg >> $version_list_file
        else
            rm -f ${pkginfo_filename}.new
        fi
    fi
done

exit 0
