Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CloudPak-Outcomes
GitHub Repository: CloudPak-Outcomes/Outcomes-Projects
Path: blob/main/Db2-L3-Tech-Lab/db2_env_setup.sh
1928 views
1
#!/bin/bash
2
#-------------------------------------------------------------------------------------------------#
3
# NAME: db2_env_setup.sh #
4
# #
5
# PURPOSE: This program is designed to install the libraries that are needed to set up and run #
6
# IBM Db2 Community Edition, and then install the IBM Db2 software, on an Ubuntu #
7
# Linux server. #
8
# #
9
# USAGE: 1) Locate the following variables in the main() function of this file and assign #
10
# them the appropriate values: #
11
# #
12
# Db2CodeFile #
13
# Db2InstallDir #
14
# #
15
# 2) Log in as the root user and issue the following command from a Linux terminal #
16
# window (after moving to the directory where the .tar file and this file are #
17
# stored - typically the Downloads directory): #
18
# #
19
# ./db2_env_setup.sh #
20
# #
21
#-------------------------------------------------------------------------------------------------#
22
# DISCLAIMER OF WARRANTIES AND LIMITATION OF LIABILITY #
23
# #
24
# (C) COPYRIGHT International Business Machines Corp. 2017, 2018, & 2022. All Rights Reserved #
25
# Licensed Materials - Property of IBM #
26
# #
27
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP #
28
# Schedule Contract with IBM Corp. #
29
# #
30
# The following source code ("Sample") is owned by International Business Machines Corporation #
31
# or one of its subsidiaries ("IBM") and is copyrighted and licensed, not sold. You may use, #
32
# copy, modify, and distribute the Sample in any form without payment to IBM, for the purpose of #
33
# assisting you with the installation of Db2 on a Ubuntu Linux server. #
34
# #
35
# The Sample code is provided to you on an "AS IS" basis, without warranty of any kind. IBM #
36
# HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT #
37
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #
38
# Some jurisdictions do not allow for the exclusion or limitation of implied warranties, so the #
39
# above limitations or exclusions may not apply to you. IBM shall not be liable for any damages #
40
# you suffer as a result of using, copying, modifying or distributing the Sample, even if IBM #
41
# has been advised of the possibility of such damages. #
42
#-------------------------------------------------------------------------------------------------#
43
# HISTORY: 16MAY2018 - Initial Coding Roger E. Sanders #
44
# 07JUN2018 - Added Error Checking and Db2 Install Shruthi Subbaiah Machimada #
45
# 02SEP2022 - Added Modifications for Installing Db2 V11.5 Roger E. Sanders #
46
#-------------------------------------------------------------------------------------------------#
47
48
49
#-------------------------------------------------------------------------------------------------#
50
# NAME: init_log_file() #
51
# #
52
# PURPOSE: This function writes the appropriate header information to the Db2 environment #
53
# setup up script log file (db2_env_setup.log). #
54
# #
55
# PARAMETERS: $1 - Log file name #
56
# #
57
# RETURNS: None #
58
#-------------------------------------------------------------------------------------------------#
59
function init_log_file
60
{
61
# Create A New Log File And Write The Appropriate Header Information To It
62
echo "#--------------------------------------------------------------------#" > ${1} 2>&1
63
echo "# NAME: db2_env_setup.log #" >> ${1} 2>&1
64
echo "# CREATED: ${timeStamp} #" >> ${1} 2>&1
65
echo "# #" >> ${1} 2>&1
66
echo "# CONTENTS: Log data produced by db2_env_setup.sh #" >> ${1} 2>&1
67
echo "#--------------------------------------------------------------------#" >> ${1} 2>&1
68
echo "" >> ${1} 2>&1
69
70
# Change Permissions On The Log File So Anyone Can Access It
71
chmod 777 ${1}
72
}
73
74
75
#-------------------------------------------------------------------------------------------------#
76
# NAME: install_db2_prereq_libraries() #
77
# #
78
# PURPOSE: This function installs the Db2 prerequisite libraries needed (for Ubuntu Linux). #
79
# #
80
# PARAMETERS: $1 - Log file name #
81
# #
82
# RETURNS: TRUE (1) - Packages and libraries needed were installed #
83
# FALSE (0) - One or more packages or libraries were not installed #
84
#-------------------------------------------------------------------------------------------------#
85
function install_db2_prereq_libraries
86
{
87
# Define All Local Variables Used
88
local returnCode=${returnCode:=0} # Function Return Code
89
local errorFlag=${errorFlag:=0} # Error Encountered Flag
90
local outputMsg=${outputMsg:=''} # Command Output Message Text
91
92
# Initialize The Appropriate Memory Variables
93
returnCode=${FALSE}
94
errorFlag=${FALSE}
95
96
# Upgrade All Packages Installed On The System
97
echo "Installing newer versions of all packages currently installed." | tee -a ${1}
98
echo "(This may take a few minutes)."
99
outputMsg=$(apt-get -y upgrade 2>&1)
100
echo "${outputMsg}" >> ${1} 2>&1
101
if [[ ${outputMsg} =~ "E:" ]]; then
102
echo "ERROR: Could not upgrade packages."
103
errorFlag=${TRUE}
104
fi
105
echo "" >> ${1}
106
echo "" | tee -a ${1}
107
108
# Fix Any Broken Packages Or Package Dependencies Found
109
echo "Fixing any broken packages and package dependencies found." | tee -a ${1}
110
echo "" >> ${1}
111
outputMsg=$(apt-get --fix-broken install)
112
echo "${outputMsg}" >> ${1} 2>&1
113
if [[ ${outputMsg} =~ "E:" ]]; then
114
echo "ERROR: Could not fix broken packages and package dependencies."
115
errorFlag=${TRUE}
116
fi
117
echo "" >> ${1}
118
echo "" | tee -a ${1}
119
120
# Install The LIBAIO1 Linux Library
121
echo "Installing the libaio1 package." | tee -a ${1}
122
echo "" >> ${1}
123
outputMsg=$(apt-get -y install libaio1 2>&1)
124
echo "${outputMsg}" >> ${1} 2>&1
125
if [[ ${outputMsg} =~ "E:" ]]; then
126
echo "ERROR: Could not install libaio1."
127
errorFlag=${TRUE}
128
fi
129
echo "" >> ${1}
130
echo "" | tee -a ${1}
131
132
# Install The BINUTILS Linux Library
133
echo "Installing the binutils package." | tee -a ${1}
134
echo "" >> ${1}
135
outputMsg=$(apt-get -y install binutils 2>&1)
136
echo "${outputMsg}" >> ${1} 2>&1
137
if [[ ${outputMsg} =~ "E:" ]]; then
138
echo "ERROR: Could not install binutils."
139
errorFlag=${TRUE}
140
fi
141
echo "" >> ${1}
142
echo "" | tee -a ${1}
143
144
# Install The ZLIB1G Linux Library
145
echo "Installing the zlib1g-dev package." | tee -a ${1}
146
echo "" >> ${1}
147
outputMsg=$(apt-get -y install zlib1g-dev 2>&1)
148
echo "${outputMsg}" >> ${1} 2>&1
149
if [[ ${outputMsg} =~ "E:" ]]; then
150
echo "ERROR: Could not install zlib1g-dev."
151
errorFlag=${TRUE}
152
fi
153
echo "" >> ${1}
154
echo "" | tee -a ${1}
155
156
# Install The LIBPAM0G:I386 Linux Library
157
echo "Installing the libpam0g:i386 package." | tee -a ${1}
158
echo "" >> ${1}
159
outputMsg=$(apt-get -y install libpam0g:i386 2>&1)
160
echo "${outputMsg}" >> ${1} 2>&1
161
if [[ ${outputMsg} =~ "E:" ]]; then
162
echo "ERROR: Could not install libpam0g:i386."
163
errorFlag=${TRUE}
164
fi
165
echo "" >> ${1}
166
echo "" | tee -a ${1}
167
168
# Install The LIBSTDC++:I386 Linux Library
169
echo "Installing the libstdc++6:i386 package." | tee -a ${1}
170
echo "" >> ${1}
171
outputMsg=$(apt-get -y install libstdc++6:i386 2>&1)
172
echo "${outputMsg}" >> ${1} 2>&1
173
if [[ ${outputMsg} =~ "E:" ]]; then
174
echo "ERROR: Could not install libstdc++6:i386."
175
errorFlag=${TRUE}
176
fi
177
echo "" >> ${1}
178
echo "" | tee -a ${1}
179
180
# Install The LIBLOGGER-SYSLOG-PERL Linux Library (For TSA MP)
181
echo "Installing the liblogger-syslog-perl package." | tee -a ${1}
182
echo "" >> ${1}
183
outputMsg=$(apt-get -y install liblogger-syslog-perl 2>&1)
184
echo "${outputMsg}" >> ${1} 2>&1
185
if [[ ${outputMsg} =~ "E:" ]]; then
186
echo "ERROR: Could not install liblogger-syslog-perl."
187
errorFlag=${TRUE}
188
fi
189
echo "" >> ${1}
190
echo "" | tee -a ${1}
191
192
# Install The KSH Linux Library (For TSA MP)
193
echo "Installing the ksh package." | tee -a ${1}
194
echo "" >> ${1}
195
outputMsg=$(apt-get -y install ksh 2>&1)
196
echo "${outputMsg}" >> ${1} 2>&1
197
if [[ ${outputMsg} =~ "E:" ]]; then
198
echo "ERROR: Could not install ksh."
199
errorFlag=${TRUE}
200
fi
201
echo "" >> ${1}
202
echo "" | tee -a ${1}
203
204
# Install The OPENSSH-SERVER Linux Library (For Data Server Manager)
205
echo "Installing the openssh-server package." | tee -a ${1}
206
echo "" >> ${1}
207
outputMsg=$(apt-get -y install openssh-server 2>&1)
208
echo "${outputMsg}" >> ${1} 2>&1
209
if [[ ${outputMsg} =~ "E:" ]]; then
210
echo "ERROR: Could not install openssh-server."
211
errorFlag=${TRUE}
212
fi
213
echo "" >> ${1}
214
echo "" | tee -a ${1}
215
216
# Install The NET-TOOLS Linux Library (For Data Server Manager)
217
echo "Installing the net-tools package." | tee -a ${1}
218
echo "" >> ${1}
219
outputMsg=$(apt-get -y install net-tools 2>&1)
220
echo "${outputMsg}" >> ${1} 2>&1
221
if [[ ${outputMsg} =~ "E:" ]]; then
222
echo "ERROR: Could not install net-tools."
223
errorFlag=${TRUE}
224
fi
225
echo "" >> ${1}
226
echo "" | tee -a ${1}
227
228
# Remove Packages That Are No Longer Needed
229
echo "Removing dependency packages that are no longer needed." | tee -a ${1}
230
echo "" >> ${1}
231
outputMsg=$(apt-get -y autoremove 2>&1)
232
echo "${outputMsg}" >> ${1} 2>&1
233
if [[ ${outputMsg} =~ "E:" ]]; then
234
echo "ERROR: Could not remove unused packages."
235
errorFlag=${TRUE}
236
fi
237
echo "" >> ${1}
238
echo "" | tee -a ${1}
239
240
# Generate A New List Of All Packages Installed On The System
241
echo "Updating the installed package list." | tee -a ${1}
242
echo "" >> ${1}
243
outputMsg=$(apt-get update 2>&1)
244
echo "${outputMsg} Done." >> ${1} 2>&1
245
if [[ ${outputMsg} =~ "E:" ]]; then
246
echo "ERROR: Could not update the installed package list."
247
errorFlag=${TRUE}
248
fi
249
echo "" >> ${1}
250
echo "" | tee -a ${1}
251
252
# Write An Appropriate Message To The Log File
253
if [[ ${errorFlag} -eq ${TRUE} ]]; then
254
echo "Problem(s) encountered. Refer to the file \"${1}\" for more information."
255
returnCode=${FALSE}
256
else
257
date >> ${1} 2>&1
258
echo "Finished installing the libraries needed for Db2." | tee -a ${1}
259
echo "" | tee -a ${1}
260
returnCode=${TRUE}
261
fi
262
263
# Return The Appropriate Value To The Calling Function
264
return ${returnCode}
265
}
266
267
268
#-------------------------------------------------------------------------------------------------#
269
# NAME: create_db2_users() #
270
# #
271
# PURPOSE: This function creates the users and groups that are needed by Db2. #
272
# #
273
# PARAMETERS: $1 - Log file name #
274
# #
275
# RETURNS: TRUE (1) - The users and groups needed were successfully created #
276
# FALSE (0) - The users and groups needed were not created #
277
#-------------------------------------------------------------------------------------------------#
278
function create_db2_users
279
{
280
# Define All Local Variables Used
281
local returnCode=${returnCode:=0} # Function Return Code
282
local errorFlag=${errorFlag:=0} # Error Encountered Flag
283
local outputMsg=${outputMsg:=''} # Command Output Message Text
284
285
# Initialize The Appropriate Memory Variables
286
returnCode=${FALSE}
287
errorFlag=${FALSE}
288
289
# Create A User Group Named "db2iadm1"
290
echo "Creating a group named \"db2iadm1\"." | tee -a ${1}
291
outputMsg=$(groupadd db2iadm1 2>&1)
292
returnCode=$?
293
if [ ${returnCode} != 0 ] && [ ${returnCode} != 9 ]; then
294
echo "ERROR: Could not create the \"db2iadm1\" group." | tee -a ${1}
295
echo " ${outputMsg}" >> ${1} 2>&1
296
errorFlag=${TRUE}
297
fi
298
echo "" | tee -a ${1}
299
300
# Create A User Group Named "db2fadm1"
301
echo "Creating a group named \"db2fadm1\"." | tee -a ${1}
302
outputMsg=$(groupadd db2fadm1 2>&1)
303
returnCode=$?
304
if [ ${returnCode} != 0 ] && [ ${returnCode} != 9 ]; then
305
echo "ERROR: Could not create the \"db2fadm1\" group." | tee -a ${1}
306
echo " ${outputMsg}" >> ${1} 2>&1
307
errorFlag=${TRUE}
308
fi
309
echo "" | tee -a ${1}
310
311
# Create A User Named "db2inst1"
312
echo "Creating a user named \"db2inst1\" (with a home directory)." | tee -a ${1}
313
outputMsg=$(useradd -g db2iadm1 -m -d /home/db2inst1 -s /bin/bash db2inst1 2>&1)
314
returnCode=$?
315
if [ ${returnCode} != 0 ] && [ ${returnCode} != 9 ]; then
316
echo "ERROR: Could not create a user named \"db2inst1\"." | tee -a ${1}
317
echo " ${outputMsg}" >> ${1} 2>&1
318
errorFlag=${TRUE}
319
fi
320
321
# Set The Password For The User Just Created To "ibmdb2"
322
outputMsg=$(echo -e "ibmdb2\nibmdb2" | passwd db2inst1 2>&1)
323
returnCode=$?
324
if [ ${returnCode} != 0 ]; then
325
echo "ERROR: Could not assign a password to the user named \"db2inst1\"." | tee -a ${1}
326
echo " ${outputMsg}" >> ${1} 2>&1
327
errorFlag=${TRUE}
328
else
329
echo " Password for user \"db2inst1\" has been set to \"ibmdb2\"." | tee -a ${1}
330
fi
331
echo "" | tee -a ${1}
332
333
# Create A User Named "db2fenc1"
334
echo "Creating a user named \"db2fenc1\" (with a home directory)." | tee -a ${1}
335
outputMsg=$(useradd -g db2fadm1 -m -d /home/db2fenc1 -s /bin/bash db2fenc1 2>&1)
336
returnCode=$?
337
if [ ${returnCode} != 0 ] && [ ${returnCode} != 9 ]; then
338
echo "ERROR: Could not create a user named \"db2fenc1\"." | tee -a ${1}
339
echo " ${outputMsg}" >> ${1} 2>&1
340
errorFlag=${TRUE}
341
fi
342
343
# Set The Password For The User Just Created To "ibmdb2"
344
outputMsg=$(echo -e "ibmdb2\nibmdb2" | passwd db2fenc1 2>&1)
345
returnCode=$?
346
if [ ${returnCode} != 0 ]; then
347
echo "ERROR: Could not create a user named \"db2fenc1\"." | tee -a ${1}
348
echo " ${outputMsg}" >> ${1} 2>&1
349
errorFlag=${TRUE}
350
else
351
echo " Password for user \"db2fenc1\" has been set to \"ibmdb2\"." | tee -a ${1}
352
fi
353
echo "" | tee -a ${1}
354
355
# Write An Appropriate Message To The Log File
356
if [[ ${errorFlag} -eq ${TRUE} ]]; then
357
echo "Problem(s) encountered. Refer to the file \"${1}\" for more information."
358
returnCode=${FALSE}
359
else
360
date >> ${1} 2>&1
361
echo "Finished creating the users and groups needed for Db2." | tee -a ${1}
362
echo "" | tee -a ${1}
363
returnCode=${TRUE}
364
fi
365
366
# Return The Appropriate Value To The Calling Function
367
return ${returnCode}
368
}
369
370
371
#-------------------------------------------------------------------------------------------------#
372
# NAME: install_db2() #
373
# #
374
# PURPOSE: This function installs the Db2 software and creates an instance and instance #
375
# user. #
376
# #
377
# PARAMETERS: $1 - Log file name #
378
# $2 - Db2 tarball file name #
379
# $3 - Db2 installation software location #
380
# $4 - Db2 software installation directory #
381
# #
382
# RETURNS: TRUE (1) - Db2 was successfully installed #
383
# FALSE (0) - Db2 was not installed #
384
#-------------------------------------------------------------------------------------------------#
385
function install_db2
386
{
387
# Define All Local Variables Used
388
local returnCode=${returnCode:=0} # Function Return Code
389
local errorFlag=${errorFlag:=0} # Error Encountered Flag
390
local outputMsg=${outputMsg:=''} # Command Output Message Text
391
local fileName=${fileName:=''} # Current Working File Name
392
local softwareDir=${softwareDir:=''} # Db2 Installation Software Location (Directory)
393
local installDir=${installDir:=''} # Db2 Software Installation Directory
394
local TivoliDir=${TivoliDir:=''} # Tivoli Installation Software Location (Directory)
395
396
# Initialize The Appropriate Memory Variables
397
returnCode=${FALSE}
398
errorFlag=${FALSE}
399
fileName=${2}
400
softwareDir=${3}
401
installDir="${4}/instance"
402
403
# Untar The File That Contains The Db2 Software, Then Delete It
404
if [ -f ${fileName} ]; then
405
echo "Untaring the file \"${fileName}\"." | tee -a ${1}
406
outputMsg=$(tar -xvf ${fileName} 2>&1)
407
returnCode=$?
408
if [ ${returnCode} != 0 ]; then
409
echo "ERROR: Could not untar the file \"${fileName}\"." | tee -a ${1}
410
echo " ${outputMsg}" >> ${1} 2>&1
411
returnCode=${FALSE}
412
return ${returnCode}
413
else
414
echo "${outputMsg}" >> ${1} 2>&1
415
rm ${fileName} 2>&1
416
fi
417
echo "" | tee -a ${1}
418
fi
419
420
# Create A Software Storage Directory
421
outputMsg=$(mkdir ${softwareDir} 2>&1)
422
returnCode=$?
423
if [ ${returnCode} != 0 ]; then
424
echo "ERROR: Could not create the \"${softwareDir}\" directory." | tee -a ${1}
425
echo " ${outputMsg}" >> ${1} 2>&1
426
returnCode=${FALSE}
427
return ${returnCode}
428
fi
429
430
# Change The Permissions Of The Software Storage Directory So Anyone Can Access It
431
outputMsg=$(chmod 777 ${softwareDir} 2>&1)
432
returnCode=$?
433
if [ ${returnCode} != 0 ]; then
434
echo -e "ERROR: Could not "
435
echo "change permissions for the \"${software_Dir}\" directory." | tee -a ${1}
436
echo " ${outputMsg}" >> ${1} 2>&1
437
returnCode=${FALSE}
438
return ${returnCode}
439
fi
440
441
# Move The Db2 Installation Software To The Software Storage Directory
442
softwareDir="${softwareDir}/ibm-db2"
443
outputMsg=$(mv server_dec ${softwareDir} 2>&1)
444
returnCode=$?
445
if [ ${returnCode} != 0 ]; then
446
echo -e "ERROR: Could not "
447
echo "move the Db2 software to the \"${softwareDir}\" directory." | tee -a ${1}
448
echo " ${outputMsg}" >> ${1} 2>&1
449
returnCode=${FALSE}
450
return ${returnCode}
451
fi
452
453
# Change The Permissions Of The Db2 Installation Software Storage Directory So Anyone
454
# Can Access It
455
outputMsg=$(chmod 777 -R ${softwareDir} 2>&1)
456
returnCode=$?
457
if [ ${returnCode} != 0 ]; then
458
echo "ERROR: Could not change permissions for the \"${softwareDir}\" directory." | tee -a ${1}
459
echo " ${outputMsg}" >> ${1} 2>&1
460
returnCode=${FALSE}
461
return ${returnCode}
462
fi
463
464
# Move To The Directory Where The Db2 Installation Software Resides
465
cd ${softwareDir}
466
467
# Install The Db2 Software
468
echo "Running the program \"db2_install\"." | tee -a ${1}
469
outputMsg=$(echo -e "yes\nSERVER" | ./db2_install -y -f NOTSAMP 2>&1)
470
returnCode=$?
471
if [ ${returnCode} != 0 ]; then
472
echo "ERROR: Problem encountered running the \"db2_install\" program." | tee -a ${1}
473
echo " ${outputMsg}" >> ${1} 2>&1
474
returnCode=${FALSE}
475
return ${returnCode}
476
fi
477
echo "${outputMsg}" >> ${1} 2>&1
478
echo "" | tee -a ${1}
479
480
# Move To The Directory Where The Tivoli System Automation for Multiplatforms (SA MP)
481
# Software Resides
482
TivoliDir="${softwareDir}/db2/linuxamd64/tsamp"
483
cd ${TivoliDir}
484
485
# Install The Tivoli SA MP Software
486
echo "Running the program \"installSAM\"." | tee -a ${1}
487
outputMsg=$(./installSAM --noprereqcheck --noliccheck --silent 2>&1)
488
returnCode=$?
489
if [ ${returnCode} != 0 ]; then
490
echo "ERROR: Problem encountered running the \"installSAM\" program." | tee -a ${1}
491
echo " ${outputMsg}" >> ${1} 2>&1
492
returnCode=${FALSE}
493
return ${returnCode}
494
fi
495
echo "${outputMsg}" >> ${1} 2>&1
496
echo "" | tee -a ${1}
497
498
# Move To The Directory Where The Software Needed To Create A Db2 Instance Resides
499
cd ${installDir}
500
501
# Create A Db2 Instance
502
echo "Creating a Db2 instance named \"db2inst1\"." | tee -a ${1}
503
outputMsg=$(./db2icrt -u db2fenc1 db2inst1 2>&1)
504
returnCode=$?
505
if [ ${returnCode} != 0 ]; then
506
echo "ERROR: Problem encountered creating a Db2 instance." | tee -a ${1}
507
echo " ${outputMsg}" >> ${1} 2>&1
508
returnCode=${FALSE}
509
return ${returnCode}
510
fi
511
echo "${outputMsg}" >> ${1} 2>&1
512
echo "" | tee -a ${1}
513
514
# Return The Appropriate Value To The Calling Function
515
returnCode=${TRUE}
516
return ${returnCode}
517
}
518
519
520
#=================================================================================================#
521
# NAME: main() #
522
# #
523
# PURPOSE: This is the main body of the script. #
524
# #
525
# PARAMETERS: $1 - Script key word #
526
# $2 - Option #
527
# #
528
# RETURNS: 0 - The script executed successfully #
529
# 1 - The script did NOT execute successfully #
530
#=================================================================================================#
531
532
# Define All Variables Used
533
TRUE=${TRUE:=1} # Boolean TRUE
534
FALSE=${FALSE:=0} # Boolean FALSE
535
536
currentDir=${currentDir:=''} # Current Working Directory
537
logFile=${logFile:=''} # Log File Name
538
Db2CodeFile=${Db2CodeFile:=''} # Db2 Install Code TAR File Name
539
timeStamp=${timeStamp:=''} # Current Date And Time Value
540
541
# Initialize The Appropriate Memory Variables
542
currentDir=$(pwd)
543
logFile="${currentDir}/db2_env_setup.log"
544
Db2CodeFile="${currentDir}/v11.5.7_linuxx64_server_dec.tar"
545
Db2SoftwareDir="/home/Software"
546
Db2InstallDir="/opt/ibm/db2/V11.5/"
547
timeStamp=$(date '+%m-%d-%Y:%H-%M-%S')
548
549
# Clear The Screen
550
clear
551
552
# If The File Containing The Db2 Developer Edition Software Does Not Exist, Display An Error Message
553
# And Return Control To The Operating System
554
if [ ! -f ${Db2CodeFile} ]; then
555
echo "ERROR: Unable to locate the file \"${Db2CodeFile}\"." | tee -a ${logFile}
556
echo "" | tee -a ${logFile}
557
exit 1
558
fi
559
560
# Create A Log File In The Current Directory And Write Header Information To It
561
init_log_file ${logFile}
562
563
# Display A "Setting Up" Message
564
date >> ${logFile} 2>&1
565
echo "Setting up the Db2 prerequisite software needed. Please wait ..." | tee -a ${logFile}
566
echo "" | tee -a ${logFile}
567
568
# Install The Db2 Prerequisite Libraries Needed For Ubuntu Linux
569
install_db2_prereq_libraries ${logFile}
570
returnCode=$?
571
if [ ${returnCode} == ${FALSE} ]; then
572
exit 1
573
fi
574
575
# Create The Users Needed For Db2
576
date >> ${logFile} 2>&1
577
echo "Creating the appropriate Db2 instance users and groups. Please wait ..." | tee -a ${logFile}
578
echo "" | tee -a ${logFile}
579
create_db2_users ${logFile}
580
returnCode=$?
581
if [ ${returnCode} == ${FALSE} ]; then
582
exit 1
583
fi
584
585
# Install The Db2 Software And Create A Default Db2 Instance
586
date >> ${logFile} 2>&1
587
echo "Installing the Db2 software and creating a Db2 instance. Please wait ..." | tee -a ${logFile}
588
echo "" | tee -a ${logFile}
589
install_db2 ${logFile} ${Db2CodeFile} ${Db2SoftwareDir} ${Db2InstallDir}
590
returnCode=$?
591
if [ ${returnCode} == ${FALSE} ]; then
592
exit 1
593
fi
594
595
# Write The End Timestamp To the Log File
596
date >> ${logFile} 2>&1
597
echo "Finished installing db2." >> ${logFile}
598
599
# Display A "Finished" Message And Write A "Finished" Message To The Log File
600
echo "Finished! Refer to the file \"${logFile}\" for more information."
601
echo ""
602
603
# Exit And Return Control To The Operating System
604
exit 0
605
606