4
source charms.reactive.sh
6
ARCHITECTURE=`uname -m`
7
ARCHIVE_DIR=$CHARM_DIR/files/archives
11
DB2_INSTALL_PATH=/opt/ibm/db2/V10.5
12
AUTH_KEY_FILE=/root/.ssh/authorized_keys
17
remoteunit=$cfgusername
22
#Get the cfguser name based on the remote unit name
29
cfgusername=`echo $cfgusername | cut -d"/" -f1`
30
cfgusername=`echo "$cfgusername" | sed -r 's/-//g' | sed -r 's/ibm//g'`
31
cfgusername=`echo "$cfgusername" | awk '{print substr($0,0,5)}'`
32
remoteunit=$cfgusername
33
cfgusername="$cfgusername$usr"
34
cfgpasswd="$cfgusername$passwd"
35
remoteunitdbname="$remoteunit$db"
38
# Check whether DB2 is installed
41
if [ -d $DB2_INSTALL_PATH/bin ]; then
49
# Remove DB2, if installed
52
db2_inst=`is_db2_installed`
53
if [ $db2_inst == True ]; then
54
juju-log "IBM DB2: Removing IBM DB2 software."
55
status-set maintenance "Removing IBM DB2"
57
#finding the DB alias names to be dropped and dropping all Databases in that
58
for queue1 in `su - $DB2_USER -c 'db2ilist'`;
60
juju-log "IBM DB2: Dropping the Databases for the instance $queue1"
61
#if db2 is not running, we need to start it first, otherwise db2 drop command will fail
62
if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1;
64
juju-log "IBM DB2: DB2 already started for the user $queue1"
66
su - $queue1 -c 'db2start'
67
juju-log "IBM DB2: DB2 is started"
70
for queue in `su - $queue1 -c 'db2 list db directory | grep "Database alias" | cut -d"=" -f2'`;
72
queue=`echo $queue | xargs`
73
juju-log "IBM DB2: Dropping the DB $queue"
74
su - $queue1 -c 'db2 drop database '$queue
76
juju-log "IBM DB2: Dropped the DB $queue"
78
juju-log "IBM DB2: Dropping the DB $queue failed"
79
status-set blocked "Dropping the DB failed"
83
juju-log "IBM DB2: Stopping the DB for $queue1"
85
if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1
87
su - $queue1 -c 'db2 force application all'
88
su - $queue1 -c 'db2stop'
90
juju-log "IBM DB2: Stopped the DB for the instance $queue1"
92
juju-log "IBM DB2: Stopping the DB for $queue1 failed"
93
status-set blocked "Stopping the DB for $queue1 failed"
98
juju-log "IBM DB2: DB2 is already stopped"
103
cd $DB2_INSTALL_PATH/instance
104
juju-log "IBM DB2: Dropping the DAS"
107
juju-log "IBM DB2: Dropped the DAS"
109
juju-log "IBM DB2: Dropping the DAS failed"
110
status-set blocked "Dropping the DAS failed"
114
#delete the instances
115
su - $DB2_USER -c 'db2ilist'
116
for queue1 in `su - $DB2_USER -c 'db2ilist'`;
118
juju-log "IBM DB2: Deleting the instance $queue1"
119
/opt/ibm/db2/V10.5/instance/db2idrop $queue1
121
juju-log "IBM DB2: Deleted the instance $queue1"
123
juju-log "IBM DB2: Deleting the instance $queue1 failed"
124
status-set blocked "Deleting the instance $queue1 failed"
130
#Delete the instance entries from /etc/services file
131
juju-log "IBM DB2: Deleting the entries from /etc/services"
132
sed -i '/db2c_/d' /etc/services
134
juju-log "IBM DB2: Deleted the entries from /etc/services"
136
juju-log "IBM DB2: Deletion of the entries from /etc/services failed"
137
status-set blocked "Deletion of the entries from /etc/services failed"
142
juju-log "IBM DB2: Uninstall "
143
cd /opt/ibm/db2/V10.5/install
147
juju-log "IBM DB2: Uninstall of db2 successful"
149
juju-log "IBM DB2: Uninstall of db2 failed"
150
status-set blocked "IBM DB2 Uninstallation failed"
156
juju-log "IBM DB2: Finished Uninstalling......."
157
status-set blocked "IBM DB2 Uninstalled"
160
juju-log "IBM DB2: DB2 not installed"
165
# Update system configuration after installing DB2
168
juju-log "IBM DB2: Updating system configuration."
169
cd $DB2_INSTALL_PATH/instance
170
su - $DB2_USER -c 'db2set DB2COMM=tcpip'
172
#Start DB for the DB2_user
173
if su - $DB2_USER -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$DB2_USER;
175
juju-log "IBM DB2: DB2 already started for the user $DB2_USER"
177
su - $DB2_USER -c 'db2start'
178
juju-log "IBM DB2: DB2 is started"
181
service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'`
182
port_num=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2`
183
port_num=`echo $port_num | xargs`
184
if su - $DB2_USER -c 'netstat -an | grep '$port_num;
186
juju-log "IBM DB2: DB2 started on port $port_num"
188
juju-log "IBM DB2: DB2 not started on port $port_num"
192
juju-log "IBM DB2: Updated system configuration."
197
configure_dftdbpath()
199
db2_inst=`is_db2_installed`
200
if [ $db2_inst == True ]; then
201
cfgdbpath=`config-get dftdbpath`
202
#If null, assign the default value
203
if [ "cfgdbpath" == "" ]
208
for queue1 in `su - $DB2_USER -c 'db2ilist'`;
210
#if db2 is not running don't do anything
211
if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1;
213
su - $queue1 -c 'db2 attach to '$queue1
214
dbpath=`su - $queue1 -c 'db2 get dbm cfg|grep -i DFTDBPATH|cut -d"=" -f2'`
215
cfgdbpath=`echo $cfgdbpath | xargs`
216
dbpath=`echo $dbpath | xargs`
217
if [ "$cfgdbpath" != "$dbpath" ]; then
218
if [ -d "$cfgdbpath" ]; then
219
su - $queue1 -c 'db2 update dbm cfg using DFTDBPATH '$cfgdbpath
221
juju-log "IBM DB2: DFTDBPATH changed to $cfgdbpath"
223
juju-log "IBM DB2: Unable to set DFTDBPATH to $cfgdbpath"
227
juju-log "IBM DB2: Not a valid path. Please check the path and run the command again"
234
juju-log "IBM DB2: DB2 is not installed. Install DB2 to change the dbpath"
238
# Edit the response file for UID
241
rsp_file=db2server_temp.rsp
242
if [ "$ARCHITECTURE" = "x86_64" ]; then
243
orgrsp_file=db2server.rsp
245
orgrsp_file=db2server_ppcle.rsp
247
cp $CHARM_DIR/files/archives/$orgrsp_file $CHARM_DIR/files/archives/$rsp_file
249
db2uid=`id $DB2_USER | cut -d"=" -f2 | cut -d"(" -f1`
250
sed -i s/db2inst1_uid/$db2uid/g $CHARM_DIR/files/archives/$rsp_file
251
sed -i s/db2inst1_gid/$db2uid/g $CHARM_DIR/files/archives/$rsp_file
252
sed -i s/db2inst1_homedir/$DB2_USER/g $CHARM_DIR/files/archives/$rsp_file
253
sed -i s/db2inst1_password/$DB2_USER_PW/g $CHARM_DIR/files/archives/$rsp_file
255
db2fenid=`id db2fenc1 | cut -d"=" -f2 | cut -d"(" -f1`
256
sed -i s/db2fenc1_uid/$db2fenid/g $CHARM_DIR/files/archives/$rsp_file
257
sed -i s/db2fenc1_gid/$db2fenid/g $CHARM_DIR/files/archives/$rsp_file
258
dasuid=`id dasusr1 | cut -d"=" -f2 | cut -d"(" -f1`
259
sed -i s/das_uid/$dasuid/g $CHARM_DIR/files/archives/$rsp_file
260
sed -i s/das_gid/$dasuid/g $CHARM_DIR/files/archives/$rsp_file
269
db2_inst=`is_db2_installed`
270
get_cfgusername $servicename
271
if [ $db2_inst == True ]; then
272
status-set maintenance "Creating Users"
273
#Find the group id for db2inst1 user which is used to install db2 and find all
274
#users belonging to this user
275
db2inst1grpid=`id $DB2_USER | cut -d" " -f2`
277
#If the user is already available, just change the password.
278
for queue2 in `awk -F':' '{ print $1}' /etc/passwd`;
280
gid=`id $queue2 | cut -d" " -f2`
281
if [ $gid == $db2inst1grpid ]; then
282
if [ $queue2 != "$DB2_USER" ]; then
283
if [ $cfgusername == $queue2 ]; then
284
juju-log "IBM DB2: Changing the password for the user $cfgusername to $cfgpasswd"
285
echo $cfgusername:$cfgpasswd | chpasswd
287
juju-log "IBM DB2: Changed the password for the user $cfgusername to $cfgpasswd"
293
#If not available, add a new user
294
if [ $passwdchanged != 1 ]; then
295
juju-log "IBM DB2: Creating New user"
296
create_newuser $servicename
297
juju-log "IBM DB2: Created New user"
298
juju-log $cfgusername
300
#Creating a new instance for the new user if not existing
302
for queue1 in `su - $DB2_USER -c 'db2ilist'`;
304
if [ $queue1 == $cfgusername ]; then
308
if [ $instance_exists != 1 ]; then
309
juju-log "IBM DB2: Creating new instance for the user"
310
/opt/ibm/db2/V10.5/instance/db2icrt -u $cfgusername $cfgusername
312
juju-log "IBM DB2: Created new instance for the user"
314
juju-log "IBM DB2: Creation of new instance failed"
319
#Do the configuration for the new instance created
323
#Check whether the port number is already in etc/services file, and then add it
325
if grep -q "db2c_$cfgusername" services
327
juju-log "IBM DB2: Services file already updated"
329
while [ $free_port == 0 ]
331
is_free=`netstat -lnp | grep $new_port | cut -d":" -f2 | cut -d" " -f1`
332
if [ "$is_free" != "$new_port" ]; then
335
new_port=$((new_port+1))
338
juju-log "IBM DB2:Updating Services file"
339
echo -e "db2c_$cfgusername $new_port/tcp" >> /etc/services
340
su - $cfgusername -c 'set db2instance=$cfgusername'
341
su - $cfgusername -c 'db2set DB2COMM=tcpip'
342
new_port=`echo $new_port | xargs`
343
#port_num_consumer=$new_port
344
su - $cfgusername -c 'db2 update dbm cfg using svcename '$new_port
345
/opt/ibm/db2/V10.5/instance/db2iupdt $cfgusername
349
#Start DB for the new user
350
if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername;
352
juju-log "IBM DB2: DB2 already started for the user $cfgusername"
354
su - $cfgusername -c 'db2start'
355
juju-log "IBM DB2: DB2 is started"
357
#set_state 'db.dbstarted'
360
juju-log "IBM DB2: DB2 is not installed. Install DB2 before creating users"
364
status-set maintenance "Created DB user and Instance"
372
get_cfgusername $servicename
373
useradd -g db2grp1 -G dasadm1 -m $cfgusername
375
juju-log "IBM DB2: Addition of user $queue2 failed."
376
status-set blocked "Addition of new used failed, Try again"
379
#Set the password for the new user
380
echo $cfgusername:$cfgpasswd | chpasswd
382
juju-log "IBM DB2: Setting password for user $queue2 failed."
383
status-set blocked "Setting the password for user failed, Try again"
386
#Check whether test DB already exists. If not create it
388
dbname=`su - $DB2_USER -c 'db2 list db directory' | grep "Database name" | grep -i "\bTEST\b" | cut -d"=" -f2`
389
dbname=`echo $dbname | xargs`
390
if [ "$dbname" != "TEST" ]; then
391
juju-log "IBM DB2: Creating DB Test"
392
su - $DB2_USER -c 'db2 create database test'
394
juju-log "IBM DB2: DB creation failed"
395
status-set blocked "DB creation failed, Try again"
398
juju-log "IBM DB2: Created DB Test"
400
#Connect to the DB and grant data access
401
su - $DB2_USER -c 'db2 connect to test;db2 grant dataaccess on database to user '$cfgusername
403
juju-log "IBM DB2: Grant access failed"
404
status-set blocked "Grant dataaccess on database failed, Try again"
407
su - $DB2_USER -c 'db2 connect to test;db2 disconnect test'
409
juju-log "IBM DB2: Disconnect DB failed"
410
status-set blocked "Disconnect DB failed"
421
get_cfgusername $servicename
422
#create the db for $dbnametocreate if it doesn't exist
423
dbname=`su - $cfgusername -c 'db2 list db directory' | grep "Database name" | grep -i "\b$dbtocreate\b" | cut -d"=" -f2`
424
dbname=`echo $dbname | xargs`
425
dbname=`echo "$dbname" | awk '{ print tolower($1) }'`
426
dbtocreate=`echo "$dbtocreate" | awk '{ print tolower($1) }'`
427
#check whether dbname is more than 8 chars
428
if [ ${#dbtocreate} -gt 8 ]; then
429
juju-log "IBM DB2: Failed to create DB $dbtocreate. DB name should be <= 8 chars"
430
#status-set blocked "DB creation for $dbtocreate failed as it contains more than 8 chars"
432
if [ "$dbname" != "$dbtocreate" ]; then
433
juju-log "IBM DB2: Creating DB $dbtocreate"
434
su - $cfgusername -c 'db2 create database '$dbtocreate
436
juju-log "IBM DB2: DB creation failed"
437
status-set blocked "DB creation failed, Try again"
440
juju-log "IBM DB2: Created DB $dbtocreate"
450
dbnames=$(relation_call --state=db.connected get_dbnames $servicename) || true
452
#If dbnames is null, create a default DB as per service name. Else create the DBs requested by the related charm
453
if [ -z "$dbnames" ] ; then
454
juju-log "IBM DB2: Creating a default DB $remoteunitdbname based on remote service name"
455
create_database $remoteunitdbname $servicename
456
if [ $isdbcreated == 1 ] ; then
457
dbs_created+=$remoteunitdbname
460
elif [ "$dbnames" == "None" ]; then
461
juju-log "IBM DB2: DB name caught as None, Creating default DB $remoteunitdbname based on remote service name"
462
create_database $remoteunitdbname $servicename
463
if [ $isdbcreated == 1 ] ; then
464
dbs_created+=$remoteunitdbname
468
juju-log "IBM DB2: Creating the DB names as passed by consumer"
469
if [ `echo $dbnames | grep -c "," ` -gt 0 ]
471
#parse the $dbnames string to get the names of dbs to be created
474
while [ "$db_to_create" != "" ]
476
db_to_create=`echo $dbnames | cut -d"," -f$count`
477
juju-log "IBM DB2:db_to_create is $db_to_create"
478
if [ "$db_to_create" != "" ] ; then
479
create_database $db_to_create $servicename
480
juju-log "Created DB $db_to_create"
481
if [ $isdbcreated == 1 ] ; then
482
dbs_created+=$db_to_create
488
juju-log "Suchitra - outside loop"
491
create_database $dbnames $servicename
492
juju-log "Created DB $dbnames"
493
dbs_created+=$dbnames
505
#Read the key from the key.txt file and see whether it exists
506
if grep -q "$servicename" $TEMP_KEY_FILE
508
key=`cat $TEMP_KEY_FILE | grep $servicename | cut -d":" -f2`
509
grep -v "$key" $AUTH_KEY_FILE > tempfile.txt
510
mv tempfile.txt $AUTH_KEY_FILE
511
if grep -q "$key" $AUTH_KEY_FILE
513
juju-log "IBM DB2: SSH Key not deleted from $AUTH_KEY_FILE"
515
juju-log "IBM DB2: SSH Key deleted from $AUTH_KEY_FILE"
517
#Remove from the temporary file as well
518
grep -v "$servicename:$key" $TEMP_KEY_FILE > tempfile1.txt
519
mv tempfile1.txt $TEMP_KEY_FILE
520
if grep -q "$key" $TEMP_KEY_FILE
522
juju-log "IBM DB2: SSH Key not deleted from $TEMP_KEY_FILE"
524
juju-log "IBM DB2: SSH Key deleted from $TEMP_KEY_FILE"
532
@when 'ibm-db2.installed'
533
@when_not 'ibm-base.license.accepted'
534
function uninstall(){
535
juju-log "IBM DB2: Removing IBM DB2 (if installed) as the license agreement is not accepted."
536
status-set maintenance "IBM DB2 is getting uninstalled"
538
remove_state 'ibm-db2.installed'
539
#remove_state 'ibm-db2.client.sshconfigured'
540
set_state 'ibm-db2.uninstalled'
541
status-set maintenance "IBM DB2 is uninstalled"
542
rm -rf $TEMP_KEY_FILE
546
#Setting the interface states after uninstall
547
@when 'ibm-db2.uninstalled'
549
function reset_interface_states(){
550
services=$(relation_call --state=db.connected services) || true
551
for service in $services; do
552
juju-log "IBM DB2: Resetting states for the service $service"
553
relation_call --state=db.connected dismiss_sshconfigured $service || true
554
relation_call --state=db.connected reset_states $service || true
557
remove_state 'ibm-db2.uninstalled'
561
@when_not 'ibm-db2.prereqsinstalled'
564
juju-log "IBM DB2: Begin Install."
566
status-set maintenance "Installing pre requisites for IBM DB2"
567
juju-log "IBM DB2: Installing binutils"
568
juju-log "IBM DB2: Installed binutils"
569
if [ "$ARCHITECTURE" != "x86_64" -a "$ARCHITECTURE" != "ppc64le" ]; then
570
juju-log "IBM DB2: Unsupported platform. IBM DB2 installed with this Charm supports only the x86_64 and POWER LE (ppc64le) platforms."
574
if [ "$ARCHITECTURE" == "x86_64" ]; then
575
juju-log "IBM DB2: Installing 32 bit libstdc++.so.6"
577
apt-get install lib32stdc++6 -y
578
juju-log "IBM DB2: Installed 32 bit libstdc++.so.6"
580
if [ "$ARCHITECTURE" == "ppc64le" ]; then
581
juju-log "IBM DB2: Installing libnuma package for POWER LE (ppc64le) platforms."
582
apt-get install libnuma-dev -y
583
#Installing XL compiler runtime packages for Linux on Power as this is one of the prerequisite software/configuration requirements
584
echo "deb http://public.dhe.ibm.com/software/server/POWER/Linux/rte/xlcpp/le/ubuntu $(lsb_release -s -c) main" | tee -a /etc/apt/sources.list.d/ibm-xlcpp-rte.list
586
apt-get install libxlc -y --force-yes
587
juju-log "IBM DB2: Installed libnuma package for POWER LE (ppc64le) platforms."
590
#create the userids required for db2 installation
594
juju-log "IBM DB2: Creating the user ids for db2 installation"
599
useradd -g db2grp1 -G dasadm1 -m $DB2_USER
600
echo $DB2_USER:$DB2_USER_PW | chpasswd
601
useradd -g dasadm1 -G db2grp1 -m dasusr1
602
echo dasusr1:dasusr1 | chpasswd
603
useradd -g db2fgrp1 -m db2fenc1
604
echo db2fenc1:db2fenc1 | chpasswd
606
juju-log "IBM DB2: Created the user ids for db2 installation"
607
status-set maintenance "Installed pre requisites for IBM DB2"
608
set_state 'ibm-db2.prereqsinstalled'
611
@when 'ibm-db2.prereqsinstalled' 'ibm-base.license.accepted' 'ibm-base.curl.resource.fetched'
612
@when_not 'ibm-db2.installed'
614
juju-log "IBM DB2: License accepted"
615
db2_inst=`is_db2_installed`
616
if [[ ! -d $ARCHIVE_DIR ]]; then
619
#Install if download succeeded
620
if [ $db2_inst == False ]; then
621
if [ -f $ARCHIVE_DIR/*.gz ]; then
623
cd $CHARM_DIR/files/archives
624
tar -zxvf $ARCHIVE_DIR/*.gz
626
juju-log "IBM DB2: Unable to extract the DB2 package content. Verify whether the package is corrupt."
627
status-set maintenance "Unable to extract the DB2 package content"
628
#Remove corrupt archive file
629
rm -rf $ARCHIVE_DIR/*.gz
632
if [ "$ARCHITECTURE" = "x86_64" ]; then
633
rsp_file=db2server.rsp
635
rsp_file=db2server_ppcle.rsp
638
cd $CHARM_DIR/files/archives/server*
639
juju-log "IBM DB2: Edited the response file"
641
juju-log "IBM DB2: Checking etc/hosts file."
642
private_address=`unit-get private-address`
644
if grep -q "$private_address" hosts
646
juju-log "IBM DB2: Host file already updated"
648
juju-log "IBM DB2: Updating Host file"
649
echo "$private_address `hostname`" >> /etc/hosts
651
juju-log "IBM DB2: Installing db2 package."
652
status-set maintenance "Installing IBM DB2"
654
./db2setup -r $CHARM_DIR/files/archives/$rsp_file
655
juju-log "IBM DB2: Installation of db2 complete."
658
# Configure system values for Db2
662
echo "Tempory Key File" > $TEMP_KEY_FILE
663
set_state 'ibm-db2.installed'
664
remove_state 'ibm-db2.uninstalled'
665
status-set active "IBM DB2 Installed"
668
@when 'config.changed.dftdbpath'
669
function configurevalues(){
673
@when 'ibm-base.license.accepted'
675
function configure_sshkeys(){
676
services=$(relation_call --state=db.connected services)
677
for service in $services; do
678
key=$(relation_call --state=db.connected get_sshkeys $service) || true
679
juju-log "IBM DB2: Received the ssh key $key from the service $service"
681
if [ "$key" == "None" ]; then
682
juju-log "IBM DB2: No data sent yet"
686
# Add the key to the authorized_keys file, if it exists
688
#Create a temp key file if it doesn't exist
689
if [ -f $TEMP_KEY_FILE ]; then
690
juju-log "IBM DB2: Temp file already exists"
692
echo "Temp Key File" > $TEMP_KEY_FILE
694
if [ -f $AUTH_KEY_FILE ]; then
695
# Append only if the key is not present
696
juju-log "IBM DB2: Updating the key file"
697
grep "$key" $AUTH_KEY_FILE > /dev/null
699
juju-log "IBM DB2: Updating authorized keys file"
700
echo "$key" >> $AUTH_KEY_FILE
701
echo "$service:$key" >> $TEMP_KEY_FILE
703
juju-log "IBM DB2: Key already present"
706
juju-log "IBM DB2: Creating authorized keys file"
707
echo "$key" > $AUTH_KEY_FILE
708
echo "$service:$key" > $TEMP_KEY_FILE
710
relation_call --state=db.connected set_sshconfigured $service || true
711
juju-log "IBM DB2: Completed updating the authorized key"
717
@when 'ibm-db2.installed'
718
@when 'db.sshconfigured'
719
function create_consumer_dbs(){
720
DB2_INSTALL_PATH=/opt/ibm/db2/V10.5
721
services=$(relation_call --state=db.connected services)
722
for service in $services; do
724
key=$(relation_call --state=db.connected get_sshkeys $service) || true
725
juju-log "IBM DB2: In create_consumer_dbs function, Received the ssh key $key from the service $service"
727
if [ "$key" == "None" ]; then
728
juju-log "IBM DB2: No data sent yet"
733
#Create the user for the remote unit connected
734
juju-log "IBM DB2: Creating the users for the consumer $service"
737
#Create the DBs after parsing
739
juju-log "IBM DB2: Create DBs completed"
741
get_cfgusername $service
742
service_name=`su - $cfgusername -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'`
743
db2_port=`grep $service_name /etc/services | cut -d"/" -f1 | grep "db2c_$cfgusername" | cut -f2`
744
db2_path="/opt/ibm/db2"
745
hostname=`unit-get private-address`
746
dbusername=$cfgusername
748
db2_instance_name=$cfgusername
751
juju-log "IBM DB2: Sending the DB details to the consumer $service"
752
juju-log "Port number: $db2_port"
753
juju-log "Hostname: $hostname"
754
juju-log "DBusername: $dbusername DBuserpw: $dbuserpw"
755
juju-log "DB Instance name: $db2_instance_name"
756
juju-log "Service: $service_name"
757
juju-log "DBname: $dbs_created"
759
relation_call --state=db.connected set_db_details $service $db2_path $db2_port $hostname $dbusername $dbuserpw $db2_instance_name $dbs_created || true
765
juju-log "IBM DB2: Stopping the DB when relation is broken"
766
services=$(relation_call --state=db.departed services) || true
767
for service in $services; do
768
juju-log "IBM DB2: Service name is $service"
769
get_cfgusername $service
770
if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername
772
su - $cfgusername -c 'db2stop'
773
juju-log "IBM DB2: DB2 stopped for instance $cfgusername"
775
juju-log "IBM DB2: DB2 is already stopped for the instance $cfgusername"
777
#Remove the ssh key entry from ssh keys file
778
remove_sshkeys $service
779
relation_call --state=db.departed dismiss_sshconfigured $service || true
780
relation_call --state=db.departed dismiss $service || true
785
reactive_handler_main