Posted in

setup_db2_for_OS2DB.sh – Cloud Based Systems

8.3.1.4 setup_db2_for_OS2DB.sh

We need to update the shell script which calls the other script we just created:

cd   /root/ECMContainers/Container-PIT/install-scripts/config-files/DB2/

vi setup_db2_for_OS2DB
.sh

Insert the following script into the setup_db2_for_OS2DB.sh file.

#/bin/bash

#

# Licensed Materials – Property of IBM

# 5747-SM3

# (c) Copyright IBM Corp.
2017,2018  All Rights Reserved.

# US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

#

# Set DB2 performance parameters

export CUR_COMMIT=ON

su – db2inst1 -c

db2set DB2_WORKLOAD=FILENET_CM

echo

set CUR_COMMIT=$CUR_COMMIT

# Change file ownership and folder permissions for non-root execution

chown db2inst1:db2iadm1 /database/config/db2inst1/*.sh

chown db2inst1:db2iadm1 /database/config/db2inst1/*.sql

chmod 755 /database/config/db2inst1/*.sh

chown -R db2inst1:db2iadm1 /db2fs

# Run the database creation script

echo

Begin to create OS2DB database

su – db2inst1 -c

/database/config/db2inst1/OS2DB.sh OS2DB

TIME_OUT=15

i=0

if [[ $i -eq $TIME_OUT*2 ]]; then

       echo

Database create can

t start within 30 minutes, something must be wrong, exit now…

       echo

Pls check DB2 docker container log to check its status.

       exit 1

fi

while(($i<$TIME_OUT*2))

do

      number_of_db=

su – db2inst1 -c

db2 list db directory

 | grep

Number of entries in the directory

 | awk -F

=


{print $2}

      if [

$number_of_db

x =
“”
x -o $number_of_db -lt 4 ]; then

        let i++

        echo -e

 $i.DB2 is not ready yet, wait 30 seconds and recheck again….

        sleep 30

      else

        echo -e

\033[36mOS2DB database created successfully \033[0m

        break

      fi

done

Next, we need to set the security on the files we created so that they can be executed:

cd /root/ECMContainers/Container-PIT/install-scripts/config-files/DB2

chmod 775
*

cd /root/ECMContainers/Container-PIT/install-scripts/config-files/CPE

chmod 775 *

8.3.1.5 Edit the deployDB2_OS2DB.sh shell script file

The commands below are used to edit the deploy shell script file, deployDB2_OS2DB.sh:

cd /root/ECMContainers/Container-PIT/install-scripts

vi deployDB2_OS2DB.sh

The following shell script code is copied to the deployDB2_OS2DB.sh:

#!/bin/bash

#

# Licensed Materials – Property of IBM

# 5747-SM3

# (c) Copyright IBM Corp.
2017, 2018  All Rights Reserved.

# US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

#

echo

==========================================

date

if [[ $ScriptsDir =
“”
 ]]; then

        source ./d_utils.sh

        echo $ScriptsDir

fi

echo

Begin to deploy OS2DB to $DB2_IMAGE_NAME:$DB2_IMAGE_TAG Container $DB2_CONTAINER_NAME

start_time_1=$(date +%s)

filename=$ScriptsDir/

status.log

function copyDB2ConfigFiles() {

        echo

Copy DB2 configuration files start…

        cd $ScriptsDir/config-files/DB2

        cp -f OS2DB.sh setup_db2_for_OS2DB.sh $DB2_CONFIGFILES_LOC/$DB2_SCRIPT

         cp -f ../CPE/OS2DB.xml $CPE_CONFIGFILES_LOC/$CPE_OVERRIDES_FOLDER

         chown -R $U_UID:$G_GID $CPE_CONFIGFILES_LOC

         chmod -R 777 $CPE_CONFIGFILES_LOC

        cd $ScriptsDir

        echo

Copied DB2 configuration files to $DB2_CONFIGFILES_LOC successfully
}

function createDB() {

  echo

Begin to create the OS2DB database…

  containerID=

docker ps -a -q –filter name=$DB2_CONTAINER_NAME$

  docker cp $DB2_CONFIGFILES_LOC/$DB2_SCRIPT/OS2DB.sh $containerID:/database/config/db2inst1

  docker cp $DB2_CONFIGFILES_LOC/$DB2_SCRIPT/setup_db2_for_OS2DB.sh $containerID:/database/config/db2inst1

  docker exec -i $DB2_CONTAINER_NAME /bin/bash /database/config/db2inst1/setup_db2_for_OS2DB.sh

if [ !
$?
-eq 0 ] ;then

          echo -e

\033[31mFailed to create the database OS2DB.
\033[0m

          exit_script

  fi

}

copyDB2ConfigFiles

createDB

end_time_1=$(date +%s)

duration_1=$((($end_time_1-$start_time_1)/60))

echo -e

\033[36mCreate database OS2DB took $duration_1 minute \033[0m

if [ $?
-eq 0 ] ;then

    echo -e

\033[36mFinished create database OS2DB successfully \033[0m

         sed -i.bak

s/deployDB2: NotCompleted/deployDB2: Completed/g

 $filename

else

    exit_script

fi

echo

==========================================

The security is changed on the script file to allow it to be executed:chmod 775 deployDB2_OS2DB.sh

Leave a Reply

Your email address will not be published. Required fields are marked *