#!/usr/bin/ksh
#
# PatchNum & ROOTDIR are inherited from patch scripts
#
#
# Remove symbolic links in SUNWcsxu SUNWcsu SUNWtoo
# SUNWtoox 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 or
# accumulated version of this patch.  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=""
 



for SYMLINK in $ROOTDIR/usr/lib/link_audit/64 $ROOTDIR/usr/lib/link_audit/32 \
            $ROOTDIR/usr/lib/secure/64 $ROOTDIR/usr/lib/secure/32  
do
         if [ -L $SYMLINK -a ! -a $SYMLINK ]
         then    
            echo "Removing symlink $SYMLINK"
            rm -f $SYMLINK

            case $SYMLINK in

            $ROOTDIR/usr/lib/link_audit/64)
                  removef SUNWtoox $SYMLINK
                  removef -f SUNWtoox ;;
            $ROOTDIR/usr/lib/secure/64)
                  removef SUNWcsxu $SYMLINK
                  removef -f SUNWcsxu ;;
            $ROOTDIR/usr/lib/link_audit/32)
                  removef SUNWtoo $SYMLINK
                  removef -f SUNWtoo  ;;
            $ROOTDIR/usr/lib/secure/32)
                  removef SUNWcsu $SYMLINK
                  removef -f SUNWcsu 

             esac

        fi

done


exit 0
