#!/bin/sh ############################################################################# # # Licensed Materials - Property of IBM # # (C) COPYRIGHT International Business Machines Corp. 2011 # # All Rights Reserved. # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # ############################################################################# # # NAME: db2chktsa # # FUNCTION: db2chktsa - internal tool to check the information of # IBM Tivoli System Automation for Multiplatforms # Base Component (SA MP Base Component) (TSAMP). # # USAGE: db2chktsa [-h|-?] [-d] [-c | -m | -i ] # -h|-? display the usage information. # -d turn debug mode on. # -c check if media has SA MP Base Component and its prerequisites are met # -i # check if the passed SA MP Base Component license can be installed # -m check if media has try-and-buy license and system has permanent license # # RETURN CODE: # # [ neither -m nor -c nor -i is given ] # # 0 : There is no TSAMP installed but TSAMP is on DB2 media; # 1 : TSAMP is installed and on DB2 media. The installed TSAMP # has no peer domain and needs update; # 2 : TSAMP is installed and on DB2 media. The installed TSAMP # has peer domain and needs update; # 3 : TSAMP is installed and on DB2 media. The installed TSAMP has # no peer domain and needs migration; # 7 : TSAMP is neither installed nor on DB2 media; # 8 : TSAMP is installed but not on DB2 media; # 9 : TSAMP is installed and on DB2 media. However, the installed TSAMP # can not be migrated nor updated; # 10 : TSAMP is installed and on DB2 media. The installed TSAMP has peer # domain and needs migration; # 11 : TSAMP is installed and on DB2 media. Installed TSAMP is at # level not lower than the TSAMP on DB2 media; # 12 : TSAMP is installed and the tool is called from DB2 installation path; # # [ -c ] # # 4 : TSAMP is not on DB2 media; # 5 : TSAMP is on DB2 media and its prerequistes are met; # 6 : TSAMP is on DB2 media and its prerequistes are not met; # # [ -i ] # # 13 : The passed TSAMP license needs to be installed with samlicm; # 14 : The passed TSAMP license does not need to be installed with samlicm; # other : internal tool error. # # [ -m ] # # 22 : TSAMP is installed on the system with a permanent license AND the # TSAMP on the media has a try-and-buy license; # 23 : All other cases # ######################################################################## # Options for "set" command setopts="${setopts:-+x}" set ${setopts?} curdir=`/bin/pwd` PROGDIR=`dirname $0` cd ${PROGDIR?} PROGDIR=`/bin/pwd` PROGNAME=`basename $0` TRUE=0 FALSE=1 export TRUE FALSE DEBUG=${DEBUG:-${FALSE?}} # To display a message when a function is called trac () { if [ ${DEBUG?} -eq ${TRUE?} ]; then echo "## call function $@" fi } # To display a message when exiting a function trax () { if [ ${DEBUG?} -eq ${TRUE?} ]; then echo "## exit function $1" fi } defaultopts () { func_name="defaultopts" trac ${func_name?} $@ set ${setopts?} TRUE=0 FALSE=1 db2chktsa_rc=99 INTERNAL_ERR=${db2chktsa_rc?} DEBUG=${FALSE?} C_OPTION=${FALSE?} I_OPTION=${FALSE?} M_OPTION=${FALSE?} TSAMP_VERSION_SYS="" TSAMP_VERSION="" SAMLIC_FILE="" NO_ACTION=0 UPDATE_ACTION=1 UPGRADE_ACTION=2 TMPDIR=${DB2TMPDIR:-/tmp} LOGFILE=${TMPDIR?}/prereqSAM.log.$$ #default if [ -f ${LOGFILE?} ]; then rm -f ${LOGFILE?} fi DB2CHKTSA_DIR="${PROGDIR?}" DB2CHKTSA="${DB2CHKTSA_DIR?}/db2chktsa" if [ -f "${DB2CHKTSA_DIR?}/../db2ls" -a -d "${DB2CHKTSA_DIR?}/../../.metadata" ]; then BINDIR="${DB2CHKTSA_DIR?}/../../bin" LOCALE_DIR="${DB2CHKTSA_DIR?}/../../msg" DISP_MSG_DIR="${DB2CHKTSA_DIR?}/../../instance" else BINDIR="${DB2CHKTSA_DIR?}/../bin" LOCALE_DIR="${DB2CHKTSA_DIR?}/locale" DISP_MSG_DIR="${BINDIR?}" fi CMD_DB2LANGDIR=${BINDIR?}/db2langdir PATH=".:"${PATH} export PATH LIBPATH_ORG=${LIBPATH} LIBPATH=.:${LIBPATH} export LIBPATH LD_LIBRARY_PATH_ORG=${LD_LIBRARY_PATH} LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH SHLIB_PATH_ORG=${SHLIB_PATH} SHLIB_PATH=.:${SHLIB_PATH} export SHLIB_PATH LANG_ORG=${LANG} export LANG_ORG set_lang trax ${func_name?} } syntax () { func_name="syntax" trac ${func_name?} $@ set ${setopts?} echo "USAGE: db2chktsa [-h|-?] [-d] [-c | -i ] [-m] -h|-? display the usage information. -d turn debug mode on. -c check if SA MP Base Component is on DB2 media and if its prerequistes for installation are met -i check if the provided license file is valid for the current DB2 on media or in the related install path and if the system has the SA MP Base Component installed which needs to be updated to use the passed license. -m checks if the SAMP installed on the system has a permanent license AND if the one in the media has a Try And Buy license. Needed for LI24722 in Cobra. NOTE: The -c and -i and -m options can not be used together. " trax ${func_name?} exit ${INTERNAL_ERR?} } #---------------------------------------------------------------- # Name - comp_version # Function - Compare the passed two versions # Parameters - $1 : the version one; # $2 : the version two; # $3 : the delimiter (one char) used to split the version number. # This is optional. If not given, '.' will be used. # Returns - 0 : equals to # 1 : is smaller than # 2 : is greater than # # NOTE: if two versions do not have the same number of version information, # the shorter one will have 0 appended. For instance, 2.2 and 2.2.1.0 # are passed, the 2.2 will be changed to 2.2.0.0 and then used for # comparison. #---------------------------------------------------------------- comp_version () { setopts="${setopts:-+x}" func_name="comp_version" trac ${func_name?} $@ set ${setopts?} comp_version_rc=-1 comp_version_flip=1 if [ $# -lt 2 ] then echo "Usage: comp_version [] " trax ${func_name?} exit 67 fi version1=$1 version2=$2 splitter=$3 if [ "X${splitter?}" = "X" ]; then splitter="." else splitter_count=`echo ${splitter?} | wc -c` if [ ${splitter_count?} -gt 2 -o ${splitter_count?} -lt 2 ] then echo "You used the delimiter ${splitter?} with more than one character." trax ${func_name?} exit 67 fi fi if [ `echo ${version1?} | awk '{print NF}' FS=${splitter?} OFS=${splitter?}` -lt \ `echo ${version2?} | awk '{print NF}' FS=${splitter?} OFS=${splitter?}` ] then version1_tmp=${version1?} version1=${version2} version2=${version1_tmp?} comp_version_flip=0 unset version1_tmp fi while [ -n "${version1?}" -a ${comp_version_rc?} -eq -1 ] do version1_tmp=`echo ${version1?} | awk '{ print $1 }' FS=${splitter?}` version2_tmp=`echo ${version2?} | awk '{ print $1 }' FS=${splitter?}` version1=`echo ${version1?} | awk '{ for(i=2;i<=NF;++i) {printf "%s",$i; if (i" trax ${func_name?} exit 67 fi var_string=$1 if [ `expr "${var_string?}" + 0 2> /dev/null` -eq "${var_string?}" 2>/dev/null ]; then is_int_rc=0 else is_int_rc=1 fi trax ${func_name?} return ${is_int_rc?} } #---------------------------------------------------------------- # Name - validate_version # Function - Check if the version string only contains digits # # Parameters - $1 : version string to check # $2 : (optional) the delimiter char for the string # Returns - 0 : version string only contains delimiter and digits # 1 : otherwise #---------------------------------------------------------------- validate_version () { func_name="validate_version" trac ${func_name?} $@ set ${setopts?} TRUE="${TRUE:-0}" FALSE="${FALSE:-1}" INTERNAL_ERR="${INTERNAL_ERR:-99}" if [ $# -lt 1 ] then echo "Usage: validate_version " trax ${func_name?} exit ${INTERNAL_ERR?} fi val_version=$1 val_splitter=$2 var_rc=-1 if [ "X${val_splitter?}" = "X" ]; then val_splitter="." else val_splitter_count=`echo ${val_splitter?} | wc -c` if [ ${val_splitter_count?} -gt 2 -o ${val_splitter_count?} -lt 2 ] then echo "You used the delimiter ${val_splitter?} with more than one character." trax ${func_name?} exit ${INTERNAL_ERR?} fi fi while [ -n "${val_version?}" -a ${var_rc?} -eq -1 ] do val_version_tmp=`echo ${val_version?} | awk '{ print $1 }' FS=${val_splitter?}` val_version=`echo ${val_version?} | awk '{ for(i=2;i<=NF;++i) {printf "%s",$i; \ if (i/dev/null 1>/dev/null if [ $? -eq ${TRUE?} ]; then tsa_version_sys=`rpm -q sam | cut -d- -f2` if [ $? -ne ${TRUE?} ]; then echo "ERROR: Could not find the version string for installed sam or sam.core.rte fileset." trax ${func_name?} exit ${INTERNAL_ERR?} fi validate_version ${tsa_version_sys?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: The version string ${tsa_version_sys?} for sam or sam.core.rte \ fileset contains non-digits besides delimiter." trax ${func_name?} exit ${INTERNAL_ERR?} else TSAMP_VERSION_SYS=${tsa_version_sys?} trax ${func_name?} return ${TRUE?} fi else trax ${func_name?} return ${FALSE?} fi } set_lang_internal () { set ${setopts?} bindir="$1" msgdir="$2" lang="$3" CMD_DB2LANGDIR="${bindir?}/db2langdir" if [ "X$lang" != "X" ]; then LANG_CUSTOM=0 else LANG_CUSTOM=1 fi # Default locale name and locale-specific message directory LANG=${LANG:-C} locname=${LANG?} if [ ${LANG_CUSTOM?} -eq 0 ]; then locname=`${CMD_DB2LANGDIR?} ${lang?} -locale` DB2_LANG_JAVA=${locname?} fi langdir=`${CMD_DB2LANGDIR?} ${locname?}` clangdir=`${CMD_DB2LANGDIR?} C` if [ -f ${msgdir?}/${langdir?}/db2install.cat ]; then DB2CAT="${msgdir?}/${langdir?}/db2install.cat" LANGUAGEDIR=${langdir?} elif [ -f ${msgdir?}/${clangdir?}/db2install.cat ]; then DB2CAT="${msgdir?}/${clangdir?}/db2install.cat" LANGUAGEDIR=${clangdir?} else echo "DBI1055E The message file db2install.cat cannot be found." echo echo "Explanation: The message file required by this" echo "script is missing from the system; it may have been" echo "deleted or the database products may have been loaded" echo "incorrectly." echo echo "User Response: Verify that the product option containing" echo "the message file is installed correctly. If there are" echo "verification errors; reinstall the product option." exit 67 fi # check if the locale exists. If not, we'll set LANG to C for any # subprocesses. locale -a 2> /dev/null | grep '^'${locname?}'$' > /dev/null if [ $? -ne 0 ] then locname=C fi # if a language was passed in, set LANG - but if not, leave it alone. # (if it isn't a valid language, well, try resetting anyway) if [ ${LANG_CUSTOM?} -eq 0 ] then locale -a 2> /dev/null | grep '^'${LANG:-C}'$' > /dev/null if [ $? -eq 0 ]; then LANG=${locname?} else # if locname is valid, set LANG to locname locale -a 2> /dev/null | grep '^'${locname:-C}'$' > /dev/null if [ $? -eq 0 ]; then LANG=${locname?} fi fi fi # Set LANG and NLSPATH variables for use by dspmsg command NLSPATH="${msgdir?}/%L/%N:${msgdir?}/${clangdir?}/%N" SHORTLANG=`${CMD_DB2LANGDIR?} ${LANG:-C} -short` export LANG NLSPATH } #----------------------------------------------------------------------- # Name - display_msg # Function - Displays a message from the message catalog # Parameters - $1 - name of the message catalog # - $2 - message number # - $3 - default message string # - $4,$5,$6 - arguments to substitute in msg string, if needed #----------------------------------------------------------------------- display_msg() { func_name="display_msg" trac ${func_name?} $@ set ${setopts?} unset catname msgid deftmsg msgstr catname="$1" msgid=$2 deftmsg="$3" shift;shift;shift msg_cmd="${DISP_MSG_DIR?}/disp_msg 1 ${msgid} ${catname}" ${msg_cmd?} "${deftmsg}" $@ trax ${func_name?} } set_lang () { func_name="set_lang" trac ${func_name?} $@ set ${setopts?} set_lang_internal ${BINDIR?} ${LOCALE_DIR?} $1 trax ${func_name?} } #---------------------------------------------------------------- # Name - chk_cmd_exist # Function - Checks the existence of a system command # # Parameters - $1 : command name # Returns - 0 : If the command exists or no command needs to be checked # 1 : otherwise #---------------------------------------------------------------- chk_cmd_exist() { func_name="chk_cmd_exist" trac ${func_name?} $@ set ${setopts?} cmd_to_check=$1 if [ "X${cmd_to_check?}" = "X" ]; then trax ${func_name?} return 0 fi which ${cmd_to_check?} > /dev/null 2> /dev/null if [ $? -ne 0 ] then trax ${func_name?} return ${FALSE?} else trax ${func_name?} return ${TRUE?} fi } #---------------------------------------------------------------- # Name - is_tool_in_db2dir # Function - Checks if the current tool is located in DB2DIR # # Parameters - none # Returns - 0 : The tool is in DB2DIR # non-zeor : otherwise #---------------------------------------------------------------- is_tool_in_db2dir () { func_name="is_tool_in_db2dir" trac ${func_name?} $@ set ${setopts?} if [ -f "${PROGDIR?}/../db2ls" -a -d "${PROGDIR?}/../../.metadata" -a ! -f "${PROGDIR?}/db2setup" ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_tsa_on_media # Function - Checks if there exists SA MP Base Component on media # # Parameters - none # Returns - 0 : The media has SA MP Base Component # non-zeor : otherwise #---------------------------------------------------------------- is_tsa_on_media () { func_name="is_tsa_on_media" trac ${func_name?} $@ set ${setopts?} is_tool_in_db2dir if [ $? -eq ${TRUE?} ]; then trax ${func_name?} return ${FALSE?} fi if [ -d "${PROGDIR?}/../tsamp" ]; then tsa_dir="${PROGDIR?}/../tsamp" ls ${tsa_dir?}/*/*/sam-* | cut -d- -f2 \ | grep '\.[0-9][0-9]*\.[0-9][0-9]*\.' 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then tsa_version=`ls ${tsa_dir?}/*/*/sam-* | cut -d- -f2 \ | grep '\.[0-9][0-9]*\.[0-9][0-9]*\.' | head -n 1` if [ $? -ne ${TRUE?} ]; then echo "ERROR: Could not find the version string for sam or sam.core.rte fileseti on DB2 media." trax ${func_name?} exit ${INTERNAL_ERR?} fi validate_version ${tsa_version?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: The version string ${tsa_version_sys?} for sam or sam.core.rte \ fileset contains non-digits besides delimiter." trax ${func_name?} exit ${INTERNAL_ERR?} else TSAMP_VERSION=${tsa_version?} fi trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi elif [ -d "${PROGDIR?}/../tsamp_nlv" ]; then tsa_dir="${PROGDIR?}/../tsamp_nlv" if [ -f "${tsa_dir?}/installSAM" ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_tsa_prereq_ok # Function - Checks if the system meeds the prerequsites for # install or update of SA MP Base Component. # # Parameters - none # Returns - 0 : prerequsites are met # non-zeor : otherwise #---------------------------------------------------------------- is_tsa_prereq_ok () { func_name="is_tsa_prereq_ok" trac ${func_name?} $@ set ${setopts?} prereq_log=$1 tsa_dir="" if [ -f "${PROGDIR?}/../tsamp/prereqSAM" ]; then tsa_cmd="${PROGDIR?}/../tsamp/prereqSAM -l ${prereq_log?} --noliccheck --silent" elif [ -f "${PROGDIR?}/../tsamp_nlv/prereqSAM" ]; then tsa_cmd="${PROGDIR?}/../tsamp_nlv/prereqSAM -l ${prereq_log?} --noliccheck --silent" else trax ${func_name?} return ${FALSE?} fi ${tsa_cmd?} 2>/dev/null 1>/dev/null if [ $? -eq ${TRUE?} ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_peer_domain_on_node # Function - Checks there exists RSCT peer domain(s) on the system # # Parameters - none # Returns - 0 : RSCT peer domain was found # non-zeor : otherwise #---------------------------------------------------------------- is_peer_domain_on_node () { func_name="is_peer_domain_on_node" trac ${func_name?} $@ set ${setopts?} is_tsa_installed rc_tsa_installed=$? if [ ${rc_tsa_installed?} -eq ${FALSE?} ]; then trax ${func_name?} return ${FALSE?} elif [ ${rc_tsa_installed?} -ne ${TRUE?} ]; then echo "ERROR: Could not detect if SA MP Base Component is installed." trax ${func_name?} exit ${INTERNAL_ERR?} fi chk_cmd_exist lsrpdomain if [ $? -ne ${TRUE?} ]; then echo "ERROR: The command lsrpdomain was not found on the system" trax ${func_name?} exit ${INTERNAL_ERR?} fi if [ `lsrpdomain 2>/dev/null | wc -l` -gt 1 ]; then lsrpdomain | grep -i -E 'name|opstate' 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_mig_updt_allowed # Function - Checks if the SA MP Base Component installed on the # system is supported for migration or update # # Parameters - $1 : m|u -> m for checking migration and u for checking update # Returns - 0 : The installed SA MP Base Component is supported for # migration or update. # non-zeor : otherwise #---------------------------------------------------------------- is_mig_updt_allowed () { func_name="is_mig_updt_allowed" trac ${func_name?} $@ set ${setopts?} if [ $# -lt 1 ] then echo "Usage: is_mig_updt_allowed m|u " trax ${func_name?} exit ${INTERNAL_ERR?} fi tmp_flag=$1 allowed_tsa_mig_version="2.1 2.2 2.3" allowed_tsa_updt_version="3.1" tsa_version="" tsa_version_sys="" if [ "X${tmp_flag?}" = "Xm" ]; then tmp_chk_version=${allowed_tsa_mig_version?} elif [ "X${tmp_flag?}" = "Xu" ]; then tmp_chk_version=${allowed_tsa_updt_version?} else echo "Usage: is_mig_updt_allowed m|u" trax ${func_name?} exit ${INTERNAL_ERR?} fi is_tsa_installed if [ $? -eq ${TRUE?} ]; then if [ "X${TSAMP_VERSION_SYS?}" != "X" ]; then tsa_version_sys=${TSAMP_VERSION_SYS?} fi is_tsa_on_media if [ $? -eq ${TRUE?} ]; then if [ "X${TSAMP_VERSION?}" != "X" ]; then tsa_version=${TSAMP_VERSION?} fi validate_version ${tsa_version_sys?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: The version string ${tsa_version_sys?} is invalid." trax ${func_name?} exit ${INTERNAL_ERR?} fi validate_version ${tsa_version?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: The version string ${tsa_version?} is invalid." trax ${func_name?} exit ${INTERNAL_ERR?} fi tmp_tsa_ver=`echo ${tsa_version_sys?} | cut -d. -f1,2` validate_version ${tmp_tsa_ver?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: The version string ${tmp_tsa_ver?} is invalid." trax ${func_name?} return ${INTERNAL_ERR?} fi for v in ${tmp_chk_version?}; do comp_version ${v?} ${tmp_tsa_ver?} if [ $? -eq ${TRUE?} ]; then comp_version ${tsa_version_sys?} ${tsa_version?} if [ $? -eq 1 ]; then trax ${func_name?} return ${TRUE?} fi fi done trax ${func_name?} return ${FALSE?} elif [ $? -eq ${FALSE?} ]; then trax ${func_name?} return ${FALSE?} else echo "ERROR: Could not detect if SA MP Base Component is on DB2 media." trax ${func_name?} exit ${INTERNAL_ERR?} fi elif [ $? -eq ${FALSE?} ]; then trax ${func_name?} return ${FALSE?} else echo "ERROR: Could not detect if SA MP Base Component is installed." trax ${func_name?} exit ${INTERNAL_ERR?} fi } is_tsa_not_lower () { func_name="is_tsa_not_lower" trac ${func_name?} $@ set ${setopts?} is_tsa_installed if [ $? -eq ${TRUE?} ]; then is_tsa_on_media if [ $? -eq ${TRUE?} ]; then tmp_tsa_ver=${TSAMP_VERSION_SYS?} tmp_tsa_ver_media=${TSAMP_VERSION?} if [ "X${tmp_tsa_ver?}" = "X" ]; then echoa"ERROR: Could not find version information for TSAMP installed on the system." trax ${func_name?} exit ${INTERNAL_ERR?} else validate_version ${tmp_tsa_ver?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: Version ${tmp_tsa_ver?} for installed TSAMP is invalid." trax ${func_name?} exit ${INTERNAL_ERR?} fi fi if [ "X${tmp_tsa_ver_media?}" = "X" ]; then echoa"ERROR: Could not find version information for TSAMP on the DB2 media." trax ${func_name?} exit ${INTERNAL_ERR?} else validate_version ${tmp_tsa_ver_media?} if [ $? -ne ${TRUE?} ]; then echo "ERROR: Version ${tmp_tsa_ver?} for TSAMP on DB2 media is invalid." trax ${func_name?} exit ${INTERNAL_ERR?} fi fi comp_version ${tmp_tsa_ver_media?} ${tmp_tsa_ver?} comp_rc=$? if [ ${comp_rc?} -eq 0 -o ${comp_rc?} -eq 1 ]; then trax ${func_name?} return ${TRUE?} elif [ ${comp_rc?} -eq 2 ]; then trax ${func_name?} return ${FALSE?} else echo "ERROR: Could not compare ${tmp_tsa_ver_media?} and ${tmp_tsa_ver?}." trax ${func_name?} exit ${INTERNAL_ERR?} fi else echo "ERROR: Could not detect if SA MP Base Component is on DB2 media." trax ${func_name?} exit ${INTERNAL_ERR?} fi else echo "ERROR: Could not detect if SA MP Base Component is installed." trax ${func_name?} exit ${INTERNAL_ERR?} fi } #---------------------------------------------------------------- # Name - is_tsa_license_needed # Function - Checks if the SA MP Base Component license needs to # be updated on the system # # Parameters - $1 : SA MP Base Component license certificate file with full path # Returns - 0 : If the following conditions are all met: # (1) The system has SA MP Base Component installed at # supported level (valid_versions) # (2) The installed SA MP Base Component does not have # full license # (3) The license file to be installed is a full license # at supported level (valid_versions) # non-zeor : otherwise #---------------------------------------------------------------- is_tsa_license_needed () { func_name="is_tsa_license_needed" trac ${func_name?} $@ set ${setopts?} if [ $# -lt 1 ] then echo "Usage: is_tsa_license_needed " trax ${func_name?} exit ${INTERNAL_ERR?} fi valid_versions="2.1 2.2 2.3 3.1" tmp_samlic=$1 if [ ! -f ${tmp_samlic?} ]; then trax ${func_name?} return ${FALSE?} fi tmp_lic_ok=${FALSE?} tmp_tsa_ok=${FALSE?} is_tsa_installed if [ $? -ne ${TRUE?} ]; then trax ${func_name?} return ${FALSE?} fi tmp_lic_ver=`grep -i ProductVersion ${tmp_samlic?} | cut -d= -f2 | cut -d. -f1,2` for v in ${valid_versions?}; do comp_version ${v?} ${tmp_lic_ver?} if [ $? -eq ${TRUE?} ]; then grep -i LicenseEndDate ${tmp_samlic?} | grep 2037 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then tmp_lic_ok=${TRUE?} fi LANG_OLD=${LANG?} LANG="en_US" export LANG samlicm -s 2>/dev/null | grep -E '2037|2038' 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then tmp_lic_ok=${FALSE?} fi LANG=${LANG_OLD?} export LANG fi done tmp_tsa_ver=${TSAMP_VERSION_SYS?} validate_version ${tmp_tsa_ver?} if [ $? -ne ${TRUE?} ]; then trax ${func_name?} return ${FALSE?} fi tmp_tsa_ver=`echo ${tmp_tsa_ver?} | cut -d. -f1,2` for v in ${valid_versions?}; do comp_version ${v?} ${tmp_tsa_ver?} if [ $? -eq ${TRUE?} ]; then tmp_tsa_ok=${TRUE?} fi done if [ ${tmp_lic_ok?} -eq ${TRUE?} -a ${tmp_tsa_ok?} -eq ${TRUE?} ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_tsa_perm_sys() # Function - Checks to see if the TSAMP license on the system is permanent # # Returns - 0 : TSAMP on system is permanent # 1 : otherwise #---------------------------------------------------------------- is_tsa_perm_sys() { func_name="is_tsa_perm_sys" trac ${func_name?} set ${setopts?} perm_lic_sys=${FALSE?} tsa_dir="${PROGDIR?}/../tsamp" if [ `echo ${TSAMP_VERSION_SYS?} | awk '{print $1$2$3$4}' FS="."` -lt 3100 ]; then LANG_OLD=${LANG?} LANG="en_US" export LANG samlicm -s 2>/dev/null | grep -E '2037|2038' 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then perm_lic_sys=${TRUE?} fi LANG=${LANG_OLD?} export LANG else samlicm -p 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then perm_lic_sys=${TRUE?} fi fi if [ ${perm_lic_sys?} -eq ${TRUE?} ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - is_tsa_tb_media() # Function - Checks to see if the TSAMP license on the media is try-and-buy # # Returns - 0 : TSAMP on media is Try-and-Buy # 1 : otherwise #---------------------------------------------------------------- is_tsa_tb_media() { func_name="is_tsa_tb_media" trac ${func_name?} set ${setopts?} tsa_dir="${PROGDIR?}/../tsamp" ls ${tsa_dir?}/license | grep tb.lic 1>/dev/null 2>/dev/null if [ $? -eq ${TRUE?} ]; then trax ${func_name?} return ${TRUE?} else trax ${func_name?} return ${FALSE?} fi } #---------------------------------------------------------------- # Name - tsa_install_action() # Function - Figure out if TSA is going to be updated or upgraded # It compares the first two digits from the version to # see if they are different, if so it is an upgrade. # When they are equal compare all 4 digits and see if # a fixpack update is required. # # Returns - 0 : no action # 1 : update # 2 : upgrade #---------------------------------------------------------------- tsa_install_action() { func_name="tsa_install_action" trac ${func_name?} set ${setopts?} rc=${NO_ACTION?} tsa_version_system=`echo ${TSAMP_VERSION_SYS?} | cut -d. -f1,2` tsa_version_media=`echo ${TSAMP_VERSION?} | cut -d. -f1,2` comp_version ${tsa_version_system?} ${tsa_version_media?} comp_rc=$? if [ ${comp_rc?} -eq 1 ]; then rc=${UPGRADE_ACTION?} elif [ ${comp_rc?} -eq 0 ]; then comp_version ${TSAMP_VERSION_SYS?} ${TSAMP_VERSION?} if [ $? -eq 1 ]; then rc=${UPDATE_ACTION?} fi fi trax ${func_name?} return ${rc?} } defaultopts # Process command-line options while getopts :i:hdcm optchar; do case ${optchar?} in d) # Turn debug mode on DEBUG=${TRUE?} setopts="-x" ;; c) # C_OPTION=${TRUE?} ;; i) SAMLIC_FILE="${OPTARG?}" I_OPTION=${TRUE?} if [ ! -f "${SAMLIC_FILE?}" ]; then echo "ERROR: The file ${SAMLIC_FILE?} does not exist." syntax fi ;; m) M_OPTION=${TRUE?} ;; ?) # Display help syntax ;; esac done set ${setopts?} OPTS="${C_OPTION?} ${I_OPTION?} ${M_OPTION?}" var=0 for i in ${OPTS?}; do if [ $i -eq 0 ]; then var=`expr $var + 1` fi done if [ $var -gt 1 ]; then syntax fi if [ ${I_OPTION?} -eq ${TRUE?} ]; then is_tsa_license_needed ${SAMLIC_FILE?} if [ $? -eq ${TRUE?} ]; then db2chktsa_rc=13 else db2chktsa_rc=14 fi elif [ ${C_OPTION?} -eq ${TRUE?} ]; then is_tsa_on_media if [ $? -ne ${TRUE} ]; then db2chktsa_rc=4 else is_tsa_prereq_ok ${LOGFILE?} if [ $? -eq ${TRUE?} ]; then db2chktsa_rc=5 else db2chktsa_rc=6 #DISPLAY 1130E display_msg ${DB2CAT?} 130 \ "DBI1130E The SA MP Base Component could not be installed or updated \ because system prerequisites were not met. See the log file %s for details.\n" ${LOGFILE?} fi fi elif [ ${M_OPTION?} -eq ${TRUE?} ]; then db2chktsa_rc=23 is_tsa_installed rc_installed=$? is_tsa_on_media rc_tsa_on_media=$? if [ ${rc_installed?} -eq ${TRUE} -a ${rc_tsa_on_media?} -eq ${TRUE} ]; then is_tsa_perm_sys if [ $? -eq ${TRUE?} ]; then tsa_install_action if [ $? -eq ${UPGRADE_ACTION?} ]; then is_tsa_tb_media if [ $? -eq ${TRUE?} ]; then db2chktsa_rc=22 fi fi fi fi else is_tsa_installed rc_installed=$? is_tsa_on_media rc_on_media=$? is_peer_domain_on_node rc_domain=$? is_mig_updt_allowed m rc_migrate=$? is_mig_updt_allowed u rc_update=$? is_tool_in_db2dir rc_tool_path=$? if [ ${rc_installed?} -eq ${TRUE} ]; then if [ ${rc_on_media?} -eq ${TRUE?} ]; then is_tsa_not_lower if [ $? -eq ${TRUE?} ]; then db2chktsa_rc=11 elif [ $? -eq ${FALSE?} ]; then if [ ${rc_migrate?} -ne ${TRUE?} -a ${rc_update?} -ne ${TRUE?} ]; then db2chktsa_rc=9 elif [ ${rc_migrate?} -eq ${TRUE?} ]; then if [ ${rc_domain?} -eq ${TRUE?} ]; then db2chktsa_rc=10 elif [ ${rc_domain?} -eq ${FALSE?} ]; then db2chktsa_rc=3 else db2chktsa_rc=${INTERNAL_ERR?} fi elif [ ${rc_update?} -eq ${TRUE?} ]; then if [ ${rc_domain?} -eq ${TRUE?} ]; then db2chktsa_rc=2 elif [ ${rc_domain?} -eq ${FALSE?} ]; then db2chktsa_rc=1 else db2chktsa_rc=${INTERNAL_ERR?} fi fi else db2chktsa_rc=${INTERNAL_ERR?} fi elif [ ${rc_on_media?} -eq ${FALSE?} ]; then if [ ${rc_tool_path?} -eq ${TRUE?} ]; then db2chktsa_rc=12 else db2chktsa_rc=8 fi else db2chktsa_rc=${INTERNAL_ERR?} fi else if [ ${rc_on_media?} -eq ${TRUE?} ]; then db2chktsa_rc=0 else db2chktsa_rc=7 fi fi fi if [ "X${TSAMP_VERSION_SYS?}" != "X" ]; then validate_version ${TSAMP_VERSION_SYS?} if [ $? -eq ${TRUE?} ]; then echo "TSAMP_VERSION_SYS=${TSAMP_VERSION_SYS?}" fi fi if [ "X${TSAMP_VERSION?}" != "X" ]; then validate_version ${TSAMP_VERSION?} if [ $? -eq ${TRUE?} ]; then echo "TSAMP_VERSION=${TSAMP_VERSION?}" fi fi exit ${db2chktsa_rc?}