~jorge/charms/precise/lamp/readme-fixes

« back to all changes in this revision

Viewing changes to hooks/db-admin-relation-changed

  • Committer: Victor Palau
  • Date: 2012-09-03 16:48:29 UTC
  • Revision ID: vtuson@gmail.com-20120903164829-n5ob87ro845fzgzh
lamp charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#set -ux
 
4
 
 
5
user=`relation-get user`
 
6
password=`relation-get password`
 
7
host=`relation-get private-address`
 
8
database=`config-get website-database`
 
9
if [ -z "$host" ] || [ -z "$user" ]; then
 
10
        juju-log "Waiting for complete setup"
 
11
        exit 0
 
12
fi
 
13
 
 
14
# Build config file to hold configuration options
 
15
 
 
16
juju-log "Building config file for $host"
 
17
cat > "config/$host" <<EOF
 
18
#!/bin/sh
 
19
 
 
20
server_name=${JUJU_REMOTE_UNIT%%/*}
 
21
server_user=${user}
 
22
server_pass=${password}
 
23
server_db=${database}
 
24
EOF
 
25
#
 
26
 
 
27
cat > "config/mysql" <<EOF
 
28
server_ip=${host}
 
29
EOF
 
30
#
 
31
 
 
32
juju-log "Building $database database on $host"
 
33
 
 
34
mysqladmin -h $host -u $user --password=$password create "$database"
 
35
#mysql -h $host -u $user --password=$password $database < $CREATE_SQL_FILE
 
36
 
 
37
 
 
38
cp ./config/* /var/webconfig
 
39
 
 
40
juju-log "Exposing apache2 service"
 
41
open-port 80/tcp
 
42