#!/sbin/sh
########################################
#  Product: HPUXOpenSSL
#  Fileset: Latest
#  postinstall
#  (c) Copyright Hewlett-Packard Company
########################################
UTILS="/usr/lbin/sw/control_utils"
    if [[ ! -f $UTILS ]]
    then
        echo "ERROR: Cannot find $UTILS"
        exit 1
    fi
    . $UTILS
exitval=$SUCCESS
####################################
# Linking The Files
####################################
# Executable Files
####################################

DEFAULT_VERSION="0.9.8"

if [[ -d /opt/openssl/bin ]]
then
	for list in `ls /opt/openssl/bin`
	do
		rm -f /usr/bin/$list 1>/dev/null 2>/dev/null
	done
fi

if [[ -d /opt/openssl/${DEFAULT_VERSION}/bin ]]
then
	if [[ -d /opt/openssl/bin/ ]]
	then
		rm -rf /opt/openssl/bin 1>/dev/null 2>/dev/null
	fi
	cd /opt/openssl/; ln -sf ${DEFAULT_VERSION}/bin bin; cd - 1>/dev/null 2>/dev/null
fi

for list in `ls /opt/openssl/bin | grep -v '^#'`
do
	rm -f /usr/bin/$list 1>/dev/null 2>/dev/null
	ln -sf /opt/openssl/bin/$list /usr/bin/$list 1>/dev/null 2>/dev/null
done

chmod 555 /opt/openssl/${DEFAULT_VERSION}         1>/dev/null 2>/dev/null
chown bin:bin /opt/openssl/${DEFAULT_VERSION}     1>/dev/null 2>/dev/null
chmod 555 /opt/openssl/${DEFAULT_VERSION}/bin     1>/dev/null 2>/dev/null
chown bin:bin /opt/openssl/${DEFAULT_VERSION}/bin 1>/dev/null 2>/dev/null

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