~jorge/charms/oneiric/owncloud/update-readme

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash

set -eu # -x for verbose logging to ensemble debug-log

hostname=`unit-get public-address`

juju-log "Retrived hostname: $hostname"
webdict="/var/www"

juju-log "Installing all components"

add-apt-repository -y ppa:charmers/charm-helpers
apt-get update
apt-get upgrade -y
apt-get install -qqy apache2 php5 php-pear php-xml-parser php5-sqlite php5-json sqlite  mp3info curl libcurl3 libcurl3-dev php5-curl zip wget charm-helper-sh php5-mysql

juju-log "Download source for owncloud version 2.0.1 and check for file integrity"

. /usr/share/charm-helper/sh/net.sh
LURL="http://owncloud.org/releases/owncloud-2.0.1.tar.bz2"
LHASH="24679dc0a0472f7ca7bba7422fdcf74d"
download=`ch_get_file $LURL $LHASH`
echo "downloaded $download"
tar -xjf $download --directory $webdict
cd /var/www
mv owncloud $hostname

#wget http://owncloud.org/releases/owncloud-2.0.1.tar.bz2 -O owncloud-2.0.1.tar.bz2

chown www-data:www-data -R /var/www/$hostname

juju-log "Virtualhost Configuration"

# Write the apache config
owncloud_vhost="/etc/apache2/sites-available/$hostname"
juju-log "Writing apache config file $owncloud_vhost"
cat > $owncloud_vhost <<EOF
<VirtualHost *:80>
  ServerName $hostname
  DocumentRoot /var/www/$hostname
  Options All
  ErrorLog /var/log/apache2/owncloud-error.log
  TransferLog /var/log/apache2/owncloud-access.log
  RewriteEngine On
</VirtualHost>
EOF
chmod 0644 $owncloud_vhost
 
# Configure apache
juju-log "Enabling apache modules: rewrite, vhost_alias"
a2enmod rewrite
a2enmod vhost_alias
juju-log "Enabling apache site: $hostname"
a2ensite $hostname
 
# Restart apache
juju-log "Restarting apache2 service"
/etc/init.d/apache2 restart

juju-log "#Increased upload limit and maximum size##"

sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 100M/g' /etc/php5/apache2/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 30M/g' /etc/php5/apache2/php.ini

/etc/init.d/apache2 reload

#Make owncloud2 publicly visible
open-port 80/tcp