Ubuntu Pastebin

Paste from suchvenu at Wed, 13 Apr 2016 15:01:13 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@when 'db.ready'
@when_not 'db.sshconfigured'
function configure_sshkeys(){
        juju-log "************************In db available function ***********"
        #hostname=$(relation_call --state=db.available get_remotehostname) || true
        #juju-log "I got the remote host anme as $hostname"
        key=$(relation_call --state=db.available get_sshkeys) || true
        juju-log "I got the ssh key - $key"
        dbnames=$(relation_call --state=db.available get_dbnames) || true
        juju-log "I got db names - $dbnames"

        if [ -z "$key" ]; then
                juju-log "No data sent yet"
                exit 0
        fi

        #code from db-relation-changed of db2 charm
        # Add the key to the authorized_kesy file, if it exists
        set +e
        if [ -f $AUTH_KEY_FILE ]; then
                # Append only if the key is not present
                juju-log "IBM DB2: Updating the key file"
                grep "$key" $AUTH_KEY_FILE > /dev/null
                if [ $? != 0 ]; then
                        juju-log "IBM DB2: Updating authorized keys file"
                        echo "$key" >> $AUTH_KEY_FILE
                else
                        juju-log "Key already present"
                fi
        else
                        juju-log "IBM DB2: Creating authorized keys file"
                        echo "$key" > $AUTH_KEY_FILE
        fi
        set -e
        juju-log "IBM DB2: Completed updating the authorized key"
        set_state 'db.sshconfigured'
}
Download as text