db2cli.sh 2.2 KB
Newer Older
1 2 3 4 5 6
#!/usr/bin/env bash
# Part of Vagrant virtual development environments for SOCI

# Installs DB2 CLI Driver 10.5 (64-bit and 32-bit) from
# IBM Data Server Driver Package (DS Driver)

7
# Prerequisities (manual download if wget fails):
8
# 1. Go to http://www-01.ibm.com/support/docview.wss?uid=swg21385217
9 10 11
# 2. Go to "IBM Data Server Driver Package (DS Driver)"
# 3. Download "IBM Data Server Driver Package (Linux AMD64 and Intel EM64T)"
# 4. Copy the package to '{SOCI SOURCE TREE ROOT}/tmp' directory.
12 13 14 15 16
DSPKG="ibm_data_server_driver_package_linuxx64_v10.5.tar.gz"
DSPREFIX=/opt/ibm
DSDRIVER=${DSPREFIX}/dsdriver
SOCITMP=/vagrant/tmp

17
# Try to download from known location
18 19
echo "DB2CLI: downloading ${DSPKG} from github.com/rorymckinley/gold_importer"
wget -q https://raw.githubusercontent.com/rorymckinley/gold_importer/master/3rdparty/ibm_data_server_driver_package_linuxx64_v10.5.tar.gz
20

21
# Check if driver package is available
22
if [[ ! -f ${DSPKG} && ! -f ${SOCITMP}/${DSPKG} ]]; then
23
  echo "DB2CLI: missing ${SOCITMP}/${DSPKG}"
24 25
  echo "DB2CLI: try manual download, then provision VM to install"
  echo "DB2CLI: meanwhile, skipping driver installation"
26 27 28
  exit 0
fi

29 30 31 32
if [ -f ${SOCITMP}/${DSPKG} ]; then
    DSPKG=${SOCITMP}/${DSPKG}
fi

33 34 35 36 37 38 39 40 41 42 43 44
# If the drivers is already installed, skip re-installation
# because installDSDriver script does not support it
if [[ -d "${DSDRIVER}" && -f ${DSDRIVER}/db2profile ]]; then
  echo "DB2CLI: ${DSDRIVER} already installed, skipping"
  echo "DB2CLI: if necessary, upgrade manually running: ${DSDRIVER}/installDSDriver -upgrade ${DSDRIVER}"
  exit 0
fi

# Korn shell required by installDSDriver script
sudo apt-get -o Dpkg::Options::='--force-confnew' -y -q install \
  ksh

45
echo "DB2CLI: unpacking ${DSPKG} to ${DSPREFIX}"
46
sudo mkdir -p ${DSPREFIX}
47
sudo tar -zxf ${DSPKG} -C ${DSPREFIX}
48 49 50 51 52 53 54 55
echo "DB2CLI: running ${DSDRIVER}/installDSDriver script"
sudo ${DSDRIVER}/installDSDriver
echo "DB2CLI: cat ${DSDRIVER}/installDSDriver.log"
cat ${DSDRIVER}/installDSDriver.log
echo
echo "DB2CLI: installing ${DSDRIVER}/db2profile in /etc/profile.d/db2profile.sh for 64-bit env"
sudo cp ${DSDRIVER}/db2profile /etc/profile.d/db2profile.sh
echo "DB2CLI: For 32-bit, manually source ${DSDRIVER}/db2profile32 to overwrite 64-bit env"