~charmers/charms/trusty/ibm-db2/trunk

« back to all changes in this revision

Viewing changes to hooks/config-changed

  • Committer: Suchitra Venugopal
  • Date: 2016-01-12 08:17:38 UTC
  • Revision ID: suchvenu@in.ibm.com-20160112081738-fintpxlwxvf66di0
DB2 charm code checkin after Canonical Review

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
        juju-log "IBM DB2: Updating system configuration."
230
230
        cd $DB2_INSTALL_PATH/instance
231
231
        su - $DB2_USER -c 'db2set DB2COMM=tcpip'
232
 
        su - $DB2_USER -c 'db2start'
 
232
 
 
233
        #Start DB for the DB2_user
 
234
        if su - $DB2_USER -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$DB2_USER;
 
235
        then
 
236
                juju-log "IBM DB2: DB2 already started for the user $DB2_USER"
 
237
        else
 
238
                su - $DB2_USER -c 'db2start'
 
239
                juju-log "IBM DB2: DB2 is started"
 
240
        fi
 
241
 
233
242
        service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'`
234
243
        port_num=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2`
235
 
        port_num=`echo $port_num | xargs`       
 
244
        port_num=`echo $port_num | xargs`
236
245
        if su - $DB2_USER -c 'netstat -an | grep '$port_num;
237
246
        then
238
247
                juju-log "DB2 started on port $port_num"
240
249
                juju-log "DB2 not started on port $port_num"
241
250
                exit 1
242
251
        fi
243
 
        
 
252
 
244
253
        juju-log "IBM DB2: Updated system configuration."
 
254
 
245
255
}
246
256
#Configure dftdbpath
247
257
configure_dftdbpath()
260
270
                        dbpath=`su - $queue1 -c 'db2 get dbm cfg|grep -i DFTDBPATH|cut -d"=" -f2'`
261
271
                        cfgdbpath=`echo $cfgdbpath | xargs`
262
272
                        dbpath=`echo $dbpath | xargs`
263
 
 
264
273
                        if  [ "$cfgdbpath" != "$dbpath" ]; then
265
274
                                if [ -d "$cfgdbpath" ]; then
266
275
                                        su - $queue1 -c 'db2 update dbm cfg using DFTDBPATH '$cfgdbpath
377
386
                new_port=50001
378
387
                free_port=0
379
388
                is_free=0
380
 
                #while [ $free_port == 0 ] 
381
 
                #do
382
 
                #       is_free=`netstat -lnp | grep $new_port | cut -d":" -f2 | cut -d" " -f1`
383
 
                #       if [ "$is_free" != "$new_port" ]; then
384
 
                #               free_port=1
385
 
                #       else
386
 
                #               new_port=$((new_port+1))
387
 
                #       fi
388
 
                #done
389
389
                #Check whether the port number is already in etc/services file, and then add it
390
390
                cd /etc
391
391
                if grep -q "db2c_$cfgusername" services
417
417
                        juju-log "IBM DB2: Db2 already started for the user $cfgusername"
418
418
                else
419
419
                        su - $cfgusername -c 'db2start'
 
420
                        juju-log "IBM DB2: DB2 is started"
420
421
                fi
421
422
                juju-log " After db2start"
422
423
 
545
546
                        ./db2setup -r $CHARM_DIR/files/archives/db2installresfile/$rsp_file
546
547
                        juju-log "IBM DB2: Installation of db2 complete."
547
548
                        # Configure system values  for Db2
548
 
                        configure_system
 
549
                        #configure_system
549
550
                fi
550
551
        fi
 
552
        # Configure system values  for Db2
 
553
        configure_system
551
554
        #Create the required user to connect to db2
552
555
        create_user
553
556
        #Configure DFTDBPATH
554
557
        configure_dftdbpath
 
558
        juju-log "After Configure dftd"
555
559
        status-set active "IBM DB2 Installed"
556
560
        $CHARM_DIR/hooks/start
 
561
        juju-log "After calling start"
557
562
else
558
563
        juju-log "IBM DB2: Acceptable values for license is 'True' or 'False'"
559
564