~george-edison55/charms/oneiric/thinkup/update-to-1-0-2

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
43
44
45
46
47
48
49
50
#!/bin/bash

set -e

# Copy our helper scripts to known locations
juju-log "Copying PHP scripts"
cp opt/* /usr/bin

# Install the Juju helper PPA
juju-log "Adding Juju helper PPA"
add-apt-repository ppa:charmers/charm-helpers
apt-get update

juju-log "Installing required packages"
export DEBIAN_FRONTEND=noninteractive
apt-get install -y php5-cli libapache2-mod-php5 php5-mysql php5-curl php5-gd mysql-client postfix unzip

juju-log "Downloading and verifying ThinkUp"
. /usr/share/charm-helper/sh/net.sh
DOWNLOAD=`ch_get_file http://cloud.github.com/downloads/ginatrapani/ThinkUp/thinkup_1.0.2.zip 29629fd162fd53a101439229c701fc2f`

if [ -z "$DOWNLOAD" ]; then
	juju-log "Failed to retrieve ThinkUp archive"
	exit 1
fi

juju-log "Extracting ThinkUp"
cd /var/www
unzip $DOWNLOAD

juju-log "Relocating files to document root"
rm index.html # this file is placed by Apache, we don't need it
mv thinkup/* .
rmdir thinkup
mv config.sample.inc.php config.inc.php

juju-log "Preparing initial configuration"
update_thinkup_config <<EOD
site_root_path='/'
EOD

juju-log "Assigning file ownership"
chown -R www-data:www-data .

juju-log "Restarting Apache"
service apache2 restart

# Make port 80 available
juju-log "Opening port 80"
open-port 80/tcp