#
# ident "@(#)preremove.src	1.7	08/04/09 SMI"
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ -z "$PKG_INSTALL_ROOT" ]; then PKG_INSTALL_ROOT=""; fi

set -u

set -e

SERVICE=utsvtreg
if [ -z "$PKG_INSTALL_ROOT" ]; then

   OS=`uname -s`
   if [ $OS = "SunOS" ]; then
	#
	# For Solaris use SMF
	#
	svcadm disable $SERVICE
	svccfg delete -f  $SERVICE
   fi
   if [ $OS = "Linux" ]; then 
	#
	# For Linux only.  We need to create the links to init.d files using
	# chkconfig.  This is something else we can't do in an altroot install,
	# but luckily Linux doesn't support altroot installs anyway.
	#
	INITFILES=$SERVICE
	for F in $INITFILES
	do
	   chkconfig --del $F > /dev/null
	done

	#
	# On SuSE/JDS, chkconfig (based on insserv) does not create Kill links in
	# lower runlevels.  They must be created manually.
	#
	if [ -f /etc/SuSE-release ]; then
           # we are installing on either SuSE or JDS
	   ETCINIT=/etc/rc.d
	   KILLFILES="K97utsvtreg"
	   for F in $KILLFILES
		do
		   rm -f $ETCINIT/rcS.d/$F
		   rm -f $ETCINIT/rc1.d/$F
		   rm -f $ETCINIT/rc0.d/$F
		done
	fi
   fi

   $PKG_INSTALL_ROOT/etc/opt/SUNWutsvt/utsvtd remove    

fi

exit 0
