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

1 by Victor Palau
lamp charm
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"
2 by Victor Palau
added option to set up a bzr branch for website installation
35
mysql -h $host -u $user --password=$password $database < ./config/mysql_conf
1 by Victor Palau
lamp charm
36
37
38
cp ./config/* /var/webconfig
39
40
juju-log "Exposing apache2 service"
41
open-port 80/tcp
42