File: //usr/openv/netbackup/bin/db2_config
#!/bin/sh
# $Id$
#***************************************************************************
# $Copyright: Copyright (c) 2016 Veritas Technologies LLC. All rights reserved VT25-0977-2658-84-51-3 $
#***************************************************************************
#
# The following variable is changed by the Makefile to a valid value.
#
MACHINE=linuxR_x86_2.6.18
# Intentionally set TMPDIR to /tmp.
TMPDIR=/tmp
BP_BIN=/usr/openv/netbackup/bin
DB_EXT=/usr/openv/netbackup/ext/db_ext
Q1="Please specify the DB2 instance home path name:"
USAGE ()
{
echo ""
echo "USAGE:"
echo " $0"
exit 22
}
trap trapped 1 2 3 15
trapped ()
{
rm -f ${Q1_ANSW} ${Q1_ANSW}.error
exit 1
}
#
# This function takes a string as input and echos it out
# as a question with a prompt for an answer. Any answer
# not beginning with y or Y is considered a no.
#
confirm ()
{
echo "${1} (y/n) [n] "
read ans
case "${ans}" in
Y*|y*)
echo
return 1
;;
*)
echo
return 0
;;
esac
}
#
# Make sure this is being run from root.
#
ISROOT=`id | egrep "^uid=0\("`
if [ "${ISROOT}" = "" ] ; then
echo ""
echo "$0 must be run while logged in as root."
echo ""
exit 1
fi
is_64_bit=0
if [ $# -ne 0 ] ; then
USAGE
fi
Q1_ANSW=${TMPDIR}/DB2_Q1.$$
rm -f ${Q1_ANSW}
REAL_BIN_NAME=db2uext2
if [ "${MACHINE}" = "linuxR_x86_2.6.18" -o \
"${MACHINE}" = "linuxS_x86_3.0.76" -o "${MACHINE}" = "rs6000_61" -o \
"${MACHINE}" = "solaris10" ] ; then
DB2_64_BIN=db2uext2.64
else
DB2_64_BIN=db2uext2
fi
if [ ! -f ${BP_BIN}/${DB2_64_BIN} ] ; then
echo ""
echo "ERROR: ${BP_BIN}/${DB2_64_BIN} was not found."
echo "ERROR: The DB2 agent software has not been installed."
echo ""
trapped
fi
done=0
echo ""
DB2_INST=""
while [ ${done} -ne 1 ] ; do
echo ${Q1}
read DB2_INST
if [ ! -d "${DB2_INST}" ] ; then
echo ""
echo "Directory \"${DB2_INST}\" does not exist."
echo "If this DB2 installation is part of a cluster and"
echo "this node is inactive, this message may safely be"
echo "ignored. Otherwise, check to see if DB2 has been"
echo "installed in \"${DB2_INST}\"."
echo ""
if confirm "Do you want to exit this script?"
then
:
else
trapped
fi
else
echo ${DB2_INST} >> ${Q1_ANSW}
echo ""
if confirm "Do you have other DB2 instances?"
then
done=1
fi
fi
done
#
# Protect the value of INST with double quotes in case there is
# a blank in the directory name.
#
while read INST
do
if [ ! -d "${INST}"/sqllib -o ! -d "${INST}"/sqllib/adm ] ; then
echo ""
echo "INSTALLATION WARNING:"
echo "Directory ${INST}/sqllib or ${INST}/sqllib/adm does not exist."
echo "If this DB2 installation is part of a cluster and"
echo "this node is inactive, this warning may safely be"
echo "ignored. Otherwise, check to see if DB2 has been"
echo "installed in ${INST}."
echo ""
else
#
# Do some extra checks for the 32bit/64bit scenario.
# Only 64bit is supported for DB2.
#
if [ "${MACHINE}" = "rs6000_61" ] ; then
/usr/bin/ls -l /unix | grep unix_64 > /dev/null 2>&1
if [ $? -eq 0 ] ; then
is_64_bit=1
fi
cut_string="-f2"
elif [ "${MACHINE}" = "solaris10" -o \
"${MACHINE}" = "solaris_x86_10_64" ] ; then
os_bits=`isainfo -nv`
echo ${os_bits} | grep "64\-bit" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
is_64_bit=1
fi
cut_string="-f1,2"
elif [ "${MACHINE}" = "linuxR_x86_2.6.18" -o \
"${MACHINE}" = "linuxS_x86_3.0.76" ] ; then
os_bits=`uname -p`
if [ "${os_bits}" = "x86_64" ] ; then
is_64_bit=1
fi
cut_string="-f3"
fi
if [ ${is_64_bit} -eq 1 ] ; then
if [ "${MACHINE}" = "linuxR_x86_2.6.18" -o \
"${MACHINE}" = "linuxS_x86_3.0.76" ] ; then
we_64_type=64
else
we_64_type=`file ${BP_BIN}/${DB2_64_BIN} | cut ${cut_string} -d" " | cut -f2 -d":"`
fi
if [ ! -f "${INST}"/sqllib/bin/db2 ] ; then
echo ""
echo "INSTALLATION WARNING:"
echo "File ${INST}/sqllib/bin/db2 does not exist."
echo "Cannot determine its binary type. Assuming it"
echo "is the same as ${BP_BIN}/${DB2_64_BIN}."
they_type="${we_64_type}"
else
if [ "${MACHINE}" = "linuxR_x86_2.6.18" -o \
"${MACHINE}" = "linuxS_x86_3.0.76" ] ; then
they_type=`file ${INST}/sqllib/bin/db2 | cut ${cut_string} -d" " | cut -f1 -d"-"`
else
they_type=`file ${INST}/sqllib/bin/db2 | cut ${cut_string} -d" " | cut -f2 -d":"`
fi
fi
if [ "${we_64_type}" = "${they_type}" ] ; then
which_bin=${DB2_64_BIN}
else
echo ""
echo "INSTALLATION ERROR:"
echo "The file type for ${INST}/sqllib/bin/db2 does not"
echo "match ${BP_BIN}/${DB2_64_BIN}."
echo ""
trapped
fi
else
# The machines that never had two versions of db2 (HP Itanium
# etc) will have DB2_64_BIN set to db2uext2. Display an
# error if not on one of those platforms and is_64_bit is not
# set.
if [ "${DB2_64_BIN}" != "db2uext2" ] ; then
echo ""
echo "INSTALLATION ERROR:"
echo "NetBackup for DB2 is not supported on 32 bit machines."
echo ""
trapped
else
which_bin=${DB2_64_BIN}
fi
fi
if ls -ld "${INST}"/sqllib/adm/${REAL_BIN_NAME} 2>/dev/null | grep "^l" > /dev/null
then
rm -f "${INST}"/sqllib/adm/${REAL_BIN_NAME}
elif [ -f "${INST}"/sqllib/adm/${REAL_BIN_NAME} ] ; then
rm -f "${INST}"/sqllib/adm/${REAL_BIN_NAME}.org
mv "${INST}"/sqllib/adm/${REAL_BIN_NAME} "${INST}"/sqllib/adm/${REAL_BIN_NAME}.org
fi
echo ""
echo "Linking ${INST}/sqllib/adm/${REAL_BIN_NAME} to ${BP_BIN}/${which_bin}."
/bin/ln -s ${BP_BIN}/${which_bin} "${INST}"/sqllib/adm/${REAL_BIN_NAME}
if [ ! -f "${INST}"/db2.conf ] ; then
echo ""
echo "Copying ${DB_EXT}/db2/scripts/db2.conf to ${INST}/db2.conf."
/bin/cp ${DB_EXT}/db2/scripts/db2.conf "${INST}"/db2.conf
fi
/bin/chmod 666 "${INST}"/db2.conf
fi
done < ${Q1_ANSW}
#
# Hitting trapped in the previous while doesn't actually exit this script
# on some platforms so check here if last command executed was ok. If I
# hit the trap in the while, I'll trap again and properly exit with a 1.
#
if [ $? -eq 0 -a ! -f ${Q1_ANSW}.error ] ; then
#
# Try to clean up an old directory and file.
#
if [ -d /usr/openv/netbackup/dbext/comm ] ; then
rmdir /usr/openv/netbackup/dbext/comm > /dev/null 2>&1
fi
rm -f ${BP_BIN}/install_db2
rm -f ${Q1_ANSW}
exit 0
else
trapped
fi