#! /usr/bin/ksh
#
# Remove symbolic links in SUNWsc introduced by the patch.
#
# This is a workaround for a patchrm bug where symlinks do not
# get removed on backout and also handles not to remove them if
# this patch is installed on top of a previous version.  
# After files have been restored on backout, check to see if
# there is an existing source pointed to by the symlink, if so,
# assume a previous patch installed the file.  If no source exists, 
# meaning sym link points to nothing, remove the sym links.
#


[ "$ROOTDIR" = / ] && ROOTDIR=""

TOP=${ROOTDIR}/opt/SUNWcluster
LINKS="lib/libscutil.so
etc/reconf/conf.d/rc12.d/99_netmon
etc/reconf/conf.d/rcA.d/99_netmon
etc/reconf/conf.d/rcK.d/99_netmon
etc/reconf/conf.d/rcR.d/99_netmon
etc/reconf/conf.d/rc12.d/90_rpcbindmon
etc/reconf/conf.d/rcA.d/90_rpcbindmon
etc/reconf/conf.d/rcK.d/90_rpcbindmon
etc/reconf/conf.d/rcR.d/90_rpcbindmon"

for link in $LINKS; do
	SYMLINK=${TOP}/${link}
    if [ -L $SYMLINK -a ! -a $SYMLINK ]
    then    
		echo "Removing symlink $SYMLINK"
        rm -f $SYMLINK
        removef SUNWsc $SYMLINK
        removef -f SUNWsc
    fi
done

exit 0
