#!/bin/bash
. /usr/share/preupgrade/common.sh

#END GENERATED SECTION
if [ -z $SOLUTION_FILE ]; then
  SOLUTION_FILE="./solution.txt"
fi
cat /dev/null > $SOLUTION_FILE
confile='/etc/openldap/slapd.conf'
confdir='/etc/openldap/'
cust_confile='<your_configuration_file>'
cp --parents -ar $confdir $VALUE_TMP_PREUPGRADE/dirtyconf/


if ! [ -e "$confile" ];then
   echo " The $confile configuration file does not exist. If you have the slapd configuration file in an alternative location, type 
the following command to test its consistency:
slaptest -v -f $cust_confile" >> $SOLUTION_FILE
   echo "It is recommended to use a new directory format of the slapd configuration in Red Hat Enterprise Linux 7. If you want to migrate your slapd configuration to the new format, type:
slaptest -f $cust_confile -F $confdir
chown -R ldap:ldap $confdir " >> $SOLUTION_FILE
   log_medium_risk "A directory format is recommended for the slapd configuration."
   exit_fail
else
   echo "It is recommended to use a new directory format of the slapd configuration in Red Hat Enterprise Linux 7. If you want to migrate your slapd configuration to the new format, type:
slaptest -f $confile -F $confdir
chown -R ldap:ldap $confdir " >> $SOLUTION_FILE
  slaptest -v -f "$confile" 2>&1 | grep "database ldbm" > /dev/null
   if [[ "$?" -eq 0 ]];then

      echo "Change the database directive in the $confile file to 'bdb'." >> $SOLUTION_FILE
      log_high_risk "The back-ldbm database back end is obsolete. Do not use it."
      exit_fail
   else
      log_medium_risk "A directory format is recommended for the slapd configuration."
      exit_fail
   fi
fi
