#!/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/fips/${DEFAULT_VERSION}/bin ]]
then
	if [[ -d /opt/openssl/fips/bin/ ]]
	then
		rm -rf /opt/openssl/fips/bin 1>/dev/null 2>/dev/null
	fi
#	cd /opt/openssl/fips; ln -sf ${DEFAULT_VERSION}/bin bin; cd - 1>/dev/null 2>/dev/null
fi

# Following is for fips 0.98f openssl cmd
#mv /opt/openssl/fips/0.9.8/bin/openssl /opt/openssl/fips/0.9.8/bin/openssl98

#echo "#!/bin/sh\n\
#export SHLIB_PATH=/opt/openssl/fips/0.9.8/lib\n\
#exec /opt/openssl/fips/0.9.8/bin/openssl98 \$*" > /opt/openssl/fips/0.9.8/bin/openssl

#chmod 555 /opt/openssl/fips/0.9.8/bin/openssl 1>/dev/null 2>/dev/null
#chown bin:bin /opt/openssl/fips/0.9.8/bin/openssl 1>/dev/null 2>/dev/null


# Following is for fips 0.97j openssl fipsld
#cd /opt/openssl/fips/0.9.7/bin
#mv fipsld fipsld32
#cat fipsld32 | sed "s|/lib/fipscanister.o|/lib/pa20_64/fipscanister.o|g"|sed "s|/lib/fips_premain.c|/lib/pa20_64/fips_premain.c|g" > fipsld64
#chmod 555 fipsld64
#chown bin:bin fipsld64
#cd -

# Following is for fips 0.98f openssl fipsld
#cd /opt/openssl/fips/0.9.8/bin
#mv fipsld fipsld32
#cat fipsld32 | sed "s|/lib/fipscanister.o|/lib/pa20_64/fipscanister.o|g" > fipsld64
#chmod 555 fipsld64
#chown bin:bin fipsld64
#cd -  

#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/fips/${DEFAULT_VERSION}         1>/dev/null 2>/dev/null
chown bin:bin /opt/openssl/fips/${DEFAULT_VERSION}     1>/dev/null 2>/dev/null
chmod 555 /opt/openssl/fips/${DEFAULT_VERSION}/bin     1>/dev/null 2>/dev/null
chown bin:bin /opt/openssl/fips/${DEFAULT_VERSION}/bin 1>/dev/null 2>/dev/null

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