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/
Insert the following script into the setup_db2_for_OS2DB.sh file.
# Licensed Materials – Property of IBM
# (c) Copyright IBM Corp.
2017,2018 All Rights Reserved.
# Set DB2 performance parameters
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
“
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.
“
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
echo -e
“
$i.DB2 is not ready yet, wait 30 seconds and recheck again….
“
echo -e
“
\033[36mOS2DB database created successfully \033[0m
“
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
cd /root/ECMContainers/Container-PIT/install-scripts/config-files/CPE
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
The following shell script code is copied to the deployDB2_OS2DB.sh:
# Licensed Materials – Property of IBM
# (c) Copyright IBM Corp.
2017, 2018 All Rights Reserved.
echo
“
==========================================
“
date
if [[ $ScriptsDir =
“”
]]; then
echo
“
Begin to deploy OS2DB to $DB2_IMAGE_NAME:$DB2_IMAGE_TAG Container $DB2_CONTAINER_NAME
“
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
echo
“
Copied DB2 configuration files to $DB2_CONFIGFILES_LOC successfully
“}
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 exec -i $DB2_CONTAINER_NAME /bin/bash /database/config/db2inst1/setup_db2_for_OS2DB.sh
echo -e
“
\033[31mFailed to create the database OS2DB.
\033[0m
“
duration_1=$((($end_time_1-$start_time_1)/60))
echo -e
“
\033[36mCreate database OS2DB took $duration_1 minute \033[0m
“
echo -e
“
\033[36mFinished create database OS2DB successfully \033[0m
“
sed -i.bak
‘
s/deployDB2: NotCompleted/deployDB2: Completed/g
‘
$filename
echo
“
==========================================
“
The security is changed on the script file to allow it to be executed:chmod 775 deployDB2_OS2DB.sh