~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-10-02 13:23:57 UTC
  • Revision ID: vtuson@gmail.com-20121002132357-3zi9hx2fgnjoag33
changed the charm to use mysql-shared

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
user=`relation-get user`
4
 
password=`relation-get password`
5
 
host=`relation-get private-address`
6
 
database=`config-get website-database`
7
 
if [ -z "$host" ] || [ -z "$user" ]; then
8
 
        juju-log "Waiting for complete setup"
9
 
        exit 0
10
 
fi
11
 
 
12
 
# Build config file to hold configuration options
13
 
juju-log "Building config file for $host"
14
 
cat > "config/$host" <<EOF
15
 
#!/bin/sh
16
 
 
17
 
server_name=${JUJU_REMOTE_UNIT%%/*}
18
 
server_user=${user}
19
 
server_pass=${password}
20
 
server_db=${database}
21
 
EOF
22
 
#
23
 
#creating file pointing to last configuration 
24
 
cat > "config/mysql" <<EOF
25
 
server_ip=${host}
26
 
EOF
27
 
#
28
 
 
29
 
#building the database
30
 
juju-log "Building $database database on $host"
31
 
mysqladmin -h $host -u $user --password=$password create "$database"
32
 
mysql -h $host -u $user --password=$password $database < ./config/mysql_conf
33
 
 
34
 
#setting up configuration files to be accessible by apache process
35
 
cp ./config/* /var/webconfig
36
 
chown -R www-data:www-data ./config
37
 
chown -R www-data:www-data /var/webconfig
38
 
chmod 640 ./config/*
39
 
chmod 640 /var/webconfig/*