#! /bin/sh
#set -x

####################################################################
# Post Remove Script for PEX 2.1     v2.0  (05/13/93)
####################################################################

OW_CONFIG_DIR=$BASEDIR/openwin/server/etc
OW_CONFIG=$OW_CONFIG_DIR/OWconfig
TMP_OW_CONFIG=/tmp/OWconfig

if [ -f $OW_CONFIG ]; then
   if [ ! -w $OW_CONFIG ]; then
	echo "Error: $OW_CONFIG not writeable"
   else
#######################################################
#  Search for SUNWX3D-PEX.so.2 and delete the entry
#  return this file back to its original state 
#######################################################
        \awk '
                BEGIN {
			i = 0
			j = 0
                        lines = 0
                }
                {
                        i = index($0, "#")
                        j = index($0, "SUNWX3D-PEX")
                        if (i != 0 && j != 0 && i < j) {
			     lines = 5
                        }
                        if (lines > 0) {
                             lines--
                        }
                        else
                             print $0
                }' < $OW_CONFIG > $TMP_OW_CONFIG
        # copy back the original file
	\cp $TMP_OW_CONFIG $OW_CONFIG
	\rm $TMP_OW_CONFIG 
   fi
else
   echo "Error: failed to remove SUNWpexsv" 
fi
