#!/bin/ksh -p
#
# ident "@(#)utcompatlinksctl.ksh	1.9 12/09/13 Oracle"
#
# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
#

set -u

########################################################################
#
# Creates compatibility library symlinks in /opt/SUNWut/lib/compatlinks and
# Creates compatibility library symlinks in /opt/SUNWuttsc/lib
# 
# Checks the availability of the required library SRSS depends on
# If the required library is not available
# then checks the availability of the compatible library
# If the compatible library is present then creates a symlink.
#
########################################################################


########################################################################
#
# Operation entry points, one for each keyword.
# This is where the specific work for this feature happens.
#
########################################################################


disable() {
    for LINK in $LIBPROC_COMPATLINK \

	do
		if [ -L $LINK ] ; then
			rm -rf $LINK
			if $VERB; then
				print "$LINK link disabled"
			fi
		fi
	done
	return 0
}


createLink() {

	typeset LIB=$1
	typeset COMPATLIB=$2
	typeset COMPATLINK=$3
	
	if [ ! -f $LIB ] ; then
		if [ -f $COMPATLIB ]; then
			rm -rf $COMPATLINK
			ln -fs $COMPATLIB $COMPATLINK
			if $VERB; then
				print "$COMPATLINK -> $COMPATLIB link enabled"
			fi
		else
			print -u2 "[${PROG}] Warning: Failed to create $COMPATLINK -> $COMPATLIB link"
			print -u2 "[${PROG}]          $COMPATLIB does not exist."
		fi
	fi

}


enable() {


	createLink $LIBPROC58_COMPATLIB $LIBPROC63_COMPATLIB $LIBPROC_COMPATLINK

}


########################################################################
# Local Variables
# They must defined here to resolve the some of parameter resolution
# problem
########################################################################
local_variables() {

	LIBPROC58_COMPATLIB=/lib64/libproc-3.2.7.so 
	LIBPROC_COMPATLINK=$SUNWUTLIB/compatlinks64/libproc-3.2.7.so
	LIBPROC63_COMPATLIB=/lib64/libproc-3.2.8.so 

}


########################################################################
#
# Configurable parameter
#
########################################################################
# NONE


########################################################################
#
# Variables used in the shared script utctl-shlib
#
########################################################################
DESCR="Sets up compatible library links for Sun Ray programs"


########################################################################
#
# Execution starts here
#
PROGPATH=$(dirname $0)
. $PROGPATH/utctl-shlib
