5
# Retrieve this machine's hostname
6
HOSTNAME=`unit-get public-address`
7
juju-log "Hostname: $HOSTNAME"
9
# Retrieve the settings from the database
10
juju-log "Retrieving database relationship"
11
DATABASE=`relation-get database`
13
if [ -z "$DATABASE" ] ; then
14
juju-log "No database relationship set"
18
# Fetch the database configuration
19
juju-log "Retrieving database configuration"
20
DB_USER=`relation-get user`
21
DB_PASS=`relation-get password`
22
DB_HOST=`relation-get private-address`
24
# Update the data in the configuration file
25
juju-log "Updating configuration file"
26
update_thinkup_config <<EOD
33
# Execute the SQL that creates the tables
34
juju-log "Creating database tables"
35
mysql -u$DB_USER -p$DB_PASS -h$DB_HOST $DATABASE < /var/www/install/sql/build-db_mysql.sql