#
# ident "@(#)postinstall.src	1.8	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
	#
	SMFSVCDIR=/var/svc/manifest/application
	MANIFEST_FILE=${SERVICE}.xml
	svccfg -v import $SMFSVCDIR/$MANIFEST_FILE
	svcadm  -v enable $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 --add $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
		   INITF=`echo $F | sed -e "s/^K..//"`
		   ln -s ../$INITF $ETCINIT/rcS.d/$F
		   ln -s ../$INITF $ETCINIT/rc1.d/$F
		   ln -s ../$INITF $ETCINIT/rc0.d/$F
		done
	fi


   fi

fi

exit 0
