#!/sbin/sh
########################################
#  Product: HPUXOpenSSL
#  Fileset: Latest
#  configure 
#  (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
####################################
# Add config files
####################################

DEFAULT_VERSION="0.9.8"

#newconfig_cp /opt/openssl/0.9.8/openssl.cnf
#newconfig_msgs $?
#newconfig_cp /opt/openssl/0.9.7/openssl.cnf
#newconfig_msgs $?
#newconfig_cp /opt/openssl/fips/0.9.8/openssl.cnf
#newconfig_msgs $?
#newconfig_cp /opt/openssl/fips/0.9.7/openssl.cnf
#newconfig_msgs $?

#if [ ! -f /opt/openssl/openssl.cnf ]
#then
#	cd /opt/openssl; 
#	ln -sf ${DEFAULT_VERSION}/openssl.cnf openssl.cnf; 
#	cd - 1>/dev/null 2>/dev/null
#fi

#if [ ! -f /opt/openssl/fips/openssl.cnf ]
#then
#	cd /opt/openssl/fips; 
#	ln -sf ${DEFAULT_VERSION}/openssl.cnf openssl.cnf; 
#	cd - 1>/dev/null 2>/dev/null
#fi

####################################
# Print a note if a process has
# either of the openssl libraries loaded
####################################

# List the shared librariy names
#if [ -d /opt/openssl/fips/0.9.7/lib ]
#then
#	lib_list=`find /opt/openssl/fips/0.9.7/lib -name "#lib*"`
#fi


# List the Command line tool
#cmd_line_tool=`ls /opt/openssl/fips/0.9.7/bin/#openssl  2>/dev/null`

#for files in ${lib_list} ${cmd_line_tool}
#do
#	process_ids=`fuser ${files} 2>/dev/null`
#	if [ "$process_ids" != "" ]
#	then
#		echo "\nNOTE:    Processes ${process_ids}"
#		echo "         are currently using the library/binary ${files}."
#		echo "         A new version of this library has been installed."
#		echo "         To use the new version, you must stop and restart the process."
#	fi
#done

if [ ! -d /opt/openssl/fips/0.9.8/old ]; then
    exit $exitval
fi

used_files1=`find /opt/openssl/fips/0.9.8/old -name "#*"`
used_files2=`find /opt/openssl/fips/0.9.8/old -name "lib*" -a -type f`
used_files3=`find /opt/openssl/fips/0.9.8/old -name "openssl" -a -type f`
used_files4=`find /opt/openssl/fips/0.9.8/old -name "openssl.fipsonly" -a -type f`

for files in $used_files1 $used_files2 $used_files3 $used_files4
do
        process_ids=`fuser ${files} 2>/dev/null`
	if [ "$process_ids" != "" ]
	then
		echo "\nNOTE:    Processes ${process_ids}"
		echo "         are currently using the library/binary ${files}."
		echo "         A new version of this library has been installed."
		echo "         To use the new version, you must stop and restart the process."
	fi
done 

####################################
# Remove fips based directory
####################################
#if [[ -d /opt/openssl/fips ]]
#then
#	rm -rf /opt/openssl/fips 1>/dev/null 2>/dev/null
#	echo "\n\nNOTE:    OpenSSL A.00.09.07l does not support FIPS 140-2"
#	echo "         compliant OpenSSL.  Any programs using OpenSSL FIPS"
#	echo "         binaries from older versions will fail when restarted."
#fi

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