#!/sbin/sh
####################################
#  Product: OpenSSL
#  Fileset: Latest
#  preinstall
#  (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
####################################
# Setup config 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
#rm -f /usr/bin/openssl_fips_fingerprint 1>/dev/null 2>/dev/null
#rm -f /usr/bin/fipsld 1>/dev/null 2>/dev/null

bin_dirs_list="/opt/openssl/fips/0.9.8/bin"
DUAL_VERSION=0

for bin_dir in $bin_dirs_list
do
  if [[ -d $bin_dir ]]
  then
    DUAL_VERSION=1
    for list in `ls $bin_dir`
    do
	echo ${bin_dir}/{$list}
      rm -f ${bin_dir}/{$list} 1>/dev/null 2>/dev/null
      if [ $? -ne 0 ]
      then
        mv ${bin_dir}/{$list} ${bin_dir}/#{$list} 1>/dev/null 2>/dev/null
        echo "${bin_dir}/\#${list}" >> /var/adm/sw/cleanupfile
      fi
    done
  fi
done

#if [[ -d /opt/openssl/fips/bin ]]
#then
#  for list in `ls /opt/openssl/fips/bin`
#  do
#    rm -f /opt/openssl/fips/bin/${list} 1>/dev/null 2>/dev/null
#    if [ $? -ne 0 ]
#    then
#      mv /opt/openssl/fips/bin/${list} /opt/openssl/0.9.7/bin/#${list}_fips 1>/dev/null 2>/dev/null
#      echo "/opt/openssl/0.9.7/bin/#${list}_fips" >> /var/adm/sw/cleanupfile
#    fi
#  done
#  rm -rf /opt/openssl/fips/bin 1>/dev/null 2>/dev/null
#  rm -f /opt/openssl/fips/openssl.cnf 1>/dev/null 2>/dev/null
#fi

#if [ $DUAL_VERSION -eq 0 ]
#then
#  if [[ -d /opt/openssl/fips/bin ]]
#  then
#    for list in `ls /opt/openssl/fips/bin`
#    do
#      rm -f /opt/openssl/fips/bin/$list 1>/dev/null 2>/dev/null
#      if [ $? -ne 0 ]
#      then
#        if [[ ! -d /opt/openssl/fips/${DEFAULT_VERSION}/bin ]]
#        then
#          mkdir -p /opt/openssl/fips/${DEFAULT_VERSION}/bin 1>/dev/null 2>/dev/null
#          chown 555 /opt/openssl/fips/${DEFAULT_VERSION}/bin 1>/dev/null 2>/dev/null
#          chmod bin:bin /opt/openssl/fips/${DEFAULT_VERSION}/bin 1>/dev/null 2>/dev/null
#        fi
#        mv /opt/openssl/fips/bin/$list /opt/openssl/fips/${DEFAULT_VERSION}/bin/#${list} 1>/dev/null 2>/dev/null
#        echo "/opt/openssl/fips/${DEFAULT_VERSION}/bin/\#${list}" >> /var/adm/sw/cleanupfile
#      fi
#    done
#  fi
#fi

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

