# Copyright Sun Microsystems, Inc. All Rights Reserved.
# @(#)preremove.src	1.7	04/16/01	SMI

if [ -z "$PKG_INSTALL_ROOT" ]; then
  PKG_INSTALL_ROOT=""
fi

set -u

#
# Remove files created as side-effects of 
# scripts delivered by this package.
#

DIR="$PKG_INSTALL_ROOT/etc/opt/SUNWut"

/bin/rm -f $DIR/terminals \
	$DIR/auth.props.bu \
	$DIR/policy/utpolicy \
	$DIR/policy/utpolicy.bu

# 
# Run utrepair to remove modifications from all CDE / Solaris files 
# for use with Sun Ray
#

SUNWUTLIB="${PKG_INSTALL_ROOT}/${BASEDIR}/SUNWut/lib"
PROTODIR="${SUNWUTLIB}/prototype"

#
# List of files to be updated by utrepair
#
MODFILES="/usr/dt/config/Xstartup  /usr/dt/config/Xsetup  /usr/dt/config/Xreset  /usr/openwin/server/etc/OWconfig  /etc/inet/services  /etc/inet/inetd.conf"

if [ -x ${SUNWUTLIB}/utrepair ]; then
	
	#
	# Build the argument list for utrepair
	#
	repairargs="-r ${MODFILES}"

	${SUNWUTLIB}/utrepair ${repairargs} 
fi

#
# Edit pam.conf to remove any configuration for utnsclogin
#

ETCFILE="/etc/pam.conf"
TMPR="/etc/tmp.$$"

isconf=`sed -n  's/^.*utnsclogin//p' $ETCFILE`

if [ "$isconf" ]
then
        sed 's/^.*utnsclogin.*$//p' $ETCFILE > $TMPR
        /usr/bin/cp $TMPR $ETCFILE
	/usr/bin/rm $TMPR
fi

# Always succeeds
exit 0;
