【DB2学习】db2profile的脚本

简介: [root@yang sqllib]# cat db2profile############################################################################### Licensed Material...

[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
    fi
    awkval='$1 != "'${addrm_str?}'"{print $0}'
    newval=`eval echo \\${$var:-""} | awk '{for (i=1; i          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/:$//'`
    fi
    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
     done

     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
     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
     done
     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
           unset ${path_name?}
        else
           export ${path_name?}
        fi
  done
fi
#-----------------------------------------------------------------------------

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
fi
export PATH
unset tmp_path

#-----------------------------------------------------------------------
# UDB Extender initialization
#-----------------------------------------------------------------------
if [ -f ${INSTHOME}/dmb/dmbprofile ]; then
    . ${INSTHOME}/dmb/dmbprofile
fi

#-----------------------------------------------------------------------
# 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
fi
if [ -f ${INSTHOME?}/sqllib/java/db2jcc.jar ]; then
    AddRemoveString CLASSPATH ${INSTHOME?}/sqllib/java/db2jcc.jar a
fi
if [ -f ${INSTHOME?}/sqllib/java/sqlj.zip ]; then
    AddRemoveString CLASSPATH ${INSTHOME?}/sqllib/java/sqlj.zip a
fi
if [ -d ${INSTHOME?}/sqllib/function ]; then
    AddRemoveString CLASSPATH ${INSTHOME?}/sqllib/function a
fi

if [ -f ${INSTHOME?}/sqllib/java/db2jcc_license_cisuz.jar ]; then
    AddRemoveString CLASSPATH ${INSTHOME?}/sqllib/java/db2jcc_license_cisuz.jar a
fi

if [ -f ${INSTHOME?}/sqllib/java/db2jcc_license_cu.jar ]; then
    AddRemoveString CLASSPATH ${INSTHOME?}/sqllib/java/db2jcc_license_cu.jar a
fi

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
fi

目录
相关文章
|
关系型数据库 数据库 Ruby
记录一次 bin/rails db:migrate 报错
记录一次 bin/rails db:migrate 报错
92 0
|
SQL 关系型数据库 数据库
|
关系型数据库 数据库连接 数据库
DB2常用命令
DB2常用命令1.打开命令行窗口   #db2cmd 2.打开控制中心   # db2cmd db2cc 3.打开命令编辑器  db2cmd db2ce 操作数据库命令*4.启动数据库实例   #db2start 5.
2113 0
|
存储 关系型数据库 MySQL
|
关系型数据库 数据库 Windows
|
SQL 分布式数据库 数据库
|
分布式计算 JavaScript NoSQL