#!/bin/sh # $Id: sybase_config.sh,v 1.35 2012/03/28 19:01:45 $ #*************************************************************************** #* $VRTScprght: Copyright 2014 Symantec Corporation, All Rights Reserved $ * #*************************************************************************** # # The following variable is changed by the Makefile to a valid value. # MACHINE=solaris_x86_10_64 # 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 Sybase 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] \c " 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}/SYBASE_Q1.$$ rm -f ${Q1_ANSW} done=0 echo "" SYB_INST="" while [ ${done} -ne 1 ] ; do echo ${Q1} read SYB_INST if [ ! -d "${SYB_INST}" ] ; then echo "" echo "Directory \"${SYB_INST}\" does not exist." echo "If this Sybase installation is part of a cluster and" echo "this node is inactive, this message may safely be" echo "ignored. Otherwise, check to see if Sybase has been" echo "installed in \"${SYB_INST}\"." echo "" if confirm "Do you want to exit this script?" then : else trapped fi else echo ${SYB_INST} >> ${Q1_ANSW} echo "" if confirm "Do you have other Sybase instances?" then done=1 fi fi done case "${MACHINE}" in hp11.11) SYB_32_API=libsybackup.sl SYB_64_API=libsybackup64.sl ;; plinuxR_2.6 | plinuxS_2.6) SYB_32_API=libsybackup32.so ;; hpia11.31) SYB_32_API=libsybackup32.so SYB_64_API=libsybackup.so ;; rs6000_61) SYB_32_API=libsybackup.sl ;; linuxR_x86_2.6.18 | linuxS_x86_2.6.16 | solaris10) SYB_32_API=libsybackup.so SYB_64_API=libsybackup64.so ;; solaris_x86_10_64) SYB_64_API=libsybackup.so ;; esac if [ "${MACHINE}" = "solaris_x86_10_64" ] ; then if [ ! -f ${BP_BIN}/${SYB_64_API} ] ; then echo "" echo "ERROR: ${BP_BIN}/${SYB_64_API} was not found." echo "ERROR: The Sybase agent software has not been installed." echo "" trapped fi elif [ ! -f ${BP_BIN}/${SYB_32_API} ] ; then echo "" echo "ERROR: ${BP_BIN}/${SYB_32_API} was not found." echo "ERROR: The Sybase agent software has not been installed." echo "" trapped fi # # Protect the value of INST with double quotes in case there is # a blank in the directory name. Now that we check for several flavors # of Sybase, when multiple INST locations are specified, it gets hard # to read when there are warnings and/or errors. Use "===" lines to # define an INST section and display which INST we're looking at. # while read INST do echo "========================================================================" echo "Examining ${INST}:" installed=0 # # First, let's figure out if we're on a 64 bit machine. # if [ "${MACHINE}" = "hp11.11" -o "${MACHINE}" = "hpia11.31" ] ; then os_bits=`getconf _CS_KERNEL_BITS` if [ "${os_bits}" = "64" ] ; then is_64_bit=1 fi cut_string="-f1" elif [ "${MACHINE}" = "linuxR_x86_2.6.18" -o "${MACHINE}" = "linuxS_x86_2.6.16" ] ; then os_bits=`uname -p` if [ "${os_bits}" = "x86_64" ] ; then is_64_bit=1 fi cut_string="-f3" 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" fi # # Next, let's figure out what kind of Sybase vendor binaries # are out there. File SYBASE.csh or SYBASE.sh in INST is an # indication of Sybase 12. A directory named asiq12 in INST # is an indication of Sybase IQ. Neither of those indicates # Sybase 11. All three could potentially be in the same # INST location. Sybase 11 is 32 bit only. Sybase IQ is # not supported. Later versions of Sybase 12 # support 64 bit. # for ase_type in ase11 ase12 iq do found=0 value="" bin_to_check=sybmultbuf vendor_api=${SYB_32_API} if [ "${ase_type}" = "ase11" -a -f "${INST}"/bin/${bin_to_check} ] ; then found=1 elif [ "${ase_type}" = "ase12" ] ; then if [ -f "${INST}"/SYBASE.csh ] ; then value=`grep "setenv SYBASE_ASE" "${INST}"/SYBASE.csh | cut -f3 -d" " | sort -u | head -1` elif [ -f "${INST}"/SYBASE.sh ] ; then value=`grep "SYBASE_ASE=" "${INST}"/SYBASE.sh | cut -f2 -d"=" | sort -u | head -1` fi if [ "${value}" != "" -a -f "${INST}"/${value}/bin/${bin_to_check} ] ; then found=1 fi elif [ "${ase_type}" = "iq" -a -d "${INST}"/asiq12 ] ; then echo "" echo "INSTALLATION WARNING:" echo "Found Sybase IQ in ${INST}. This is not supported." fi if [ ${found} -eq 1 ] ; then # # Make sure the vendor lib directory is present before # we go too far since we'll be linking there. # dir="${value}" if [ ! -d "${INST}"/${dir}/lib ] ; then echo "" echo "INSTALLATION WARNING:" echo "Directory ${INST}/${dir}/lib does not exist." echo "If this Sybase installation is part of a cluster and" echo "this node is inactive, this warning may safely be" echo "ignored. Otherwise, check to see if Sybase has been" echo "installed in ${INST}." else # # Do some extra checks for the 32bit/64bit scenario. # Try not to link incorrect types together. We know # the vendor file we want exists since we checked already. # The rules are: If vendor binary is 32 bit, iq is not # allowed except for HP and solaris. If vendor binary # is 64 bit, ase11 is not allowed. # do_the_link=0 if [ ${is_64_bit} -eq 1 ] ; then we_32_type=`file ${BP_BIN}/${SYB_32_API} | cut -f2 -d":" | cut ${cut_string} -d" "` we_64_type=`file ${BP_BIN}/${SYB_64_API} | cut -f2 -d":" | cut ${cut_string} -d" "` # # For HP, a vendor 32 bit binary could have a file type # of s800 or PA-RISC1.1 so map s800 to the type of # our 32 bit library, which is PA-RISC1.1 (starting with 5.0). # CAREFUL: there's some tabs hiding in a couple of these lines. # if [ "${MACHINE}" = "hp11.11" ] ; then syb_type=`file "${INST}"/${dir}/bin/${bin_to_check} | cut -f2 -d":" | cut ${cut_string} -d" "` if [ "${syb_type}" = " s800" ] ; then they_type=" PA-RISC1.1" else they_type="${syb_type}" fi else they_type=`file "${INST}"/${dir}/bin/${bin_to_check} | cut -f2 -d":" | cut ${cut_string} -d" "` fi if [ "${we_64_type}" = "${they_type}" ] ; then if [ "${ase_type}" != "ase11" ] ; then our_api=${SYB_64_API} do_the_link=1 else echo "" echo "INSTALLATION WARNING:" echo "Found 64 bit mode Sybase ASE in ${INST}. This is not" echo "supported." fi elif [ "${we_32_type}" = "${they_type}" ] ; then our_api=${SYB_32_API} do_the_link=1 else echo "" echo "INSTALLATION ERROR:" echo "The file type for ${INST}/${dir}/bin/${bin_to_check} does not" echo "match ${BP_BIN}/${SYB_32_API} or" echo "${BP_BIN}/${SYB_64_API}." touch ${Q1_ANSW}.error fi else our_api=${SYB_32_API} do_the_link=1 fi # On power PC the libsybackup library hase been renamed to # to libsybackup32. As a result we need to change the # vendor_api to libsybackup to avoid linking problems. if [ "${MACHINE}" = "plinuxR_2.6" -o "${MACHINE}" = "plinuxS_2.6" -o "${MACHINE}" = "hpia11.31" ] ; then vendor_api=libsybackup.so fi # # Only if all checks have passed do we do the linking # from our library to the name the Sybase product # expects. Clean up possible old file name from 3.4 # (libsybackup.s?64). # if [ ${do_the_link} -eq 1 ] ; then rm -f ${BP_BIN}/libsybackup.s?64 if ls -ld "${INST}"/${dir}/lib/${vendor_api} 2>/dev/null | grep "^l" > /dev/null then rm -f "${INST}"/${dir}/lib/${vendor_api} elif [ -f "${INST}"/${dir}/lib/${vendor_api} ] ; then rm -f "${INST}"/${dir}/lib/${vendor_api}.org mv "${INST}"/${dir}/lib/${vendor_api} "${INST}"/${dir}/lib/${vendor_api}.org fi echo "" echo "Linking ${INST}/${dir}/lib/${vendor_api} to ${BP_BIN}/${our_api}." /bin/ln -s ${BP_BIN}/${our_api} "${INST}"/${dir}/lib/${vendor_api} # Sybase ASE 12.5.3 on AIX now requires that libsybackup have a .so # suffix. To get around this problem, we will now create two symbolic # links on AIX. One link with a .so suffix and the other with a .sl # suffix. if [ "${MACHINE}" = "rs6000_61" ] ; then vendor_api=libsybackup.so if ls -ld "${INST}"/${dir}/lib/${vendor_api} 2>/dev/null | grep "^l" > /dev/null then rm -f "${INST}"/${dir}/lib/${vendor_api} elif [ -f "${INST}"/${dir}/lib/${vendor_api} ] ; then rm -f "${INST}"/${dir}/lib/${vendor_api}.org mv "${INST}"/${dir}/lib/${vendor_api} "${INST}"/${dir}/lib/${vendor_api}.org fi echo "" echo "Linking ${INST}/${dir}/lib/${vendor_api} to ${BP_BIN}/${our_api}." /bin/ln -s ${BP_BIN}/${our_api} "${INST}"/${dir}/lib/${vendor_api} fi installed=1 fi fi fi done # # We've checked all possible sybase types for this INST. If # we've had an error, the *.error file will exist so don't # issue another message. However, if we've only had warnings # but nothing was installed, issue an error message here. # if [ ${installed} -ne 1 ] ; then echo "" echo "INSTALLATION WARNING:" echo "If this Sybase installation is part of a cluster and" echo "this node is inactive, this warning may safely be" echo "ignored. Otherwise, check to see if Sybase has been" echo "installed in ${INST}." fi echo "========================================================================" done < ${Q1_ANSW} # # If the *.error file exists, we've had a problem for some flavor # of Sybase in one or more INST dirctories. Don't finish. # if [ ! -f ${Q1_ANSW}.error ] ; then # # Try to clean up an old directory and file. # if [ -d ${DB_EXT}/sybase/syb_db_comm ] ; then rmdir ${DB_EXT}/sybase/syb_db_comm > /dev/null 2>&1 fi rm -f ${BP_BIN}/install_sybackup rm -f ${Q1_ANSW} exit 0 else echo "" echo "One or more installation errors have occurred. Installation is not" echo "complete." trapped fi