[root@yang sqllib]# cat db2profile
#############################################################################
#
# licensed materials - property of ibm
# (c) copyright international business machines corp. 2009
# all rights reserved.
# us government users restricted rights - use, duplication or
# disclosure restricted by gsa adp schedule contract with ibm corp.
# name: db2profile
# function: this script. sets up a default database environment for
# bourne shell or korn shell users.
# usage: . db2profile
# this script. can either be invoked directly as above or
# it can be added to the user's .profile file so that the
# database environment is established during login.
# #### do not edit this file ####
db2dir=/opt/ibm/db2/v9.5
# remember the current db2instance environment variable
cur_instname=${db2instance:=""}
#-----------------------------------------------------------------------
# db2instance [default null, values: any valid instance name]
# specifies the instance that is active by default.
db2instance=db2inst1
export db2instance
insthome=/home/db2inst1
# function to add or remove certain path to or from the specified
# environment variable.
addremovestring()
{
if [ $# -ne 3 ]; then
return 0
fi
var=$1 #the enviornment variable to be processed
addrm_str=$2 #the new path to be used
action=$3 #action: a -> add, r -> remove
if [ "x${action?}" != "xa" -a "x${action?}" != "xr" ]; then
return 0 # return without doing anything
awkval='$1 != "'${addrm_str?}'"{print $0}'
if( $i != var && length($i) > 0 ) print $i":"}' fs=":" var=${addrm_str?}`
newval=`echo ${newval?} | sed 's/\: /\:/g'`
if [ "x${action?}" = "xa" ]; then
newval=${newval?}"${addrm_str?}"
else
newval=`echo ${newval?} | sed 's/:$//'`
eval $var=\"${newval?}\"
unset var addrm_str awkval newval
}
#----------------------------------------------------------------------------
# if db2 instance environment is being switched from one instances to another,
# the entries for old db2 instance in the original instance enviornment
# are cleaned up.
if [ -n "${cur_instname?}" ]; then
cur_insthome=`${insthome?}/sqllib/bin/db2usrinf -d ${cur_instname?}`
path_list="bin adm misc db2tss/bin"
class_list="java/db2java.zip java/db2jcc.jar java/sqlj.zip function \
java/db2jcc_license_cisuz.jar java/db2jcc_license_cu.jar \
java/runtime.zip"
for tmp_entry in ${path_list?}; do
addremovestring path ${cur_insthome?}/sqllib/${tmp_entry?} r
done
for tmp_entry in ${class_list?}; do
addremovestring classpath ${cur_insthome?}/sqllib/${tmp_entry?} r
for path_name in ld_library_path libpath shlib_path ld_library_path_32 \
ld_library_path_64; do
for tmp_path in lib lib32 lib64; do
addremovestring ${path_name?} ${cur_insthome?}/sqllib/${tmp_path?} r
done
for path_name in path classpath ld_library_path libpath shlib_path \
ld_library_path_32 ld_library_path_64; do
eval path_value=\$$path_name
if [ "x${path_value}" = "x" ]; then
unset ${path_name?}
else
export ${path_name?}
fi
unset cur_instname path_list class_list tmp_entry path_name path_value
fi
#-----------------------------------------------------------------------------
# in db2 instance environment, the das environment needs to be cleaned up.
dasworkdir=${dasworkdir:=""}
if [ "x${dasworkdir}" != "x" ]; then
addremovestring path ${dasworkdir?}/bin r
addremovestring path ${dasworkdir?}/adm r
for path_name in libpath shlib_path ld_library_path; do
for tmp_path in lib function; do
addremovestring ${path_name?} ${dasworkdir?}/${tmp_path?} r
done
done
for path_name in path libpath shlib_path ld_library_path; do
if [ "x${path_name}" = "x" ]; then
for tmp_path in bin adm misc; do
addremovestring path ${insthome?}/sqllib/${tmp_path?} a
done
if [ -d ${insthome}/sqllib/db2tss/bin ]; then
addremovestring path ${insthome}/sqllib/db2tss/bin a
export path
unset tmp_path
# udb extender initialization
if [ -f ${insthome}/dmb/dmbprofile ]; then
. ${insthome}/dmb/dmbprofile
# the following variables are used for jdbc support
classpath=${classpath:-""}
if [ -f ${insthome?}/sqllib/java/db2java.zip ]; then
addremovestring classpath ${insthome?}/sqllib/java/db2java.zip a
if [ -f ${insthome?}/sqllib/java/db2jcc.jar ]; then
addremovestring classpath ${insthome?}/sqllib/java/db2jcc.jar a
if [ -f ${insthome?}/sqllib/java/sqlj.zip ]; then
addremovestring classpath ${insthome?}/sqllib/java/sqlj.zip a
if [ -d ${insthome?}/sqllib/function ]; then
addremovestring classpath ${insthome?}/sqllib/function a
if [ -f ${insthome?}/sqllib/java/db2jcc_license_cisuz.jar ]; then
addremovestring classpath ${insthome?}/sqllib/java/db2jcc_license_cisuz.jar a
if [ -f ${insthome?}/sqllib/java/db2jcc_license_cu.jar ]; then
addremovestring classpath ${insthome?}/sqllib/java/db2jcc_license_cu.jar a
addremovestring classpath . a
export classpath
ld_library_path=${ld_library_path:-""}
addremovestring ld_library_path ${insthome?}/sqllib/lib32 a
export ld_library_path
#--------------------------------------------------------------------------
# any user changes to the environment goes into userprofile. modifications
# to db2profile may be overwritten in fixpaks.
if [ -f ${insthome?}/sqllib/userprofile ]; then
. ${insthome?}/sqllib/userprofile