Ubuntu Pastebin

Paste from root at Tue, 12 Jul 2016 17:46:37 +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
#!/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' 'user'`
my_port=`relation_call --state 'mysql.available' 'port'`
set +e
#result=`mysqlshow -h ${my_host}:${my_port} -u ${my_user} -p${my_pwd} pac | grep -o pac`
result=`mysql -h${my_host} -P${my_port} -u${my_user} -p${my_pwd} --skip-column-names -e "show databases like 'pac'"`
set -e
if [ "$result" == "pac" ]; then
        juju-log "IBM PAC Helper: pac database already exists. connecting to pac database."
else
	mysqladmin -h ${my_host} -u ${my_user} --password=${my_pwd} create database pac default character set utf8 default collate utf8_bin
	mysqladmin -h ${my_host} -u ${my_user} --password=${my_pwd} CREATE USER 'pacuser'@'%' IDENTIFIED BY 'pacuser'
	mysqladmin -h ${my_host} -u ${my_user} --password=${my_pwd} GRANT ALL PRIVILEGES ON pac.* to pacuser@'%' IDENTIFIED BY 'pacuser'
	mysqladmin -h ${my_host} -u ${my_user} --password=${my_pwd} GRANT ALL PRIVILEGES ON pac.* to pacuser@'localhost' IDENTIFIED BY 'pacuser'

       # mysqladmin -h ${my_host} -u ${my_user} -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