Warning, file /sdk/codevis/thirdparty/soci/scripts/vagrant/db2.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #!/usr/bin/env bash
0002 # Part of Vagrant virtual development environments for SOCI
0003 
0004 # Installs DB2 Express-C 9.7
0005 # Pre-installation
0006 source /vagrant/scripts/vagrant/common.env
0007 export DEBIAN_FRONTEND="noninteractive"
0008 # Installation
0009 /vagrant/scripts/ci/install_db2.sh
0010 # Post-installation
0011 ## Let's be gentle to DB2 and try to not to recreate existing databases
0012 echo "db2: checking if ${SOCI_USER} database exists"
0013 # First time guest machine is created, there is no database, hence test for:
0014 # SQL1031N  The database directory cannot be found on the indicated file system.
0015 sudo -u db2inst1 -i db2 "LIST DATABASE DIRECTORY" | grep SQL1031N
0016 NODB=$?
0017 sudo -u db2inst1 -i db2 "LIST DATABASE DIRECTORY" | grep -i ${SOCI_USER}
0018 HASSOCI=$?
0019 if [[ $NODB -eq 0 || $HASSOCI -ne 0 ]]; then
0020   echo "db2: creating database ${SOCI_USER}"
0021   sudo -u db2inst1 -i db2 "CREATE DATABASE ${SOCI_USER}"
0022   sudo -u db2inst1 -i db2 "ACTIVATE DATABASE ${SOCI_USER}"
0023 else
0024   echo "db2: database ${SOCI_USER} (may) exists, skipping"
0025 fi