Ubuntu Pastebin

Paste from lazypower at Thu, 16 Jun 2016 17:28:05 +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
#!/bin/bash
set -ex

source charms.reactive.sh


@when 'mysql.available'
@when 'apt.mysql-client.installed'
function run_mysql_commands(mysql) {
    '' Run database migrations, not idempotent, and this method will
        require additional work to pass review '''

# there is no library support here, so you will need to use a
# bash compliant tempting language if required. I chose sed for
# this operation. Comments left inline for clarity of approach.

# $ cat template.txt
# the number is ${i}
# the dog's name is ${name}

# $ cat replace.sed
# s/${i}/5/
# s/${name}/Fido/

sed -f replace.sed template.txt > out.txt

# $ cat out.txt
# the number is 5
# the dog's name is Fido

mysql -h ${mysql.host()}:${mysql.port()} -u ${mysql.username()} -p${mysql.password()}

}


reactive_handler_main
Download as text