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
38
39
40
41
42
|
#!/bin/sh
set -ux
. lib/common.sh
# Check we haven't already been setup.
#if [ ! -f "$config_file" ]; then
# echo "Already Configured, Exiting"
#fi
user=`relation-get user`
password=`relation-get password`
host=`relation-get private-address`
database=`config-get control-database`
if [ -z "$host" ] || [ -z "$user" ]; then
juju-log "Waiting for complete setup"
exit 0
fi
# Build meta file to hold configuration options
juju-log "Building meta file for $host"
cat > "meta/$host" <<EOF
#!/bin/sh
server_user=${user}
server_pass=${password}
server_db=${database}
EOF
#
juju-log "Building $database database on $host"
mysqladmin -h $host -u $user --password=$password create "$database"
mysql -h $host -u $user --password=$password $database < $CREATE_SQL_FILE
juju-log "Exposing apache2 service"
open-port 80/tcp
# Generate configuration file!
build_cfg
|