Ubuntu Pastebin

Paste from root at Mon, 11 Jul 2016 17:20:25 +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
#!/bin/bash
set -ex

source charms.reactive.sh

@when 'mysql.available'
@when_not 'mysql-config.done'
function config_db() {

juju-log "IBM PAC: Logging into mysql console."
my_host=`relation_call --state 'mysql.available' 'host'`
my_pwd=`relation_call --state 'mysql.available' 'password'`
#my_user=`relation_call --state 'mysql.available' 'username'`
#my_port=`relation_call --state 'mysql.available' 'port'`

set +e
result=`mysqlshow -h ${my_host} -u root -p${my_pwd} pac | grep -o pac`
set -e
if [ "$result" == "pac" ]; then
        juju-log "IBM PAC Helper: pac database already exists. connecting to pac database."
else
        mysql -h ${my_host} -u root -p${my_pwd} << EOF
        create database pac default character set utf8 default collate utf8_bin;
        CREATE USER 'pacuser'@'%' IDENTIFIED BY 'pacuser';
        GRANT ALL PRIVILEGES ON pac.* to pacuser@'%' IDENTIFIED BY 'pacuser';
        GRANT ALL PRIVILEGES ON pac.* to pacuser@'localhost' IDENTIFIED BY 'pacuser';
EOF
	set_state 'mysql-config.done'
	status-set active "Ready"
fi
}
reactive_handler_main
Download as text