#! /bin/sh 
# 
# yppasswd changes pkgs and moves from SUNWcsu to SUNWnisu pkg.  
# Remove it from SUNWcsu pkg in the database.
#

PKG_INSTALL_ROOT=$ROOTDIR
INFO="$PKG_INSTALL_ROOT/var/sadm/pkg/SUNWcsu/pkginfo"

# check for diskless client install. if installing to service area
# continue else exit because we are patching the client's root.

pids=`egrep '^PATCHLIST' $INFO 2> /dev/null | nawk -F= '{print $2}'`
if [ "$pids" = "" ]; then
	exit 0
fi

reset_db_csu () {

if [ "$ROOTDIR" != "" ]; then
        REMOVEF="removef -R ${ROOTDIR}"
else
        REMOVEF="removef"
fi

pkginfo -R $ROOTDIR -q  SUNWcsu
if [ $? -eq 0 ]
then
        ${REMOVEF} SUNWcsu /usr/bin/yppasswd
        ${REMOVEF} -f SUNWcsu || exit 2
fi

}


for i in `echo $pids`; do
        echo $i | egrep -s 128624 || continue
        rev=`expr //$i : '.*-\(.*\)'`
        [ $rev -ge 01 ] && exit
done

for i in `echo $pids`; do
        echo $i | egrep -s 108993 || continue
        rev=`expr //$i : '.*-\(.*\)'`
        [ $rev -ge 14 ] && exit
done

reset_db_csu

exit 0

