#!/sbin/sh

########
#  Product: GraphicsPHIGSRT
#  Fileset: PHIGS-RUN
#  unconfigure
#  @(#) $Revision: 206.1 $
########
#
# (c) Copyright Hewlett-Packard Company, 1993
#
########

	UTILS="/usr/lbin/sw/control_utils"

	if [[ ! -f $UTILS ]]
	then
		echo "ERROR: Cannot find $UTILS"
		exit 1
	fi

	. $UTILS

	exitval=$SUCCESS

################################################################################
#set -x # For debugging purposes.  _Never_ ship uncommented!!

	##
	## Set up local environment variables
	##

	SW_INSTALL_DIR="/"
	
	##
	## Test to see if either SW_ROOT_DIRECTORY or SW_LOCATION is
	## set to something other than /.  If so, set up SW_INSTALL_DIR
	## so it will not have spurious /'s in the path name.
	##
	
	if [ $SW_ROOT_DIRECTORY != / -o $SW_LOCATION != / ]
		then
		if [ $SW_ROOT_DIRECTORY != / ]
			then
				if [ $SW_LOCATION != / ]
					then
						SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}${SW_LOCATION}"
					else
						SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}"
				fi
			else
				if [ $SW_LOCATION != / ]
					then
						SW_INSTALL_DIR="${SW_LOCATION}"
				fi
		fi
	fi

	PHIGS_DIR="$SW_LOCATION"
	PHIGS_CHARSETS_DIR="${PHIGS_DIR}char_sets"
	PHIGS_CHARSETS_FILE="${PHIGS_DIR}config/char_set_info"
	PHIGS_DEFAULTS_FILE="${PHIGS_DIR}config/defaults"

	ETC_DIR="/etc/opt"
	ETC_PHIGS_DIR="${ETC_DIR}/phigs"
	ETC_CHARSETS_DIR_LINK="${ETC_PHIGS_DIR}/char_sets"
	ETC_CHARSETS_FILE_LINK="${ETC_PHIGS_DIR}/char_set_info"
	ETC_DEFAULTS_LINK="${ETC_PHIGS_DIR}/defaults"

	##
	##  Delete the symbolic links in the /etc/opt/directory
	##  only if they are links.  If a user has replaced then
	##  with a file or directory, do not remove them.
	##

	if [ -h $ETC_CHARSETS_DIR_LINK ]
	then
		rm -f $ETC_CHARSETS_DIR_LINK > /dev/null 2>&1
	fi

	##
	##  Remove the PHIGS socket directory contents
	##

	SOCKETS_DIR="/var/spool/sockets"
	PHIGS_SOCKET="${SOCKETS_DIR}/phigs"

	if [ -d $PHIGS_SOCKET ]
	then
		rm -fr ${PHIGS_SOCKET}/* > /dev/null 2>&1
	fi

	##
	## Delete /opt/graphics/phigs/bin from /etc/PATH
	##

	mod_pathfile -d P ${PHIGS_DIR}bin

	##
	## Delete /opt/graphic/phigs/lib from /etc/SHLIB_PATH
	##

	mod_pathfile -d SP ${PHIGS_DIR}lib

	exit $exitval
################################################################################
